Context Graph
Long-Term Memory for AI Agents
A structured knowledge system that persists across sessions. Store architectural decisions, coding standards, and project context with 7 specialized note types.
Persistent Storage
Knowledge survives across AI sessions. No need to re-explain project context.
Structured Notes
7 note types with defined fields ensure consistent, searchable documentation.
Code Integration
Notes link directly to code. Changes are tracked and stale context is detected.
Structured Knowledge Capture
Each note type has defined fields designed for specific use cases. This structure makes context searchable and machine-readable.
Architectural Decision Records
Document significant architectural decisions
Fields:
- context—The situation that led to this decision
- decision—What was decided and why
- consequences—Expected outcomes and trade-offs
- alternatives—Options considered and rejected
Use: Record major design choices with full context and rationale
Coding Standards
Store coding conventions and style guides
Fields:
- scope—Where this standard applies
- standard—The rule or convention
- rationale—Why this standard exists
- enforcement—How to enforce or check compliance
Use: Maintain consistency across the codebase
Performance Optimizations
Record performance improvements
Fields:
- problem—Performance issue identified
- solution—Optimization applied
- before_metrics—Performance before optimization
- after_metrics—Performance after optimization
Use: Document performance wins and lessons learned
Lessons Learned
Document failures and prevention strategies
Fields:
- error—What went wrong
- cause—Root cause analysis
- fix—How it was resolved
- prevention—How to prevent recurrence
Use: Learn from mistakes and prevent future issues
Refactoring Plans
Plan and track refactoring work
Fields:
- target—What needs refactoring
- reason—Why refactoring is needed
- approach—How to perform the refactoring
- risks—Potential issues and mitigation
Use: Structure complex refactoring efforts
Technical Debt
Track technical debt and pending work
Fields:
- task—What needs to be done
- priority—Urgency level (high/medium/low)
- effort—Estimated effort required
- blocking—What is blocking completion
Use: Manage pending tasks and known issues
Open Questions
Document open questions and investigations
Fields:
- question—The question being asked
- context—Background and relevance
- attempts—What has been tried
- answer—Resolution when found
Use: Track investigations and their outcomes
How Context Graph Works
Advanced features that make Context Graph an essential tool for AI-assisted development.
File Context Workflow
Single-description-per-file pattern ensures each file has exactly one authoritative context note. AI queries get consistent, up-to-date information without redundancy.
Code Linking
Link notes to specific functions, classes, or files. Navigate seamlessly between context and code with automatic relationship tracking.
Stale Context Detection
System automatically flags when linked code changes. Know immediately when context notes may be outdated and need review.
Context-First Queries
AI queries Context Graph before Code Graph, dramatically reducing search space and improving response relevance.
Context Management Tools
Three specialized MCP tools for adding, retrieving, and searching context notes.
add_context_note
Add a structured note to the context graph
{
"file_path": "src/auth.rs",
"note_type": "ADR",
"content": "Implemented JWT authentication",
"fields": {
"context": "Need for stateless auth",
"decision": "Use JWT tokens",
"consequences": "Scalable but requires token refresh",
"alternatives": "Session-based auth (rejected for scalability)"
},
"tags": ["auth", "security"]
}get_context_notes
Retrieve context notes for files or the entire project
{
"file_path": "src/auth.rs",
"note_types": ["ADR", "TODO"],
"include_stale": false
}search_context
Search through context notes and memories
{
"query": "authentication",
"note_types": ["ADR", "STANDARD"],
"tags": ["security"]
}Typical Workflow
AI makes an architectural decision
During development, AI decides to use a specific design pattern
Record with add_context_note (ADR)
Documents context, decision, consequences, and alternatives
Later sessions query get_context_notes
New AI sessions understand previous decisions without asking
search_context finds relevant notes
AI quickly locates relevant context when needed