ast-grep
Use when you need ast-grep structural search, linting, or safe codemod rewrites, especially for requests that mention ast-grep, sg, codemod, rule files, or…
Skill by matt-riley
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/matt-riley-ast-grep
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/ast-grep
What's inside
- Skill name
ast-grep- Description
- Use when you need ast-grep structural search, linting, or safe codemod rewrites, especially for requests that mention ast-grep, sg, codemod, rule files, or syntax-aware edits instead of plain-text search.
- License
- GPL-3.0
- Metadata
- kind: task · version: 2.0.1 · audience: general-coding-agent · category: workflow · maturity: draft
- Instructions
- 102 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (8)
- SKILL.md
- openai.yaml · agents/
- examples.md · assets/
- evals.json · evals/
- trigger-queries.json · evals/
- command-patterns.md · references/
- safety-and-review.md · references/
- scaffold-ast-grep-command.mjs · scripts/
SKILL.md (first lines)
# ast-grep Use this skill when the task benefits from AST-based search, linting, or rewrites instead of regex- or line-based editing. ## Use this skill when - You need structural search over code, lint-rule authoring, or rewrite changes with AST-aware patterns. - You want repeatable, reviewable edits across many files. - You want to preview candidate matches before applying a codemod. - A request explicitly mentions `ast-grep`, `sg`, codemod, rule files, or syntax-aware edit work. ## Do not use this skill when - The task is simple literal string search; route to normal `rg`/`glob` usage. - The request is under-specified and needs sharpening first; route to `reverse-prompt`. - The main work is root-cause analysis of a failure; route to `systematic-debugging`. - The task is writing behavior tests first for a feature or bugfix; route to `test-driven-development`. ## Routing boundary | Situation | Use this skill? | Route instead | | --- | --- | --- | | "Author a lint rule for a structural pattern" | Yes | - | | "Replace a JS API call pattern across all TS files safely" | Yes | - | | "Find where this exact string appears" | No | direct `rg` search | | "I have a failing test and do not know why" | No | `systematic-debugging` | | "Before coding, rewrite my vague request into an executable brief" | No | `reverse-prompt` | | "Implement feature X with failing test first" | No | `test-driven-development` | ## Inputs to gather **Required before editing** - Goal: search, lint, or rewrite. - Target language(s) and search scope (paths/directories). - Structural pattern and, for rewrites, replacement pattern or rule file. **Helpful if present** - Existing ast-grep rule files in the repository. - Known exclusions (`dist`, generated code, vendored directories). - Expected output format (human-readable vs JSON for tooling). **Only investigate if encountered** - Parser/language mismatch warnings. - Rewrite collisions where one pass affects later matches. - File-encoding or formatting side effects. ## First move 1. Choose mode: search, lint, or rewrite. 2. Build a narrow command from the reference templates and run a preview first. 3. Expand scope only after the preview matches the intended shape. ## Workflow 1. Build a search or rewrite command from [`references/command-patterns.md`](references/command-patterns.md) and constrain it by language/path. 2. For search or lint work, inspect representative results before broadening scope. 3. If rewrite is needed, choose replacement (`-r`) or rule-file mode (`--rule`) and re-run preview. 4. Apply rewrite only after preview is clean and exclusions are explicit. 5. Review resulting diffs and check for unintended changes using the safety checklist in [`references/safety-and-review.md`](references/safety-and-review.md). 6. If output is noisy, roll back and tighten pattern/scope before retrying. ## Outputs - A documented ast-grep command (or rule invocation) used for the task. - For rewrites, a clean diff showing intended structural edits only. - For linting, a tested rule file or rule invocation. - A short summary of matched scope, applied exclusions, and any rollback/retry decisions. ## Guardrails - Default to non-destructive flow: preview before apply. - Never run broad rewrites without explicit language and scope constraints. - Prefer the full `ast-grep` binary name in docs and generated commands; use `sg` only if local shell compatibility requires it. - Keep command examples portable (repo-relative paths only, no user-specific absolute paths). - Treat helper automation as optional convenience; do not require it to use this skill. - If pattern intent is ambiguous, narrow to search mode first instead of guessing rewrite behavior. ## Validation - Validate each ast-grep command against the requested language, scope, and output format before applying any rewrite. - Confirm every support file listed in `## Reference files` exists and is linked. - Smoke-test description-level routing with one trigger and one near-miss: - should trigger: `Use ast-grep to rewrite obj.val && obj.val() to obj.val?.() in TypeScript, preview first` - should not trigger: `Find the exact string "obj.val && obj.val()" in this repository.` ## Examples - `Use ast-grep to search for \`console.log($X)\` in \`src/\` with \`--lang ts\` and return JSON output.` - `Use ast-grep to rewrite \`var code = $PAT\` to \`let code = $PAT\` in JavaScript after previewing matches.` - `Use ast-grep to rewrite \`obj.val && obj.val()\` to optional chaining in TypeScript after a narrow preview.` ## Reference files - [`references/command-patterns.md`](references/command-patterns.md) - search/rewrite command templates and scoped usage patterns - [`references/safety-and-review.md`](references/safety-and-review.md) - review checklist, rollback flow, and failure-mode handling - [`assets/examples.md`](assets/examples.md) - trigger and near-miss prompt matrix for activation tuning - [`scripts/scaffold-ast-grep-command.mjs`](scripts/scaffold-ast-grep-command.mjs) - optional helper to scaffold portable ast-grep commands
From matt-riley/agent-skills, GPL-3.0.
More from matt-riley/agent-skills
- 0.614score
code-intelligence
matt-riley
Use when navigating or refactoring code — choosing between LSP, rg, or semantic search tools; an LSP call returns empty and you need to know if it failed; or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
code-tour
matt-riley
Use when asked to create a .tour walkthrough — onboarding, PR review, RCA, architecture, or any persona-targeted step-by-step code narrative.
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-governance
matt-riley
Use this skill when building AI agents that call external tools, implementing policy-based access controls, adding semantic intent classification, creating…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agentic-eval
matt-riley
Use when designing or implementing an evaluation loop for AI agent outputs — reflection loops, evaluator-optimizer pipelines, LLM-as-judge scoring, or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
api-smoke-validation
matt-riley
Use when running quick, repeatable API smoke tests after changes with hurl, including auth, status-code, response-shape, endpoint sanity, and pre-integration…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-sdk-v2-to-v3-migration
matt-riley
Use when the codebase still imports from 'aws-sdk' v2, uses new AWS.*() constructors, .promise() calls, AWS.config.update(), DocumentClient, or s3.upload() —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
circleci-to-github-actions-migration
matt-riley
Use when a repository still depends on .circleci/config.yml jobs, workflows, or artifacts that need to be replaced or phased out with GitHub Actions —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
mocha-to-jest-migration
matt-riley
Use when a JavaScript or TypeScript suite still depends on Mocha, Chai, or Sinon and needs an incremental Jest migration.
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
project-references-migration
matt-riley
Use when a layered TypeScript workspace needs an incremental project-references migration without breaking package boundaries or editor resolution.
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-instructions
matt-riley
Use when creating or updating agent instruction files (AGENTS.md for Pi, copilot-instructions.md for Copilot, per-path guides, or AGENTS.md router) —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
autoresearch
matt-riley
Use when running autonomous iterative experiments to optimize a measurable metric on an existing codebase — not for writing tests or diagnosing a specific…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-lambda-go-deployment
matt-riley
Use when deploying or debugging Go-based AWS Lambda packaging, bootstrap, runtime, or handler issues — not when the main failure is SAM stack wiring, IAM OIDC…
SkillAFreshness: A★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 0
- Open issues
- 1
- Last commit (this folder)
- Sep 24, 2026 (1 month ago)
- Last release
- Oct 23, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 2.0.1
- License
- GPL-3.0
- Repository
- github.com/matt-riley/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from matt-riley
- 0.614score
agent-instructions
matt-riley
Use when creating or updating agent instruction files (AGENTS.md for Pi, copilot-instructions.md for Copilot, per-path guides, or AGENTS.md router) —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-supply-chain
matt-riley
Use this skill when generating SHA-256 integrity manifests for agent plugins, verifying that installed plugins match their manifests, detecting tampered…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agentic-eval
matt-riley
Use when designing or implementing an evaluation loop for AI agent outputs — reflection loops, evaluator-optimizer pipelines, LLM-as-judge scoring, or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
api-smoke-validation
matt-riley
Use when running quick, repeatable API smoke tests after changes with hurl, including auth, status-code, response-shape, endpoint sanity, and pre-integration…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-sdk-v2-to-v3-migration
matt-riley
Use when the codebase still imports from 'aws-sdk' v2, uses new AWS.*() constructors, .promise() calls, AWS.config.update(), DocumentClient, or s3.upload() —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-governance
matt-riley
Use this skill when building AI agents that call external tools, implementing policy-based access controls, adding semantic intent classification, creating…
SkillAFreshness: A★ 4Claude Code +9
Cite this page
ast-grep skill. Agent Mart. https://agentmart.dev/skills/matt-riley-ast-grep (last updated 2026-10-24)