Context System
How CHAOS-AI's three-database context layer works and how to manage it.
Overview
CHAOS maintains persistent context across all agent sessions via three databases. Context is injected automatically before each agent run — no manual setup required.
The Three Stores
SQLite Context Store (per project)
Located at .claude/context/ in your project root. Stores:
- Session logs and agent findings
- File summaries indexed by path
- Discovered coding conventions and patterns
- Previous architectural decisions with rationale
Uses FTS5 full-text search for fast retrieval. Every agent run appends to this store.
Praxis Store (cross-project)
A shared database in your home directory (~/.chaos/praxis.db). Stores:
- Best practices that emerge from real agent work
- Framework patterns that recur across codebases
- Error signatures and their established fixes
- Language conventions that apply universally
This store grows with every project you run CHAOS on. New projects benefit immediately from patterns established in past projects.
PostgreSQL Knowledge Graph
The structured semantic network: 268+ nodes, 89+ relationship edges. Nodes represent concepts (files, modules, patterns, decisions). Edges represent relationships (depends_on, implements, conflicts_with).
The engine ranks nodes by relevance to the current task using a PageRank-style algorithm and injects the top-N entries before each agent session.
How Injection Works
Before any agent starts, CHAOS:
- Queries the SQLite store for entries relevant to the task and affected files
- Queries the Praxis Store for applicable best practices
- Queries the knowledge graph for top-ranked related concepts
- Combines results using Reciprocal Rank Fusion (RRF) — keyword + semantic
- Prepends the merged context to the agent's initial prompt
Total injection cost: ~800–2,000 tokens. Savings per agent: 5,000–50,000+ tokens (replaces reading many files from scratch).
Managing Context
View context stats
cw run pm "/context-stats"
Search context
cw run pm "/context-search <query>"
Add a context entry manually
cw run pm "/context-add <content>"
Sync context after major changes
cw run pm "/context-sync"
Context Isolation
Each project has its own SQLite context store. The Praxis Store and knowledge graph are shared across projects but scoped by language and framework — a Python project does not inherit Java-specific patterns.
Resetting Context
To clear a project's context store:
rm -rf .claude/context/
cw run pm "/context-sync" # re-index from scratch
The Praxis Store and knowledge graph are not affected — those persist cross-project.
Privacy Note
All context databases are local files on your machine. Nothing in the context system is transmitted to CHAOS servers. The only data that leaves your machine is the context that gets sent to your configured LLM provider as part of agent API calls.
Next Steps
- Agents — How agents read and write context
- Pipelines — Context sharing across pipeline agents
- Configuration — Context ignore patterns