Agent Skills & Prompts
Relevant source files
The following files were used as context for generating this wiki page:
Agent Skills and Prompts form the orchestration layer of the code-review-graph system, enabling AI coding assistants to interact effectively with the underlying knowledge graph. This module provides structured guidance, automated hooks, and platform-specific configurations for tools like Claude Code, Cursor, and GitHub Copilot to ensure token-efficient codebase exploration and high-accuracy code reviews.
Sources: code_review_graph/skills.py:1-12, code_review_graph/prompts.py:1-10, CLAUDE.md:1-10
Agent Skill Architecture
Skills are defined as specialized instruction sets that guide an AI agent through complex workflows such as debugging, refactoring, or reviewing pull requests. The system automatically generates these skills in Markdown format, often including frontmatter metadata for the host AI platform.
Skill Categories
The project defines four primary internal skills used to structure agent behavior:
| Skill Name | Description | Key Focus Area |
|---|---|---|
| Explore Codebase | Navigate structure via knowledge graph | Architectural overview and relationship tracing |
| Review Changes | Structured, risk-aware code review | Change detection and impact radius analysis |
| Debug Issue | Systematically trace and resolve bugs | Semantic search and execution flow tracing |
| Refactor Safely | Plan/execute safe refactoring | Dead code detection and rename previews |
Sources: code_review_graph/skills.py:270-400
Skill Generation Flow
The generate_skills function manages the creation of these instructions, placing them in platform-specific directories like .claude/skills/ or .gemini/skills/.
Sources: code_review_graph/skills.py:403-432
MCP Prompt Templates
Prompt templates provide multi-turn conversation starters for AI agents, enforcing the "Graph-First" workflow. Every prompt follows the Token Efficiency Rules, which mandate using minimal context before escalating to deeper inspections.
Core Prompts
- review_changes_prompt: A workflow for pre-commit reviews that starts with a risk overview and drills into high-risk functions.
- architecture_map_prompt: Generates architecture documentation including Mermaid diagrams and community coupling summaries.
- debug_issue_prompt: Uses semantic search keywords to find relevant nodes and trace call chains.
- onboard_developer_prompt: Orients new developers using high-level stats and critical execution flows.
- pre_merge_check_prompt: A GO/NO-GO assessment focused on test gaps and newly introduced dead code.
Sources: code_review_graph/prompts.py:44-123, code_review_graph/main.py:645-685
Prompt Data Flow
Prompts are registered within the FastMCP server and return a list of Message objects to the client.
Platform Hooks & Automation
To keep the knowledge graph synchronized with the source code, the system installs automated hooks into various IDEs and version control systems.
Git Pre-Commit Hook
The install_git_hook function creates a pre-commit script in the .git/hooks directory. This script runs detect-changes --brief to surface risk summaries to the developer before a commit is finalized.
Sources: code_review_graph/skills.py:539-585, AGENTS.md:59-66
Editor Hooks
The system supports specific hook configurations for different AI environments:
- Claude Code/Qoder: Uses
PostToolUseandSessionStartmatchers to trigger graph updates after file edits. - Cursor: Installs shell scripts (e.g.,
crg-update.sh) into~/.cursor/hooks/for events likeafterFileEditandbeforeShellExecution. - OpenCode: Deploys a TypeScript plugin that uses the Bun shell API to monitor
file.editedevents.
Sources: code_review_graph/skills.py:435-517, code_review_graph/skills.py:801-850, code_review_graph/skills.py:910-970
Token Efficiency Rules
A critical component of all skills and prompts is the enforcement of token-saving protocols to minimize LLM overhead.
- Initial Call: Agents MUST start with
get_minimal_context(task="<description>"), costing ~100 tokens. - Detail Level: Use
detail_level="minimal"by default; only escalate to "standard" for specific entities. - Tool Targets: Aim for ≤5 tool calls per task and ≤800 total context tokens.
- Targeted Queries: Prefer
query_graph_toolwith a specific symbol over broad list commands.
Sources: CLAUDE.md:12-18, code_review_graph/prompts.py:16-30, skills/review-pr/SKILL.md:11-13
Summary
Agent Skills & Prompts provide the interface between the user's intent and the system's structural intelligence. By combining platform-specific skill files with standardized MCP prompt templates and automated execution hooks, the module ensures that AI agents interact with the codebase in a structurally aware, risk-scored, and token-efficient manner.
Sources: code_review_graph/skills.py:1-12, CLAUDE.md:162-178