agent-browser
Browser automation CLI for AI agents. Use when needs to interact with websites, including navigating pages, filling forms,…
Guide for writing ast-grep rules to perform structural code search and analysis. This skill should be used when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text
$ npx -y skills add archibate/dotfiles-opencode --skill ast-grep --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ast-grepContext preview
The summary Claude sees to decide when to auto-load this skill.
Guide for writing ast-grep rules to perform structural code search and analysis. This skill should be used when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text
name: ast-grep description: Guide for writing ast-grep rules to perform structural code search and analysis. This skill should be used when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search, or when a simple grep/glob search is insufficient for structural code pattern matching.
This skill helps translate natural language queries into ast-grep rules for structural code search. ast-grep uses Abstract Syntax Tree (AST) patterns to match code based on its structure rather than just text, enabling powerful and precise code search across large codebases.
Use this skill when users:
Follow this process to help users write effective ast-grep rules:
Clearly understand what the user wants to find. Ask clarifying questions if needed:
Write a simple code snippet that represents what the user wants to match. Save this to a temporary file for testing.
**Example:** If searching for "async functions that use await", create a test file:
// test_example.js
async function example() {
const result = await fetchData();
return result;
}Translate the pattern into an ast-grep rule. Start simple and add complexity as needed.
**Key principles:**
**Example rule file (test_rule.yml):**
id: async-with-await
language: javascript
rule:
kind: function_declaration
has:
pattern: await $EXPR
stopBy: endSee `references/rule_reference.md` for comprehensive rule documentation.
Use ast-grep CLI to verify the rule matches the example code. There are two main approaches:
**Option A: Test with inline rules (for quick iterations)**
echo "async function test() { await fetch(); }" | ast-grep scan --inline-rules "id: test
language: javascript
rule:
kind: function_declaration
has:
pattern: await \$EXPR
stopBy: end" --stdin**Option B: Test with rule files (recommended for complex rules)**
ast-grep scan --rule test_rule.yml test_example.js
**Debugging if no matches:** 1. Simplify the rule (remove sub-rules) 2. Add `stopBy: end` to relational rules if not present 3. Use `--debug-query` to understand the AST structure (see below) 4. Check if `kind` values are correct for the language
Once the rule matches the example code correctly, search the actual codebase:
**For simple pattern searches:**
ast-grep run --pattern 'console.log($ARG)' --lang javascript /path/to/project
**For complex rule-based searches:**
ast-grep scan --rule my_rule.yml /path/to/project
**For inline rules (without creating files):**
ast-grep scan --inline-rules "id: my-rule language: javascript rule: pattern: \$PATTERN" /path/to/project
Dump the AST structure to understand how code is parsed:
ast-grep run --pattern 'async function example() { await fetch(); }' \
--lang javascript \
--debug-query=cst**Available formats:**
**Use this to:**
**Example:**
# See the structure of your target code
ast-grep run --pattern 'class User { constructor() {} }' \
--lang javascript \
--debug-query=cst
# See how ast-grep interprets your pattern
ast-grep run --pattern 'class $NAME { $$$BODY }' \
--lang javascript \
--debug-query=patternTest a rule against code snippet without creating files:
echo "const x = await fetch();" | ast-grep scan --inline-rules "id: test language: javascript rule: pattern: await \$EXPR" --stdin
**Add --json for structured output:**
echo "const x = await fetch();" | ast-grep scan --inline-rules "..." --stdin --json
Simple pattern-based search for single AST node matches:
# Basic pattern search ast-grep run --pattern 'console.log($ARG)' --lang javascript . # Search specific files ast-grep run --pattern 'class $NAME' --lang python /path/to/project # JSON output for programmatic use ast-grep run --pattern 'function $NAME($$$)' --lang javascript --json .
**When to use:**
YAML rule-based search for complex structural queries:
# With rule file ast-grep scan --rule my_rule.yml /path/to/project # With inline rules ast-grep scan --inline-rules
小彭老师现在改用claude code的开源替代opencode,满足了开源人士旺盛的定制需求x(其实opencode中也可以继续用claude的闭源模型,只是换成了开源的opencode客户端) 安装方法:SETUP.md
Browser automation CLI for AI agents. Use when needs to interact with websites, including navigating pages, filling forms,…
Review common AI slops of defensive programming patterns, avoid silent errors. TRIGGER when reviewing code for defensive…
Best practices for AI-driven English-to-Chinese translation. This skill should be used when the user asks to "translate to…
This skill should be used when the user asks to "use bilibili API", "download bilibili video", "get bilibili user info", "list…
Interact with local Chrome browser session (only on explicit user approval after being asked to inspect, debug, or interact with…
Spec CLI surface area before implementation - command tree, flags, exit codes, I/O contract. Use when designing or planning a CLI…