{
  "markdown": "<p align=\"center\">\n  <h1 align=\"center\">context-bench</h1>\n  <p align=\"center\">\n    <strong>Your AI editor knows what you're working on — automatically.</strong>\n  </p>\n  <p align=\"center\">\n    <em>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.</em>\n  </p>\n  <p align=\"center\">\n    <a href=\"#how-it-works\">How It Works</a> · <a href=\"#installation\">Installation</a> · <a href=\"#learning\">How It Learns</a> · <a href=\"#architecture\">Architecture</a> · <a href=\"#toggle\">Toggle</a>\n  </p>\n</p>\n\n<p align=\"center\">\n  <img src=\"https://img.shields.io/badge/python-3.9+-blue?logo=python&logoColor=white\" alt=\"Python 3.9+\">\n  <img src=\"https://img.shields.io/badge/license-MIT-green\" alt=\"MIT License\">\n  <img src=\"https://img.shields.io/badge/dependencies-zero-success\" alt=\"Zero deps\">\n  <img src=\"https://img.shields.io/badge/hooks-3_registered-blueviolet\" alt=\"3 hooks\">\n  <img src=\"https://img.shields.io/badge/bootstrap-200ms-brightgreen\" alt=\"200ms bootstrap\">\n  <img src=\"https://img.shields.io/github/stars/nessos666/context-bench?style=social\" alt=\"Stars\">\n</p>\n\n---\n\n## The Problem\n\nEvery 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.\n\n**That's wasted time and context.**\n\ncontext-bench solves this by **learning from your sessions**. After a few interactions, it knows:\n\n- What keywords belong to which project\n- Which files you typically reference\n- Which framework markers (pyproject.toml, package.json, Cargo.toml) identify your stack\n- When a project is no longer active (confidence decay)\n\nIt then **injects relevant file paths as invisible context** before you even finish typing your first message.\n\n---\n\n## How It Works\n\n```\n┌──────────────────────────────────────────────────────────┐\n│                  Claude Code Session                      │\n│                                                           │\n│  User: \"fix the parser in my strategy builder\"            │\n│         │                                                 │\n│         ▼                                                 │\n│  [UserPromptSubmit hook fires]                            │\n│         │                                                 │\n│         ▼                                                 │\n│  context-bench:                                           │\n│    ├─ Keywords: \"parser\" + \"strategy\" + \"builder\"         │\n│    ├─ Match: \"nq-strategy-builder\" (confidence 0.85)      │\n│    └─ Inject: /path/to/parser.py, /path/to/knowledge.py   │\n│         │                                                 │\n│         ▼                                                 │\n│  Claude responds with full project context                │\n│                                                           │\n│  ... user edits files ...                                 │\n│         │                                                 │\n│  [PostToolUse hook fires] → tracks changed files          │\n│                                                           │\n│  ... session ends ...                                     │\n│         │                                                 │\n│  [SessionEnd hook fires] → updates confidence +0.15       │\n│                                                           │\n└──────────────────────────────────────────────────────────┘\n```\n\n### The three hooks\n\n| Hook | Trigger | What it does | Latency |\n|------|---------|--------------|---------|\n| `UserPromptSubmit` | User sends a message | Matches keywords → injects relevant file paths as context | < 200ms |\n| `PostToolUse` | Tool call completes | Records which files were read/written | < 50ms |\n| `SessionEnd` | Session closes | Updates confidence scores, decays old topics, creates new ones | < 100ms |\n\n---\n\n## Installation\n\n### As Claude Code Plugin (recommended)\n\n```bash\nclaude plugin add nessos666/context-bench\n```\n\nThat's it. The plugin registers all three hooks automatically.\n\n### Standalone (manual)\n\n```bash\ngit clone https://github.com/nessos666/context-bench\ncd context-bench\n./install.sh\n```\n\n`install.sh` registers the three hooks in `~/.claude/settings.json` and copies `context_bench.py` to `~/.context-bench/`.\n\n### Local testing\n\n```bash\nclaude --plugin-dir ./context-bench\n```\n\n---\n\n## How It Learns\n\ncontext-bench uses a **confidence-based learning system** — no ML model, no API calls, just deterministic updates:\n\n### Confidence scoring\n\n| Event | Confidence change | Why |\n|-------|-------------------|-----|\n| Match found + files changed | **+0.15** | Strong signal — you're working on this project |\n| Match found + no files changed | **−0.05** | Weak signal — maybe a false positive |\n| No match + files changed | **New topic at 0.5** | Discovered a new project organically |\n| Topic idle > 30 days | **−0.01/day** | Gradual decay for inactive projects |\n| Topic below **0.3** | **Auto-removed** | Confidence too low to be useful |\n\n### Bootstrap (first run)\n\nOn first run (no `projects.json` yet), context-bench scans the current directory for framework markers:\n\n| Marker | Detected as |\n|--------|-------------|\n| `pyproject.toml` / `requirements.txt` / `setup.py` | Python project |\n| `package.json` | Node.js project |\n| `go.mod` | Go project |\n| `Cargo.toml` | Rust project |\n| `pom.xml` | Java project |\n\nBootstrap completes within **200ms** to avoid blocking hooks.\n\n### Data model\n\n```json\n{\n  \"version\": 1,\n  \"projects\": [\n    {\n      \"id\": \"nq-strategy-builder\",\n      \"keywords\": [\"strategy\", \"builder\", \"nq\", \"fvg\", \"backtest\"],\n      \"root\": \"/home/user/projects/strategy-builder\",\n      \"paths\": [\"engine/parser.py\", \"sb/cli.py\"],\n      \"confidence\": 0.85,\n      \"uses\": 47,\n      \"last_used\": \"2026-05-17T10:30:00\"\n    }\n  ]\n}\n```\n\n---\n\n## Architecture\n\n```\ncontext_bench.py (single file, zero dependencies)\n├── cmd_prompt()  → UserPromptSubmit  → match topic, inject context\n├── cmd_track()   → PostToolUse       → record changed files\n└── cmd_learn()   → SessionEnd        → update confidence, create topics, decay\n```\n\n**Single file.** **Zero dependencies.** **Zero API calls.**\n\n---\n\n## Toggle (disable/enable)\n\nTemporarily disable context-bench without uninstalling:\n\n```bash\ntouch ~/.context-bench/DISABLED   # disable\nrm ~/.context-bench/DISABLED      # enable again\n```\n\nWhen disabled, all hooks exit immediately (no context injected, no tracking). The `learn` hook still cleans up session files to prevent leaks.\n\n### Claude Code skill shortcuts\n\n`~/.claude/commands/ctx-bench-aus.md`:\n```markdown\nRun: mkdir -p ~/.context-bench && touch ~/.context-bench/DISABLED\nOutput: \"context-bench deactivated\"\n```\n\n`~/.claude/commands/ctx-bench-an.md`:\n```markdown\nRun: rm -f ~/.context-bench/DISABLED\nOutput: \"context-bench active\"\n```\n\n---\n\n## Uninstall\n\nPlugin mode:\n```bash\nclaude plugin remove context-bench\n```\n\nStandalone:\n```bash\n./uninstall.sh\n```\n\n---\n\n## Requirements\n\n- **Python 3.9+** (stdlib only, no dependencies)\n- **Claude Code** with hooks support\n\n---\n\n## Project Structure\n\n```\n├── context_bench.py              # Single-file plugin (hooks + learning)\n├── hooks/hooks.json              # Hook registration\n├── install.sh                    # Hook installer\n├── uninstall.sh                  # Hook remover\n├── .github/workflows/tests.yml   # CI pipeline\n├── tests/test_context_bench.py   # Test suite\n└── examples/\n    ├── node-project.json         # Example project manifest\n    ├── python-project.json\n    └── rust-project.json\n```\n\n---\n\n## Testing\n\n```bash\npytest tests/ -v\n```\n\n```bash\n# Manual test\npython context_bench.py prompt \"fix the parser in my strategy builder\"\n```\n\n---\n\n## License\n\nMIT\n\n<p align=\"center\">\n  <small>Built because repeating your project context every session is a waste of tokens — and brainpower.<br>\n  <strong>github.com/nessos666</strong></small>\n</p>\n",
  "bytes": 7970,
  "sha": "77a721c15fe7f983891e025372c0accff75f61a765f88497ee5f6cd685173a4a",
  "repo_slug": "nessos666/context-bench",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_nessos666_context_bench_context_bench_6dbc3ec9/readme"
}