context0
v2.0.0
Published
Context management across AI agent sessions
Downloads
176
Readme
Context0
Context management across AI agent sessions. Zero LLM dependency — your agent produces all content, Context0 stores, validates, and retrieves it.
AI agents have no memory across sessions. Every new conversation starts from zero. Context0 fixes this with structured context that persists, compresses, and improves over time.
Install
npm install -g context0Requires Node.js >= 22.
Quick Start
# Initialize in your project
context0 init
# Start a session
context0 session start --intent "Implement authentication module"
# Log observations, commit progress
context0 log "Investigating auth approaches" --type observation
context0 commit "Implemented JWT auth" --rationale "Stateless requirement" --validation tests-passed
# Read it back (lean overview by default)
context0
# End the session — generates metrics + promotion candidates
context0 session endHow It Works
Everything flows through one pipeline:
observe → decide → validate → remember- Observe: Log entries, human feedback
- Decide: Commits with rationale and validation
- Validate: Every item carries validation status (tests-passed, explicit-approval, etc.)
- Remember: Best patterns promoted to persistent cross-session context
Context0 maintains two context spaces:
- Session context (
.context0/sessions/): Lives within one session. Branching memory with commit, branch, and merge operations — agents can explore alternatives in isolation. - Persistent context (
~/.context0/+.context0/persistent/): Survives across sessions. Human profile, project wisdom, validated patterns. Grows over time.
Commands
Read (the tool's name IS the query)
| Command | Returns |
|---------|---------|
| context0 | Session overview (~200-300 tokens) |
| context0 --branch <name> | Branch summary + recent commits |
| context0 --commit <id> [--trace] | Full commit with rationale |
| context0 --log [--lines N] | Raw observation/thought/action trace |
| context0 --conversation | Human feedback with reasoning |
| context0 --decisions | Expanded architecture decision refs |
| context0 --arch | Agent-written architectural knowledge |
| context0 --git | Live git status + deps (no session required) |
| context0 --persistent | Profile + wisdom + patterns + trend |
| context0 --all [--budget N] | Everything, token-budgeted |
Write
| Command | Description |
|---------|-------------|
| context0 log <entry> | Append observation/thought/action to current branch |
| context0 feedback <type> <msg> | Record human feedback (correction, preference, decision, note) |
| context0 commit <summary> | Checkpoint progress with rationale and validation |
| context0 branch create <name> | Create exploration branch |
| context0 merge <branch> | Merge branch back with origin tags |
| context0 meta set <segment> <json> | Write architectural metadata |
Lifecycle
| Command | Description |
|---------|-------------|
| context0 init | Initialize .context0/ and ~/.context0/ |
| context0 session start | Start session (auto-ends stale sessions) |
| context0 session end | End session, generate metrics + promotion candidates |
| context0 session resume <id> | Reactivate a previous session |
| context0 session list | List all sessions |
| context0 session export <id> | Export session as JSON or Markdown |
| context0 status | Dashboard with metrics |
| context0 promote | Review and promote patterns to persistent context |
| context0 profile | View/update human profile |
Global Flags
| Flag | Effect |
|------|--------|
| --quiet | Suppress status messages |
| --json | Machine-readable JSON output |
Agent Integration
See AGENT.md for a ready-to-use system prompt snippet.
Development
npm run build # Build with tsup
npm test # Run tests (vitest)
npm run lint # Type-check (tsc --noEmit)
npm run test:watch # Watch mode