代码图上下文
- 作者仓库星标 3,585
- 作者仓库 CodeGraphContext
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @CodeGraphContext · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# CodeGraphContext (CGC)
## When to use this skill
- Indexing or re-indexing a codebase for AI or CLI queries.
- Explaining how to install and run `cgc`, choose a database backend, or wire MCP into an editor.
- Interpreting CGC tools: `codegraph_find_code`, `analyze_code_relationships`, `add_code_to_graph`, etc.
## Core workflow
1. **Install**: `pip install codegraphcontext` (or `pipx install codegraphcontext`). With **uv**, `uv tool install codegraphcontext` or `uvx codegraphcontext …` is supported; if a parser fails with `ModuleNotFoundError: tree_sitter_c_sharp`, run with an explicit extra package, e.g. `uvx --with tree-sitter-c-sharp codegraphcontext …`.
2. **Configure**: Optional `~/.codegraphcontext/.env` for `DEFAULT_DATABASE`, Neo4j URI, or Kùzu path. Run `cgc doctor` if connections fail.
3. **Index**: From the repo root, `cgc index .` (or `cgc index --force .` to rebuild). Ensure CLI and MCP use the same config so they see the same graph.
4. **Query**: CLI (`cgc find`, `cgc query`, …) or MCP tools after `cgc mcp setup` / `cgc mcp start` in the client config.
## MCP setup (short)
- Run `cgc mcp setup` and pick the editor, or add a server entry that runs `cgc` with args `mcp` `start` and the same env as the CLI.
- **OpenCode**: Follow the vendor MCP docs for registering a stdio server, then point the command at `cgc` with arguments `mcp`, `start` (same as other editors). Official OpenCode MCP overview: [OpenCode MCP servers](https://opencode.ai/docs/ko/mcp-servers/#_top).
## Agent behavior
- Prefer **indexing the workspace** before deep graph queries if the user has not indexed yet.
- For **fuzzy symbol search** on Kùzu/Falkor backends, matching is typo-tolerant (edit distance); on Neo4j, full-text fuzzy uses Lucene-style terms—preserve **original casing** in queries when fuzziness matters for camelCase symbols.
- If **`Repository.path` is missing** in the DB, that row is skipped for path checks and a **warning is logged** when repositories are listed; suggest cleaning stale `Repository` nodes (see Neo4j example in logs) if it keeps happening.
## References in this repo
- CLI entry: `codegraphcontext.cli.main`
- MCP server and tool wiring: `codegraphcontext.server`, `tool_definitions.py`
- User-facing setup detail: `docs/docs/setup_workflows.md`, `docs/docs/guides/mcp_guide.md`
- Published copy of this skill (for docs / GitHub): `docs/docs/agent_skill_codegraphcontext.md`
章节与文件索引
按说明文件中的顺序排列。
何时使用该技能
核心工作流程
MCP 设置(短)
代理行为
本仓库中的参考文献
文件/命令 -> cgc · codegraph_find_code · analyze_code_relationships · add_code_to_graph · pip install codegraphcontext · pipx install codegraphcontext · uv tool install codegraphcontext · uvx codegraphcontext …
内容校验值 -> fb49767a439a
当前原文的自动摘译,尚未人工审校。
何时使用该技能
为 AI 或 CLI 查询的代码库建立索引或重新索引。解释如何安装和运行
cgc、选择数据库后端或将 MCP 连接到编辑器。 CGC工具解读:codegraph_find_code、analyze_code_relationships、add_code_to_graph等核心工作流程
安装:
pip install codegraphcontext(或pipx install codegraphcontext)。对于uv,支持uv tool install codegraphcontext或uvx codegraphcontext …;如果解析器因ModuleNotFoundError: tree_sitter_c_sharp失败,请使用显式的额外包运行,例如uvx --with tree-sitter-c-sharp codegraphcontext …。配置:对于DEFAULT_DATABASE、Neo4j URI 或 Kùzu 路径可选~/.codegraphcontext/.env。如果连接失败,请运行cgc doctor。MCP 设置(短)
运行
cgc mcp setup并选择编辑器,或者添加一个运行cgc的服务器条目,参数为mcpstart以及与 CLI 相同的环境。 OpenCode:按照供应商 MCP 文档注册 stdio 服务器,然后将命令指向cgc,并使用参数mcp、start(与其他编辑器相同)。官方 OpenCode MCP 概述:OpenCode MCP 服务器。代理行为
如果用户尚未建立索引,则优先在深度图查询之前对工作区建立索引。对于 Kùzu/Falkor 后端的模糊符号搜索,匹配是可拼写错误的(编辑距离);在 Neo4j 上,全文模糊使用 Lucene 风格的术语——当模糊性对驼峰命名法符号很重要时,在查询中保留原始大小写。如果数据库中缺少
Repository.path,则会跳过该行进行路径检查,并在列出存储库时记录警告;如果这种情况持续发生,建议清理陈旧的Repository节点(请参阅日志中的 Neo4j 示例)。本仓库中的参考文献
CLI 条目:
codegraphcontext.cli.mainMCP 服务器和工具接线:codegraphcontext.server、tool_definitions.py面向用户的设置详细信息:docs/docs/setup_workflows.md、docs/docs/guides/mcp_guide.md此技能的已发布副本(用于文档/GitHub):docs/docs/agent_skill_codegraphcontext.md