tool-ast-grep-rules

tool-ast-grep-rules is a skill for Claude Code, Codex from Heyvhuang/ship-faster. It costs 71 tokens per session (1,037 once invoked), scanned A, original, MIT.

A guide for writing ast-grep rules in YAML. ast-grep searches source code by its parsed structure, so rules can identify code patterns more precisely than plain text search.

In plain words
What is it for?
Writing lint rules, finding code patterns, modernizing code, and migrating APIs with optional automatic fixes.
Why use it?
It helps create repeatable checks and automated code changes without relying on fragile text matches. It also explains project configuration and the difference between standalone and project scans.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Writing lint rules, finding code patterns, modernizing code, and migrating APIs with optional automatic fixes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/heyvhuang/ship-faster/tool-ast-grep-rules
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Heyvhuang/ship-faster --skill tool-ast-grep-rules
Clone the repo
git clone --depth 1 https://github.com/Heyvhuang/ship-faster

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tool-ast-grep-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/heyvhuang/ship-faster/tool-ast-grep-rules/github.svg)](https://agentmods.dev/skills/heyvhuang/ship-faster/tool-ast-grep-rules)
Your own site
<a href="https://agentmods.dev/skills/heyvhuang/ship-faster/tool-ast-grep-rules"><img src="https://agentmods.dev/badge/skills/heyvhuang/ship-faster/tool-ast-grep-rules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tool-ast-grep-rules

Your own site · 80×15
<a href="https://agentmods.dev/skills/heyvhuang/ship-faster/tool-ast-grep-rules"><img src="https://agentmods.dev/badge/skills/heyvhuang/ship-faster/tool-ast-grep-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,037 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00071 $0.01037
Opus 5 $0.00036 $0.00518
Sonnet 5 $0.00014 $0.00207
Haiku 4.5 $0.00007 $0.00104

Measured 12d ago against content hash e3b4d5991832, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

tool-ast-grep-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/tool-ast-grep-rules/SKILL.md · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ast-grep Rule Crafter

ast-grep uses tree-sitter to parse code into AST, enabling precise pattern matching. Rules are defined in YAML for linting, searching, and rewriting code.

Quick Start

id: no-console-log
language: JavaScript
rule:
  pattern: console.log($$$ARGS)
fix: logger.log($$$ARGS)
message: Replace console.log with logger

Project Configuration

Project-level scanning requires an sgconfig.yml configuration file:

# sgconfig.yml (project root)
ruleDirs:
  - rules          # Rule directory, recursively loads all .yml files

Typical project structure:

my-project/
├── sgconfig.yml
├── rules/
│   ├── no-console.yml
│   └── custom/
│       └── team-rules.yml
└── src/

Running project scan:

ast-grep scan              # Automatically finds sgconfig.yml
ast-grep scan --config path/to/sgconfig.yml  # Specify config

Note: ast-grep scan command requires sgconfig.yml, while ast-grep run -p can be used standalone.

Rule Workflow

Lint Rule (Common)

Check only without fixing, used for CI/editor hints:

# rules/no-console-log.yml
id: no-console-log
language: JavaScript
severity: warning
message: Avoid console.log in production code
rule:
  pattern: console.log($$$ARGS)

Verify:

ast-grep scan -r rules/no-console-log.yml src/

Rewrite Rule (Optional)

Add fix when auto-fix is needed:

id: no-console-log
language: JavaScript
severity: warning
message: Replace console.log with logger
rule:
  pattern: console.log($$$ARGS)
fix: logger.log($$$ARGS)

Apply fix:

ast-grep scan -r rules/no-console-log.yml --update-all src/

Development Workflow

- [ ] 1. Explore pattern with CLI: ast-grep -p 'pattern' src/
- [ ] 2. Create rule file (.yml)
- [ ] 3. Verify: ast-grep scan -r rule.yml src/
- [ ] 4. If false positives → add constraints → re-verify

Debug AST structure:

ast-grep -p 'console.log($ARG)' --debug-query ast

Essential Syntax

Read the full file on GitHub · 146 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 146 lines · 71 tokens per session scan A e3b4d5991832

Subscribe to this mod's changes

tool-ast-grep-rules is a skill published in the GitHub repository Heyvhuang/ship-faster (339 stars, last pushed 28d ago), licensed MIT. It adds 71 tokens to every session and 1,037 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

qt-qml-review

Invoke when the user asks to review, check, audit, or look over Qt6 QML code -- or suggest before committing. Runs deterministic linting (47+ rules) then six parallel deep- analysis agents covering bindings, layout, loaders, delegates, states, and performance. Optionally invokes system qmllint for type-level checks.…

mavlink/qgroundcontrol · 95 tokens

verify-behavior

Verify or reproduce visible product behavior by driving the real UI with pi-computer-use's checked tools, requiring verified expect postconditions and durable state evidence for meaningful UI flows. Use when triage needs visual reproduction, implementation needs behavioral proof, review needs interactive confirmation…

nicknisi/dotfiles · 68 tokens

recipe-front-review

Reviews completed frontend implementation for governing-source compliance, scope economy, repository quality, and security, then applies user-approved React corrections.

shinpr/claude-code-workflows · 29 tokens

qa-frontend

Internal PostHog developer frontend/browser QA skill. Use only when a PostHog developer explicitly asks to run frontend QA, browser-test a PR, verify a UI flow against the local PostHog stack, use qa-frontend, or QA current frontend changes with browser/runtime evidence. Do not use for generic code review, PR review…

PostHog/posthog · 142 tokens

frontend-architecture

Frontend component architecture review — dispatch the component-architecture-review agent over the frontend component files to catch reusable components that should be extracted, duplicated UI patterns, prop drilling, component-granularity problems, and inconsistent component APIs as a frontend evolves. Use when the…

bdfinst/agentic-dev-team · 106 tokens

review-persistence-security-resources

Normative reviewer for persistence, settings, secrets, logging hygiene, resources, caches, cross-platform behavior and long-lived state in the explyt/spring-plugin IntelliJ plugin. Use when reviewing changes that touch PersistentStateComponent, settings UI, credentials, caches, service fields, logging, file paths…

explyt/spring-plugin · 83 tokens