codegraph-worktree
Initialize and refresh the CodeGraph symbol index for the current worktree or workspace. Trigger: entering or creating a worktree where code will be edited, after large refactors, or when codegraph query/explore results look stale for files changed on a branch.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 2
01 前言 Front Matter
- name
- codegraph-worktree
- license
- MIT
- metadata
- { "scope": [ "root", "runtime" ], "author": "ai-specs", "version": "1.0", "auto_invoke": [ "Starting work in a fresh worktree where code will be edited", "Reindexing code after a large refactor on a branch", "Codegraph query or explore returned stale or missing symbols" ] }
- description
- Initialize and refresh the CodeGraph symbol index for the current worktree or workspace. Trigger: entering or creating a worktree where code will be edited, after large refactors, or when codegraph query/explore results look stale for files changed on a branch.
03 SKILL.md 正文
CodeGraph Worktree Index
Why this exists
CodeGraph indexes per workspace: the .codegraph/ index is machine-local and
git-ignored, so git worktree add never brings it over. A fresh worktree has no
index, and the main checkout's index does not cover worktree paths — querying it
from a worktree session silently misses files created or changed on the branch.
Verified facts (2026-09-02, ai-specs-cli):
.codegraph/.gitignore(written by the tool) ignores everything except itself: the database, daemon files, and logs are never committed.- The Pi-native
codegraphtool (registered by gentle-pi'scodegraph-tools.tsextension) resolves the index from the current workspace only and never accepts external paths or shell commands. - If the
codegraphbinary is missing, the tool reportsunavailableand falls back toread/grep/find— install it withnpm install -g @colbymchenry/codegraph.
When to run codegraph init
| Situation | Action |
|---|---|
| Fresh worktree created; you will edit code there | Run codegraph init in the worktree root |
Entering an existing worktree with no .codegraph/ |
Run codegraph init before symbol queries |
| Large refactor landed on the branch (new/renamed symbols) | Re-run codegraph init to refresh the graph |
| Read-only exploration only | Skip — the main checkout's index is fine |
How
- Confirm you are in the right workspace root:
git rev-parse --show-toplevel(must equal the directory you will index). - In Pi, use the native tool:
codegraphwithoperation: "init". Outside Pi or from a script, use the binary:codegraph init(run from the worktree root). - Verify:
.codegraph/codegraph.dbexists in that worktree.
Freshness rules (do not skip)
query/explorere-read source from disk live, but symbol/call-path data (callers, blast radius) is only as fresh as the last index run.- For any critical decision based on blast radius ("who calls this?"), corroborate
with
grepbefore acting — grep cannot be stale. - CodeGraph does not index shell scripts or prose: for
.shlogic and docs, usegrep/git log -Sdirectly.
Never
- Never commit
.codegraph/— it is a regenerable, machine-local build artifact (the tool's own.gitignoreenforces this). - Never run
codegraph initin$HOMEor a temp directory — the tool refuses (it requires a real Git project root). - Never treat a stale index as proof of absence: "no callers found" may only mean "not re-indexed since the caller was added".
04 同仓库更多 Skills
test-skill
Test skill for fixture purposes.
obsidian-markdown
Fixture skill for obsidian-markdown.
obsidian-cli
Fixture skill for obsidian-cli.
obsidian-bases
Fixture skill for obsidian-bases.
json-canvas
Fixture skill for json-canvas.
defuddle
Fixture skill for defuddle.