Observed since 20 Oct, 19:09 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2context
Turn your git history into structured knowledge — for your team and your AI tools.
A file-based knowledge graph for coding agents. Extracts decisions, conventions, and patterns from your git history and writes them as plain Markdown files that agents like Claude Code read directly.
A CLI that builds and maintains a Markdown knowledge graph in your repo.
Coding agents are stateless: they re-derive your conventions every session. 2context processes that context once (currently from your git commit history), classifies it, and writes it to disk where the agent can grep and read it with the tools it already has. No MCP server, no daemon, no API.
Output is plain files committed alongside your code:
.2context/KNOWLEDGE_GRAPH.md is the entry point. The agent is instructed to read this first..2context/graph/{category}/ holds the central knowledge as a self-balancing tree, organized into four categories: architecture, convention, decision, pattern. Each folder contains an _index.md summarizing its children, plus leaf .md files that group related findings together.KNOWLEDGE.md files sit next to the source folders they describe (e.g. src/auth/KNOWLEDGE.md).## Knowledge Context section is added to CLAUDE.md or AGENTS.md pointing the agent at the index.The current build ships with one adapter: git-commits. The pipeline is built around a generic adapter interface, so additional sources can feed the same graph without changing how the agent consumes it. Pull requests, ADRs, issue threads, and custom sources are on the roadmap.
npm install -g 2context
cd /path/to/your-repo
2context init
First run walks you through provider selection (Anthropic, OpenAI, or Google) and API key entry, then ingests your full history. Keys are stored in ~/.2context/keys.json (chmod 600).
After the first run, use 2context ingest to pick up new commits incrementally.
Each ingest run goes through these phases:
--force). Skip merges, dependency bumps, and formatting-only diffs.KnowledgeItems with category, summary, content, and source provenance (commit SHAs, files touched)..md file alongside other related findings. Co-located items go straight to the matching source-tree KNOWLEDGE.md.2context rebalance command runs the same checks across the whole tree on demand.## Knowledge Context section in CLAUDE.md / AGENTS.md is regenerated, telling the agent to read .2context/KNOWLEDGE_GRAPH.md before starting any task.State for each adapter lives in .2context/sources/{adapter-id}/state.json so the next run only processes what is new.
2context initConfigure the AI provider, scaffold .2context/, and run the first ingest.
-b, --branch <name> Branch to analyze (default: main/master)
-v, --verbose Verbose output
2context ingestRun the ingestion pipeline. Incremental by default.
-b, --branch <name> Branch to analyze
-f, --force Wipe items and reprocess from scratch
-s, --source <id> Run a single adapter only (e.g. git-commits)
--no-rebalance Skip the post-ingest rebalance step
-v, --verbose Verbose output
2context statusPrint configuration, item counts per category, source cursor positions, and co-located files.
2context validateCheck stored items against their sources. For git-commits, this verifies referenced files still exist and source commits are reachable. Items get marked stale on a miss and removed after two consecutive stale verdicts. Rebuilds the index on completion.
--dry-run Report removals without writing
-v, --verbose
2context rebalanceSweep the entire central tree: re-cluster overfull leaves and branches, regenerate every node's summary. The index already self-balances on every insert during ingest; this command is for manual reorganization, e.g. after threshold changes.
--dry-run Show proposed splits/merges without changing anything
-v, --verbose
your-repo/
├── .2context/
│ ├── KNOWLEDGE_GRAPH.md # Entry point. Agent reads this first.
│ ├── graph/
│ │ ├── architecture/
│ │ │ ├── _index.md # Folder summary + child outline
│ │ │ ├── api-design/ # Sub-branch created on insert when siblings cluster
│ │ │ │ ├── _index.md
│ │ │ │ └── versioning.md # Leaf — multiple findings grouped by topic
│ │ │ └── caching.md # Leaf — sits directly under architecture/
│ │ ├── convention/
│ │ │ └── _index.md
│ │ ├── decision/
│ │ │ └── _index.md
│ │ └── pattern/
│ │ └── _index.md
│ └── sources/
│ └── git-commits/state.json # Cursor (gitignored)
├── src/
│ ├── auth/
│ │ ├── KNOWLEDGE.md # Co-located items for this folder
│ │ └── jwt.ts
│ └── db/
│ └── KNOWLEDGE.md
└── CLAUDE.md # Auto-updated Knowledge Context section
Every _index.md and leaf .md carries YAML frontmatter (id, summary, keywords, parent, children/items) so a navigating agent can drill down a level at a time using only summaries — no need to read the full graph.
Commit: .2context/KNOWLEDGE_GRAPH.md, .2context/graph/, src/**/KNOWLEDGE.md, CLAUDE.md / AGENTS.md.
Don't commit: .2context/sources/ (cursor state, already gitignored).
Resolution order: env vars → ~/.2context/keys.json → interactive wizard.
export TWOCONTEXT_PROVIDER=anthropic # anthropic | openai | google
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export GOOGLE_GENERATIVE_AI_API_KEY=...
# Optional
export TWOCONTEXT_MODEL=anthropic/claude-opus-4-7
export TWOCONTEXT_CI=true # plain-text output, no prompts
| Provider | Default | Other models |
|---|---|---|
| Anthropic | claude-sonnet-4-6 | claude-haiku-4-5, claude-opus-4-7 |
| OpenAI | gpt-4o | gpt-4o-mini, o3-mini |
gemini-2.5-flash | gemini-2.5-pro, gemini-2.0-flash |
- name: Update knowledge graph
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
npm install -g 2context
2context ingest
git add .2context CLAUDE.md src/**/KNOWLEDGE.md
git commit -m "chore: update knowledge graph" || true
git push
git clone https://github.com/fabian-emilius/2context-cli
cd 2context-cli
npm install
npm run start:dev -- init # dev mode (tsx)
npm run build && npm run start:prod -- status
npm run lint && npm run format
Pull requests welcome. Open an issue first for significant changes, especially new adapters.
MIT · Copyright (c) 2026 Fabian Emilius
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
inkEnvironment{
"local_name": "ink",
"alias": false,
"peer_metadata": null
} | ^4.4.1 | runtime |
zodEnvironment{
"local_name": "zod",
"alias": false,
"peer_metadata": null
} | ^3.24.0 | runtime |
rxjsEnvironment{
"local_name": "rxjs",
"alias": false,
"peer_metadata": null
} | ^7.8.1 | runtime |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | ^18.3.1 | runtime |
jsonrepairEnvironment{
"local_name": "jsonrepair",
"alias": false,
"peer_metadata": null
} | ^3.13.3 | runtime |
simple-gitEnvironment{
"local_name": "simple-git",
"alias": false,
"peer_metadata": null
} | ^3.27.0 | runtime |
@mastra/coreEnvironment{
"local_name": "@mastra/core",
"alias": false,
"peer_metadata": null
} | ^1.10.0 | runtime |
@nestjs/coreEnvironment{
"local_name": "@nestjs/core",
"alias": false,
"peer_metadata": null
} | ^11.0.0 | runtime |
@ai-sdk/googleEnvironment{
"local_name": "@ai-sdk/google",
"alias": false,
"peer_metadata": null
} | ^1.0.0 | runtime |
@ai-sdk/openaiEnvironment{
"local_name": "@ai-sdk/openai",
"alias": false,
"peer_metadata": null
} | ^1.0.0 | runtime |
@nestjs/commonEnvironment{
"local_name": "@nestjs/common",
"alias": false,
"peer_metadata": null
} | ^11.0.0 | runtime |
ink-text-inputEnvironment{
"local_name": "ink-text-input",
"alias": false,
"peer_metadata": null
} | ^5.0.1 | runtime |
nest-commanderEnvironment{
"local_name": "nest-commander",
"alias": false,
"peer_metadata": null
} | ^3.15.0 | runtime |
ink-select-inputEnvironment{
"local_name": "ink-select-input",
"alias": false,
"peer_metadata": null
} | ^5.0.0 | runtime |
reflect-metadataEnvironment{
"local_name": "reflect-metadata",
"alias": false,
"peer_metadata": null
} | ^0.2.2 | runtime |
@ai-sdk/anthropicEnvironment{
"local_name": "@ai-sdk/anthropic",
"alias": false,
"peer_metadata": null
} | ^1.0.0 | runtime |
tsxEnvironment{
"local_name": "tsx",
"alias": false,
"peer_metadata": null
} | ^4.21.0 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | ^8.57.1 | development |
@swc/cliEnvironment{
"local_name": "@swc/cli",
"alias": false,
"peer_metadata": null
} | ^0.6.0 | development |
prettierEnvironment{
"local_name": "prettier",
"alias": false,
"peer_metadata": null
} | ^3.8.1 | development |
@swc/coreEnvironment{
"local_name": "@swc/core",
"alias": false,
"peer_metadata": null
} | ^1.11.0 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.7.0 | development |
@nestjs/cliEnvironment{
"local_name": "@nestjs/cli",
"alias": false,
"peer_metadata": null
} | ^11.0.0 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^22.0.0 | development |
@types/reactEnvironment{
"local_name": "@types/react",
"alias": false,
"peer_metadata": null
} | ^18.3.28 | development |
eslint-config-prettierEnvironment{
"local_name": "eslint-config-prettier",
"alias": false,
"peer_metadata": null
} | ^10.1.8 | development |
eslint-plugin-prettierEnvironment{
"local_name": "eslint-plugin-prettier",
"alias": false,
"peer_metadata": null
} | ^5.5.5 | development |
@typescript-eslint/parserEnvironment{
"local_name": "@typescript-eslint/parser",
"alias": false,
"peer_metadata": null
} | ^8.57.2 | development |
eslint-plugin-unused-importsEnvironment{
"local_name": "eslint-plugin-unused-imports",
"alias": false,
"peer_metadata": null
} | ^4.4.1 | development |
@typescript-eslint/eslint-pluginEnvironment{
"local_name": "@typescript-eslint/eslint-plugin",
"alias": false,
"peer_metadata": null
} | ^8.57.2 | development |
eslint-plugin-simple-import-sortEnvironment{
"local_name": "eslint-plugin-simple-import-sort",
"alias": false,
"peer_metadata": null
} | ^12.1.1 | development |
Source distribution
{
"shasum": "033d050dc4c38de86e0276f8d49abc8cfea39817",
"tarball": "https://registry.npmjs.org/2context/-/2context-0.1.0.tgz",
"fileCount": 137,
"integrity": "sha512-wfdZkfoMKYse/KpDA9Bnt5w7DgUt33Spx9v9Ojoz6NEB8jFLsqK4+zHKS8FuAXtV0K+Y+q/qrzOqb49Hi2w0oA==",
"signatures": [
{
"sig": "MEYCIQDoJfpvJgiAy9sccjdC9hTFhhQkjQ73uZIOTaDVbyFJWgIhAKj5iOADog8yBkyKg9kjE2UQ5tYspcASWMSLgxh4JVJg",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 598899
}Shared repository data · GitHub
Observed since 20 Oct, 19:09 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:f82fe808e517386d2ccf6ba65854fd39240c430503b21858e3cfa267a7267a4e