Guide · Agent skill
How to use the codegraph agent skill: install and query code graphs
Updated · written with AI from the project's own documentation and checked against our catalogue data
The codegraph skill teaches an AI coding agent to build and query a knowledge graph of a software project, covering functions, call chains, imports, classes and git history, plus semantic embeddings for similarity search. It is built on CodeScope and is useful for developers exploring a large unfamiliar codebase, and for maintainers triaging bugs or reviewing open pull requests. After this guide you will be able to install the skill, create an index for a repository, and ask your agent questions that a plain text search cannot answer well.
Quick start
- 1Install codegraph-ai. Create a virtual environment and run pip install codegraph-ai. This provides the codegraph command.
- 2Place the skill folder. Unzip the downloaded skill into ~/.claude/skills/ or into your project's .claude/skills/ folder, or upload the ZIP under Settings → Capabilities → Skills in the Claude apps.
- 3Index your repository. From the repository root, run codegraph init --repo . --lang auto --commits 500 to build the structure and history graph.
- 4Check the index. Run codegraph status --db $CODESCOPE_DB_DIR to confirm the index exists and is readable.
- 5Ask a natural question. Describe what you want, such as who calls a function or which code is dead, and the agent will query the graph.
- 6Generate a report. Run codegraph analyze --db $CODESCOPE_DB_DIR --output report.md for a written architecture overview.
What does the codegraph skill make the agent do?
An agent skill is a folder of instructions and scripts that an AI agent loads when a task matches its description. This skill tells the agent how to use CodeScope, which indexes source code into two layers: structure (functions, calls, imports, classes, modules) and evolution (commits, file changes, function modifications). Each function also gets a semantic embedding.
With this in place the agent can answer questions such as who calls a function, which code is dead or highly coupled, or what a change might affect, instead of relying only on text search. It can also fetch GitHub issues to trace bugs to likely code locations and help score and compare open pull requests.
- Call graphs, callers and callees, and dependencies
- Dead code, hotspots, module coupling and architecture reports
- Semantic search and impact analysis
- Bug root cause analysis from GitHub issues
- Class diagrams (UML) and PR review with risk scoring, conflict detection and labeling
Install the codegraph skill
Download the ZIP of the skill from this page and unzip it. For a personal install, place the folder in ~/.claude/skills/. For a single project, place it in that project's .claude/skills/ folder. Alternatively, in the Claude apps go to Settings → Capabilities → Skills and upload the ZIP.
The skill also needs the codegraph-ai Python package. Install it in a virtual environment so it stays isolated from your other tools.
- Requires Python with pip
- Files included: SKILL.md, bug-analysis.md, pr-analysis.md, patterns.md, schema.md, and evals/evals.json
pip install codegraph-aiCreate or check a code index
The skill works on an indexed repository. Run the index command from the root of a git repository. The --lang auto option detects languages from file extensions. The --commits flag ingests git history, which is needed for evolution queries; without it only structural analysis is available.
To check an existing index, point the status command at its database directory. If you have a pre-built database, you can set CODESCOPE_DB_DIR to skip indexing.
- Supported languages: Python, JavaScript/TypeScript, C and Java
- Add --backfill-limit 200 to compute function-level MODIFIES edges (slower; enables change_attribution and co_change)
- Set HF_HUB_OFFLINE=1 to use HuggingFace models offline
codegraph init --repo . --lang auto --commits 500Trigger the skill with natural requests
You do not need to name the skill. The skill applies when your request involves code structure, or when a .codegraph index exists in the workspace, or when you ask to create one. Describe what you want to know in plain language and the agent decides when to use the graph.
Good requests name the thing you care about: a function, a module, a bug report number, or a pull request.
- Who calls parse_config, and what breaks if I change it?
- Which functions in this project are dead code?
- Which modules are most tightly coupled?
- Why does this project have so many bugs? Trace issue 1234 to code.
- Generate a class diagram for the payment classes.
- Review the open pull requests and tell me which ones conflict.
Run analyses from the CLI or Python
Use the CLI for status and reports. Use the Python API when you want raw Cypher queries or custom analysis. The API provides methods such as hotspots, dead_code, circular_deps, module_coupling and impact, and always closes the connection when finished.
- Report: codegraph analyze --db $CODESCOPE_DB_DIR --output report.md
- Cypher example: find callers of a function with MATCH (caller:Function)-[:CALLS]->(f:Function {name: ...})
codegraph analyze --db $CODESCOPE_DB_DIR --output report.mdSafety notes: scripts and network access
This skill runs scripts and uses the network. Indexing and analysis run local Python code against your repository. Fetching GitHub issues or PRs and applying labels requires GitHub access, and the source does not state the token requirement, so check the bundled documentation before supplying one. Model downloads for sentence-transformers embeddings also use the network unless you use an offline or mirror setup.
Applying GitHub labels changes shared project state. Review analysis results before letting the agent label a live repository.
- Use HF_HUB_OFFLINE=1 once models are cached
- Use HF_ENDPOINT to point at a mirror if HuggingFace is unreachable
- Review labels before applying them to a shared repository
Tips for better results
Index once and reuse the database. Re-running indexing on every question is slow. Use git history if you ask about why something changed, since evolution queries depend on it.
Ask narrow questions first. A specific function or issue number gives the agent a clear starting point for graph queries.
- Keep the index in the project so the agent finds .codegraph automatically
- Use the Python API for chained or custom queries
- Use the PR analysis workflow to write a prioritized report to a file
What people use it for
- Find who calls a function before changing its signature
- Locate dead code and highly coupled modules in a large codebase
- Trace a GitHub bug report to likely code locations
- Generate a class diagram showing composition and inheritance
- Score open pull requests for risk and spot cross-PR conflicts
Frequently asked questions
Is the codegraph skill free to use?
The source is released under the Apache-2.0 licence. The skill and the codegraph-ai package are installed with pip, and the source does not list any pricing.
What do I need to run the codegraph skill?
You need Python with pip to install codegraph-ai, and a git repository to index. Git history is needed for evolution queries. Optional extras are a HuggingFace model download or mirror for embeddings, and GitHub access with a token for issues, PR review and labels.
Which languages does codegraph support?
It supports Python, JavaScript/TypeScript, C and Java. Code in other languages is outside what the skill covers.
How do I install the codegraph skill in Claude?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or a project's .claude/skills/ folder. You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.
Why does the agent say no index was found?
The skill applies when a .codegraph index exists or when you ask to create one. Create an index with codegraph init from the repository root, or set CODESCOPE_DB_DIR to a pre-built database.
Should I use codegraph instead of grep?
For a small project, grep or your IDE is usually enough, because building an index adds setup cost. The graph helps most with questions about callers, call chains, coupling and change impact in larger codebases.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose the codegraph skill if you work in a large Python, JavaScript/TypeScript, C or Java project and need call graphs, architecture overviews, bug tracing or PR triage. Skip it for small projects, other languages, or any case where you want automatic PR labelling without human review.
Download the skill