Skip to content

codegraph-ai/codegraph-rules-for-agents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeGraph rules for agents

Pre-configured rule files that teach AI coding agents to use CodeGraph before falling back to grep, AST scripts, or filesystem walks.

CodeGraph is a local semantic code graph with persistent RocksDB storage, 38 language parsers, and 32+ MCP tools — see the main README or marketplace listing.

What this does

The rule files in this directory tell your AI agent:

  1. Call CodeGraph tools first for code-structural questions (callers, callees, impact, dependency graphs, complexity, dead code, semantic symbol search).
  2. Use the curated AI-context tools (codegraph_get_edit_context etc.) instead of reading multiple files blindly.
  3. Persist discoveries via the memory subsystem so future sessions can retrieve debugging insights, decisions, conventions, and known issues.
  4. Tag stored memories with agentSource so cross-agent attribution shows up in codegraph_memory_list.
  5. Maintain a codegraph-sources.md at the repo root tracking which workspaces have been indexed.

Quick setup

Copy the rule file for your agent into the agent's rules directory:

# Claude (Claude Code, claude.ai/code)
cp .claude/agents/codegraph.md ~/.claude/agents/

# Cursor
cp .cursor/rules/codegraph.mdc ~/.cursor/rules/

# Windsurf
cp .windsurf/rules/codegraph.md ~/.windsurf/rules/

# Codex
cp .codex/prompts/codegraph.md ~/.codex/prompts/

# Cline (VS Code extension)
cp .clinerules/codegraph.md ~/.clinerules/

# Generic / unspecified agent
cp general-agents/AGENTS.md ~/.claude/AGENTS.md   # or wherever your agent reads system prompts

You can also drop them in the project root instead of the home directory to scope the rules to a single repo (e.g. <repo>/.claude/agents/codegraph.md).

Prerequisites

Your agent needs access to the CodeGraph MCP server. Install one of:

  • VS Code extension: aStudioPlus.codegraph (marketplace) — auto-starts the LSP server when you open a workspace
  • MCP server (standalone): npx -y @astudioplus/codegraph-mcp — configure as an MCP server in Claude Desktop / Cursor / Cline etc.

After install, the first session indexes your workspace (1-5 min depending on size). Subsequent sessions load instantly from the persisted graph.

Files

File For Notes
.claude/agents/codegraph.md Claude (Claude Code, claude.ai/code) Includes tools: allowlist in frontmatter
.cursor/rules/codegraph.mdc Cursor Always-applied rule (alwaysApply: true)
.windsurf/rules/codegraph.md Windsurf Plain markdown
.codex/prompts/codegraph.md Codex Plain markdown
.clinerules/codegraph.md Cline Plain markdown
general-agents/AGENTS.md Any agent / generic Most detailed; use as reference

The files differ mainly in frontmatter format and the agentSource string the rule tells the agent to pass when storing memories. The core content (tool cheatsheet + workflow rules) is consistent.

Tool profiles — narrow the surface

If your agent's prompt context fills up listing 32 tools, launch the MCP server with --profile=core|graph|memory|security|all (or set CODEGRAPH_TOOL_PROFILE):

  • core — 8 tools (search + symbol info + AI context)
  • graph — 16 tools (callers/callees/deps/impact/traverse)
  • memory — 7 tools (codegraph_memory_*)
  • security — Pro security tools only (community: empty)
  • all — default, every tool

Contributing

  • Add configurations for new agents (Aider, Continue, etc.) — PRs welcome
  • Improve the tool cheatsheet / workflow rules
  • Share patterns that worked well in your sessions

Links

About

Pre-configured rule files for AI coding agents to use CodeGraph effectively.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors