coograph-rebuild-graph
Skill17 starsChanged 7 months agoMITView on GitHub
Rebuild or update the code-graph database. Use when the user wants to refresh the code graph, e.g. after major changes or when graph seems stale.
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- coograph-initSkill
- coograph-applySkill
- coograph-archiveSkill
- coograph-disable-multi-modelsSkill
- coograph-exploreSkill
- coograph-initSkill
- coograph-new-ticketSkill
- coograph-proposeSkill
- coograph-retroSkill
- coograph-suggest-multi-modelsSkill
- coograph-ultra-reviewSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
If not found: stop and tell the user:
- Distinctive: line 35
If multiple found: use the one closest to the current working directory (shortest path).
- Distinctive: line 45
If neither works: stop and tell the user Python 3.10+ is required.
- Distinctive: line 47
If version is below 3.10: stop and tell the user Python 3.10+ is required.
- Very specific: line 53
If the user said "update" or "incremental" → use --update
- Very specific: line 54
If the user said "build", "rebuild", "full", or gave no argument → use --build
- Very specific: line 55
If .code-graph/graph.db does not exist → always use --build (update requires an existing db)
- Very specific: line 94
If nodes is 0: warn the user — the builder may not have detected the tech stack.
- Distinctive: line 105
If the build command fails:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rebuild or incrementally update the .code-graph/graph.db SQLite database.
IMPORTANT: This skill runs commands. Follow every step in order. Do not skip error handling.
Step 1: Locate the code-graph tooling
Find server.py — it could be in several locations depending on the project setup:
.github/code-graph/server.py # standard location
coograph/.github/code-graph/server.py # monorepo with template as submoduleSearch for it:
find . -path "*/code-graph/server.py" -not -path "*/node_modules/*" 2>/dev/null | head -5If not found: stop and tell the user:
"No code-graph tooling found. Run the
coograph-initskill to set it up, or copy.github/code-graph/from the coograph."
If multiple found: use the one closest to the current working directory (shortest path). Report which one you're using.
Store the resolved path as $SERVER_PY.
Step 2: Check Python
python3 --version 2>/dev/null || python --version 2>/dev/nullIf neither works: stop and tell the user Python 3.10+ is required.
If version is below 3.10: stop and tell the user Python 3.10+ is required.
Store the working Python command as $PYTHON (python3 preferred over python).
Step 3: Determine build mode
- If the user said "update" or "incremental" → use
--update - If the user said "build", "rebuild", "full", or gave no argument → use
--build - If
.code-graph/graph.dbdoes not exist → always use--build(update requires an existing db)
Step 4: Run the build
Execute from the project root (the directory where .code-graph/ should be created):
cd <project-root> && $PYTHON $SERVER_PY <--build or --update>Expected success output includes lines like:
Detected stacks: java, structuredGraph built: N files -> .code-graph/graph.db (X.XXs)
or for update:
Graph updated: updated N, dependents M, deleted DGraph up to date — no changes detected.
Step 5: Verify
Confirm the database exists and has data:
$PYTHON -c "
import sqlite3, os
db = '<project-root>/.code-graph/graph.db'
if not os.path.exists(db):
print('ERROR: graph.db was not created')
exit(1)
conn = sqlite3.connect(db)
nodes = conn.execute('SELECT COUNT(*) FROM nodes').fetchone()[0]
edges = conn.execute('SELECT COUNT(*) FROM edges').fetchone()[0]
stacks = conn.execute(\"SELECT value FROM meta WHERE key='stacks'\").fetchone()
print(f'Graph OK: {nodes:,} nodes, {edges:,} edges')
if stacks: print(f'Stacks: {stacks[0]}')
conn.close()
"If nodes is 0: warn the user — the builder may not have detected the tech stack. Ask them to check if the project has recognizable stack markers (pom.xml, package.json, go.mod, etc.).
Step 6: Report
Tell the user:
- ✅ Graph rebuilt/updated successfully
- Node count, edge count, detected stacks
- File path of the database
Error Handling
If the build command fails:
ModuleNotFoundError: No module named 'parsers'— the script was run from the wrong directory. Ensure$PYTHONruns$SERVER_PYwith the server.py's parent directory containingparsers/. The--buildflag does NOT requiremcp.FileNotFoundErroror permission errors — check the project root path is correct and writable.- Empty output / no files parsed — the stack detection found no recognized files. Check that the project root is correct (not a subdirectory).
- Any other error — show the full error output to the user and suggest running manually:
cd <project-root> && uv run --with-requirements .github/code-graph/requirements.txt .github/code-graph/server.py --build
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

