context-graph-builder
Skill87 starsChanged 8 months agoMITView on GitHub
Build, maintain, and enrich the project's context graph as you work. This skill runs automatically — agents should follow these guidelines during every task execution to incrementally improve the context graph. Always update the graph when you: - Complete a task (success or failure) - Discover a code pattern or anti-pattern - Make an architectural decision - Encounter and fix an error - Learn a user preference (coding style, framework choice, etc.) - Modify files in the project Build from…
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- generate-reportsSkill
- health-checkSkill
- run-testsSkill
- security-reviewSkill
- generate-reportsSkill
- health-checkSkill
- run-testsSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Always: update the graph when you:
- Distinctive: line 17
Build from scratch: when:
- Distinctive: line 26
When a project path is provided, the system auto-scans to create:
- Distinctive: line 35
After each task execution, store context:
- Very specific: line 96
All nodes created within a project session carry that project_id.
- Very specific: line 104
When no project is configured, nodes have project_id="" (global scope).
≈ “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
Context Graph Builder Skill
Build, maintain, and enrich the project's context graph as you work. This skill runs automatically — agents should follow these guidelines during every task execution to incrementally improve the context graph.
When to Build Context
Always update the graph when you:
- Complete a task (success or failure)
- Discover a code pattern or anti-pattern
- Make an architectural decision
- Encounter and fix an error
- Learn a user preference (coding style, framework choice, etc.)
- Modify files in the project
Build from scratch when:
- The user provides a
--projectpath for the first time - The user requests
rescanorrebuild context - The graph is empty for the active project
How to Build Context
1. Project Registration (First Use)
When a project path is provided, the system auto-scans to create:
- A
PROJECTnode (root anchor for the project graph) FILEnodes for each directoryPATTERNnodes for detected languages, frameworks, and structureDECISIONnodes for detected CI/CD, testing, and infrastructure choicesCONTAINS/RELATED_TOedges linking them all
2. Incremental Updates During Operation
After each task execution, store context:
# After completing a task
manager.store_task(
task_description="What was done",
outcome="The result",
success=True,
agents_involved=["claude", "codex"],
files_modified=["src/auth.py"],
project_id=project_id, # Scope to current project
)
# When you discover a useful pattern
manager.store_pattern(
pattern_name="Error Handling Convention",
pattern_type="convention",
description="This project uses Result types instead of exceptions",
examples=["def fetch_user(...) -> Result[User, Error]: ..."],
languages=["python"],
)
# When you encounter and fix a bug
manager.log_mistake(
error_type="import_error",
error_message="Circular import between auth and users modules",
context_description="When refactoring the auth module",
correction="Moved shared types to a common.types module",
prevention_strategy="Keep shared types in dedicated modules",
severity="medium",
)
# When an architectural decision is made
manager.store_decision(
decision_title="Use PostgreSQL over MongoDB",
decision_description="Chose relational DB for strong consistency",
rationale="ACID transactions needed for payment processing",
alternatives_considered=["MongoDB", "CockroachDB"],
)3. Build from Scratch
To fully rebuild a project's context graph:
# Delete existing graph for the project
manager.delete_project_graph(project_id)
# Re-register and scan
manager.register_project("/path/to/project")Or via CLI:
ai-orchestrator run "analyze project" --project /path/to/projectMulti-Project Isolation
Each project gets a unique project_id derived from its absolute path.
All nodes created within a project session carry that project_id.
This ensures:
- Graphs from different projects never mingle
- Searching within a project only returns its own context
- Deleting a project's graph doesn't affect others
- The dashboard can filter by project
When no project is configured, nodes have project_id="" (global scope).
Global nodes are shared across all contexts — use for universal patterns.
What Makes Good Context
DO store:
- Concrete patterns discovered in the codebase
- Specific error messages and their fixes
- Architectural decisions with rationale
- File modification history per task
- User's coding preferences (naming, style, framework choices)
DON'T store:
- Raw LLM outputs verbatim (summarize instead)
- Temporary debugging artifacts
- Sensitive credentials or secrets
- Duplicate information already in the graph
Triggering
This skill activates automatically through the engine integration. Both the Orchestrator and Agentic Team engines:
- Auto-register projects on startup if
PROJECT_PATHis set - Store task results after each execution
- Log mistakes on failures
- Pass
project_idto scope all context operations
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.

