Your AI editor knows what you're working on — automatically.
A self-learning Claude Code plugin that detects your current project from your first message and injects the right file context — without any manual configuration.
How It Works · Installation · How It Learns · Architecture · Toggle
Every Claude Code session starts the same way: you tell it what project you're working on, what files matter, what the architecture looks like. Then the next session, you do it again.
That's wasted time and context.
context-bench solves this by learning from your sessions. After a few interactions, it knows:
- What keywords belong to which project
- Which files you typically reference
- Which framework markers (pyproject.toml, package.json, Cargo.toml) identify your stack
- When a project is no longer active (confidence decay)
It then injects relevant file paths as invisible context before you even finish typing your first message.
┌──────────────────────────────────────────────────────────┐
│ Claude Code Session │
│ │
│ User: "fix the parser in my strategy builder" │
│ │ │
│ ▼ │
│ [UserPromptSubmit hook fires] │
│ │ │
│ ▼ │
│ context-bench: │
│ ├─ Keywords: "parser" + "strategy" + "builder" │
│ ├─ Match: "nq-strategy-builder" (confidence 0.85) │
│ └─ Inject: /path/to/parser.py, /path/to/knowledge.py │
│ │ │
│ ▼ │
│ Claude responds with full project context │
│ │
│ ... user edits files ... │
│ │ │
│ [PostToolUse hook fires] → tracks changed files │
│ │
│ ... session ends ... │
│ │ │
│ [SessionEnd hook fires] → updates confidence +0.15 │
│ │
└──────────────────────────────────────────────────────────┘
| Hook | Trigger | What it does | Latency |
|---|---|---|---|
UserPromptSubmit |
User sends a message | Matches keywords → injects relevant file paths as context | < 200ms |
PostToolUse |
Tool call completes | Records which files were read/written | < 50ms |
SessionEnd |
Session closes | Updates confidence scores, decays old topics, creates new ones | < 100ms |
claude plugin add nessos666/context-benchThat's it. The plugin registers all three hooks automatically.
git clone https://github.com/nessos666/context-bench
cd context-bench
./install.shinstall.sh registers the three hooks in ~/.claude/settings.json and copies context_bench.py to ~/.context-bench/.
claude --plugin-dir ./context-benchcontext-bench uses a confidence-based learning system — no ML model, no API calls, just deterministic updates:
| Event | Confidence change | Why |
|---|---|---|
| Match found + files changed | +0.15 | Strong signal — you're working on this project |
| Match found + no files changed | −0.05 | Weak signal — maybe a false positive |
| No match + files changed | New topic at 0.5 | Discovered a new project organically |
| Topic idle > 30 days | −0.01/day | Gradual decay for inactive projects |
| Topic below 0.3 | Auto-removed | Confidence too low to be useful |
On first run (no projects.json yet), context-bench scans the current directory for framework markers:
| Marker | Detected as |
|---|---|
pyproject.toml / requirements.txt / setup.py |
Python project |
package.json |
Node.js project |
go.mod |
Go project |
Cargo.toml |
Rust project |
pom.xml |
Java project |
Bootstrap completes within 200ms to avoid blocking hooks.
{
"version": 1,
"projects": [
{
"id": "nq-strategy-builder",
"keywords": ["strategy", "builder", "nq", "fvg", "backtest"],
"root": "/home/user/projects/strategy-builder",
"paths": ["engine/parser.py", "sb/cli.py"],
"confidence": 0.85,
"uses": 47,
"last_used": "2026-05-17T10:30:00"
}
]
}context_bench.py (single file, zero dependencies)
├── cmd_prompt() → UserPromptSubmit → match topic, inject context
├── cmd_track() → PostToolUse → record changed files
└── cmd_learn() → SessionEnd → update confidence, create topics, decay
Single file. Zero dependencies. Zero API calls.
Temporarily disable context-bench without uninstalling:
touch ~/.context-bench/DISABLED # disable
rm ~/.context-bench/DISABLED # enable againWhen disabled, all hooks exit immediately (no context injected, no tracking). The learn hook still cleans up session files to prevent leaks.
~/.claude/commands/ctx-bench-aus.md:
Run: mkdir -p ~/.context-bench && touch ~/.context-bench/DISABLED
Output: "context-bench deactivated"~/.claude/commands/ctx-bench-an.md:
Run: rm -f ~/.context-bench/DISABLED
Output: "context-bench active"Plugin mode:
claude plugin remove context-benchStandalone:
./uninstall.sh- Python 3.9+ (stdlib only, no dependencies)
- Claude Code with hooks support
├── context_bench.py # Single-file plugin (hooks + learning)
├── hooks/hooks.json # Hook registration
├── install.sh # Hook installer
├── uninstall.sh # Hook remover
├── .github/workflows/tests.yml # CI pipeline
├── tests/test_context_bench.py # Test suite
└── examples/
├── node-project.json # Example project manifest
├── python-project.json
└── rust-project.json
pytest tests/ -v# Manual test
python context_bench.py prompt "fix the parser in my strategy builder"MIT
Built because repeating your project context every session is a waste of tokens — and brainpower.
github.com/nessos666