ast-code-graph

ast-code-graph is a skill for Claude Code, Codex from rolandbrecht/agent-skills. It costs 196 tokens per session (3,056 once invoked), scanned A, original, MIT.

A code-analysis workflow that understands program structure, including definitions, calls, imports, and dependencies, instead of only matching text. It uses syntax trees, which represent how code is arranged.

In plain words
What is it for?
It helps locate structural patterns, analyze dependencies and impact, find dead code, and identify code that needs refactoring.
Why use it?
It reduces mistakes when searching for symbols, tracing what a change may affect, or finding unused code. Plain text search can also match comments, strings, or unrelated names.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/rolandbrecht/agent-skills/ast-code-graph
Any agent
npx skills add rolandbrecht/agent-skills --skill ast-code-graph
Clone the repo
git clone --depth 1 https://github.com/rolandbrecht/agent-skills

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 ast-code-graph

README.md
[![agentmods](https://agentmods.dev/badge/skills/rolandbrecht/agent-skills/ast-code-graph.svg)](https://agentmods.dev/skills/rolandbrecht/agent-skills/ast-code-graph)
Your own site
<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>
Per session 196 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,056 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00196 $0.03056
Opus 5 $0.00098 $0.01528
Sonnet 5 $0.00039 $0.00611
Haiku 4.5 $0.00020 $0.00306

Measured 4d ago against content hash aad7bcda094b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

The scan reads SKILL.md. This mod also ships 9 executable files (scripts/build-graph.py, scripts/parse-js.mjs, tests/fixtures/sample_helper.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

ast-code-graph/SKILL.md · 237 lines

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

Read the full file on GitHub · 237 lines

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. 4d ago First seen · 237 lines · 196 tokens per session scan A aad7bcda094b

Subscribe to this mod's changes

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.

Related

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.

zebbern/claude-code-guide · 43 tokens

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.

zebbern/claude-code-guide · 74 tokens

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…

zebbern/claude-code-guide · 71 tokens

code-documenter

Use when adding docstrings, creating API documentation, or building documentation sites. Invoke for OpenAPI/Swagger specs, JSDoc, doc portals, tutorials, user guides.

zebbern/claude-code-guide · 39 tokens

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…

techygarg/lattice · 115 tokens

intelligent-investor-graham

Use Graham value investing for Is this investment or speculation, defensive stock screens, margin of safety, Mr. Market, allocation, funds, IPOs.

simbajigege/book2skills · 37 tokens