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.
npx agentmods add skills/rolandbrecht/agent-skills/ast-code-graphnpx skills add rolandbrecht/agent-skills --skill ast-code-graphgit clone --depth 1 https://github.com/rolandbrecht/agent-skillsWrote 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.
[](https://agentmods.dev/skills/rolandbrecht/agent-skills/ast-code-graph)<a href="https://agentmods.dev/skills/rolandbrecht/agent-skills/ast-code-graph"><img src="https://agentmods.dev/badge/skills/rolandbrecht/agent-skills/ast-code-graph.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00196 | $0.03056 |
| Opus 5 | $0.00098 | $0.01528 |
| Sonnet 5 | $0.00039 | $0.00611 |
| Haiku 4.5 | $0.00020 | $0.00306 |
Grade A, and why
ast-code-graph 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 4d 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.
How it starts
The opening of the file, as written. The whole thing — 237 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AST & Code Graph Indexing
Overview
Text-based search (grep, ripgrep) finds string matches. AST-based analysis understands structure — it knows the difference between a function definition, a function call, a comment, and a string literal.
Primary tool: ast-grep (sg / ast-grep) — a fast, Rust-based CLI for structural code search, lint, and rewriting. It uses tree-sitter for parsing and supports 20+ languages out of the box.
Core principle: When the question is about code structure, use AST analysis. When the question is about text content, use grep.
Trigger Patterns
Detailed examples of when to trigger this skill:
| Category | Example queries |
|---|---|
| Structural pattern search | "useEffect without dependency array", "async functions without try-catch", "User.objects.get() without exception handling", "fetch() calls outside src/api/", "console.log inside class methods", "route handlers missing error handling" |
| Bulk code migration | wrap all async handlers, replace all X() calls with Y(), add error handling to all route handlers, rewrite deprecated API patterns across hundreds of files |
| Dependency & impact analysis | "what does analyzePayment depend on", "blast radius of changing X", "which modules depend on ./lib/database.js", "direct and transitive dependencies" |
| Safe renaming | "rename fetchUserData to getUserData safely", rename across TypeScript/JavaScript codebase |
| Dead code & circular imports | "exports never imported anywhere", "circular imports causing webpack bundle", unused exports, which npm dependencies are actually used in source |
| ast-grep rules | write an ast-grep rule, sg pattern, ast-grep syntax |
When to Use
Use this skill when the task involves:
| Task | Why AST beats grep |
|---|---|
| Refactoring / renaming | Grep finds the string in comments and strings too; AST finds only the symbol |
| Dead code detection | Grep can't tell if an export is actually imported elsewhere |
| Dependency tracing | "What modules does X depend on?" requires understanding import/require |
| Impact analysis | "If I change function X, what breaks?" needs call-graph traversal |
| Circular dependency detection | Requires building and analyzing a full import graph |
| Code migration | Rewriting deprecated API patterns structurally across a codebase |
| Custom linting | Enforcing project-specific patterns that standard linters don't cover |
What ships with it
16 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.
- package-lock.json 1.1 KB
- package.json 933 B
- references/ast-grep-cheatsheet.md 7.1 KB
- references/graph-schema.md 3.0 KB
- references/query-patterns.md 6.0 KB
- scripts/build-graph.py 11 KB runs code
- scripts/parse-js.mjs 3.8 KB runs code
- tests/__pycache__/test_build_graph.cpython-310.pyc 7.6 KB
- tests/__pycache__/test_build_graph.cpython-312.pyc 10 KB
- tests/fixtures/sample_helper.py 863 B runs code
- tests/fixtures/sample_module.py 1.2 KB runs code
- tests/fixtures/sample-cjs.js 549 B runs code
- tests/fixtures/sample-esm.mjs 447 B runs code
- tests/fixtures/sample-no-exports.js 180 B runs code
- tests/test_build_graph.py 5.1 KB runs code
- tests/test-parse-js.mjs 3.6 KB runs code
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.
- 4d ago First seen · 237 lines · 196 tokens per session scan A aad7bcda094b
ast-code-graph is a skill published in the GitHub repository rolandbrecht/agent-skills (4 stars, last pushed 22d ago), licensed MIT. It adds 196 tokens to every session and 3,056 once invoked, about $0.0010 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-31.
Other skills, from other repositories
r3f-animation
React Three Fiber animation - useFrame, useAnimations, spring physics, keyframes. Use when animating objects, playing GLTF animations, creating procedural motion, or implementing physics-based movement.
r3f-best-practices
React Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.
log-error-digest
Analyze log files to troubleshoot errors, identify peak error periods, and produce error clustering, frequency statistics, and time distribution reports. Supports JSON, syslog, and Nginx formats with automatic detection. Use when a user uploads a .log file and asks to analyze errors, find patterns, debug issues, or…
code-documenter
Use when adding docstrings, creating API documentation, or building documentation sites. Invoke for OpenAPI/Swagger specs, JSDoc, doc portals, tutorials, user guides.
lattice-init
Guided setup and upgrade-check experience for Lattice projects -- scans the repository, detects existing configuration and outdated conventions, suggests refiners and available upgrades in priority order, and creates or reconciles the .lattice/ config. Bridges the gap between installing skills and getting first value…
intelligent-investor-graham
Use Graham value investing for Is this investment or speculation, defensive stock screens, margin of safety, Mr. Market, allocation, funds, IPOs.