{"_id":"@anshmaj121/context-optimizer","_rev":"5-0d44135cdcf86fd98e4179ac6f254efa","name":"@anshmaj121/context-optimizer","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@anshmaj121/context-optimizer","version":"1.0.0","keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"author":{"name":"anshmajumdar121"},"license":"MIT","_id":"@anshmaj121/context-optimizer@1.0.0","maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"bin":{"context-optimizer":"bin/cli.js"},"dist":{"shasum":"213f13edbdd5c7459dbd1cfe9e70186bcdf4a44b","tarball":"https://registry.npmjs.org/@anshmaj121/context-optimizer/-/context-optimizer-1.0.0.tgz","fileCount":14,"integrity":"sha512-upEveOVinG2xYdxtqHRrr1Q2UxKDhKaMQzHC6w74n5NWPsKmP0fa6nkJjif9+1wBH5bDNiPKDHsknqrcqgEa0Q==","signatures":[{"sig":"MEYCIQDTIj3rTlFlLbhUMH/m02nhM90yvYXdhk8QZeMw9rOtTAIhAJSrKwfY5EBgPr/ENTlvKBKh3QqRO+m5OIJ4gfuvKEOp","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54147},"engines":{"node":">=14.0.0"},"gitHead":"c6478ec091ae9ba5f998ebe8fb8b403e784169c7","_npmUser":{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"},"_npmVersion":"11.11.0","description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-optimizer_1.0.0_1778650717581_0.29896958742332","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@anshmaj121/context-optimizer","version":"1.0.1","keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"author":{"name":"anshmajumdar121"},"license":"MIT","_id":"@anshmaj121/context-optimizer@1.0.1","maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"bin":{"context-optimizer":"bin/cli.js"},"dist":{"shasum":"6a664e0649000703f8e35b9ee5ecb80c38123e55","tarball":"https://registry.npmjs.org/@anshmaj121/context-optimizer/-/context-optimizer-1.0.1.tgz","fileCount":14,"integrity":"sha512-UXoSzUojSCEvUaXdft+U+tTUM+4ZMTAt5Ou/twnCddMmYvzgq0UfJTv54GOXcsrQ9EfkfrGc1UQioz6DleZnSw==","signatures":[{"sig":"MEQCIEVfRuvvnT1in3wBhteXcSBmP54Tc3Fu7Z/ECfhIK9ZKAiBgt6MO+l5TtmJ6ci3Fzff0LM7fpjT395T26cwucJrfYQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56140},"engines":{"node":">=14.0.0"},"gitHead":"fb107a3d9cc76fcba5728d193bd24c11ad02c56b","_npmUser":{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"},"_npmVersion":"11.11.0","description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-optimizer_1.0.1_1778651047491_0.5017040552748575","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@anshmaj121/context-optimizer","version":"1.0.2","keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"author":{"name":"anshmajumdar121"},"license":"MIT","_id":"@anshmaj121/context-optimizer@1.0.2","maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"bin":{"context-optimizer":"bin/cli.js"},"dist":{"shasum":"ceb6ea6e401a820db0435e747dca5139e1262ad7","tarball":"https://registry.npmjs.org/@anshmaj121/context-optimizer/-/context-optimizer-1.0.2.tgz","fileCount":14,"integrity":"sha512-lTcUNqRmvpHSh+KKgLs5dd/2bzB4MpHiVu2CPe7M5yHKIasAnFRN2+foXOvk6L3BG2fc9k2cJBBRc33DMM1cBw==","signatures":[{"sig":"MEUCIQCVIMgGxmgJapMqOU1S56sSbGaGAxqHk+C0FYh/EjHRfwIgEaeAcfiya8+Hh/PDa4asgfLqDCgRvWfZfAU/jpmepm4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56138},"engines":{"node":">=14.0.0"},"gitHead":"fb107a3d9cc76fcba5728d193bd24c11ad02c56b","_npmUser":{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"},"_npmVersion":"11.11.0","description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-optimizer_1.0.2_1778651297091_0.1885284412835353","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@anshmaj121/context-optimizer","version":"1.0.3","keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"author":{"name":"anshmajumdar121"},"license":"MIT","_id":"@anshmaj121/context-optimizer@1.0.3","maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"bin":{"context-optimizer":"bin/cli.js"},"dist":{"shasum":"b8c97779c7e974760ce5e60fec90f084c3528c0b","tarball":"https://registry.npmjs.org/@anshmaj121/context-optimizer/-/context-optimizer-1.0.3.tgz","fileCount":14,"integrity":"sha512-wAz0EMQu+6d9CwEuKPqE8N9eNVBlL9RyMaV6m1YR/sySWcLrtJNor5CnDF1T0owBGPLV0P0oOAXI45LXWJXt1w==","signatures":[{"sig":"MEQCIC+yGu0WS9ppnsZg5vS+D9rMMoGZKkWg293RH3Yi8v4lAiAzZ7NCIjNXpJJbSfNaIRd1N7eUj4/S989860A21SriEw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56148},"engines":{"node":">=14.0.0"},"gitHead":"c7a2521b7a9e550a113b3f1e6f5a969b4bf74df8","_npmUser":{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"},"_npmVersion":"11.11.0","description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/context-optimizer_1.0.3_1778651524003_0.5086141664652428","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@anshmaj121/context-optimizer","version":"1.0.4","description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","bin":{"context-optimizer":"bin/cli.js"},"keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"author":{"name":"anshmajumdar121"},"license":"MIT","engines":{"node":">=14.0.0"},"gitHead":"2768cf888e3b3349e01603a08722a8f6d092ff3f","_id":"@anshmaj121/context-optimizer@1.0.4","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-b6ZTh9PGAAuRwQm+jZ05iCsyGyAYCDL813NgDmy7tFs6RwQY1q1dZam/2lEQRtZsvYOz28Zwxo2ehh4TXynVwg==","shasum":"c6802b9ac55a6f2f9d4832f7a794291ec697001c","tarball":"https://registry.npmjs.org/@anshmaj121/context-optimizer/-/context-optimizer-1.0.4.tgz","fileCount":14,"unpackedSize":56202,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDfCKqSPLl5GEsfFu+XxWl4mTQgfSy7hKvWU0tHs0exgAiAX2udl1DbzChYrmDickfz90WrRgPufbSu7Y2BXM7TrAw=="}]},"_npmUser":{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"},"directories":{},"maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/context-optimizer_1.0.4_1778651591455_0.6426894045788301"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T05:38:37.482Z","modified":"2026-05-13T05:53:11.693Z","1.0.0":"2026-05-13T05:38:37.723Z","1.0.1":"2026-05-13T05:44:07.632Z","1.0.2":"2026-05-13T05:48:17.308Z","1.0.3":"2026-05-13T05:52:04.161Z","1.0.4":"2026-05-13T05:53:11.594Z"},"author":{"name":"anshmajumdar121"},"license":"MIT","keywords":["claude","ai","context","tokens","optimization","llm","cursor","windsurf","cline"],"description":"Zero-install context discipline for Claude. 5-27x fewer tokens.","maintainers":[{"name":"anshmaj121","email":"anshmajumdar100@gmail.com"}],"readme":"# context-optimizer\r\n\r\n**5–27x fewer tokens. No setup required to start.**\r\n\r\nUse the skill alone — no install needed, works anywhere Claude runs.  \r\nAdd Python 3.7+ to unlock auto-manifest generation.\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\n| Tool | What it cuts | Install needed |\r\n|------|-------------|----------------|\r\n| 🪨 [Caveman](https://github.com/JuliusBrussee/caveman) | Output tokens (~75%) | One command |\r\n| 🔬 [code-review-graph](https://github.com/tirth8205/code-review-graph) | Input tokens (8.2x²) | pip + Python 3.10+ |\r\n| 🗜️ Context Optimizer | Input tokens (see benchmarks) | Zero to start |\r\n\r\n² [code-review-graph benchmarks](https://github.com/tirth8205/code-review-graph#benchmarks)\r\n\r\n## Why This Exists\r\n\r\nClaude has a **200K token context window** — but burning 20K tokens just to show a directory structure is wasteful. This toolkit teaches Claude to **fetch only what it needs**, **compress what it sees**, and **reason structurally** instead of reading raw files.\r\n\r\n**No API hacks. No leaked code. No reverse engineering.**\r\nJust official Claude features (Custom Instructions + Projects + Knowledge) and a lightweight local indexer.\r\n\r\n## Real-World Savings\r\n\r\n| Scenario | Before (tokens) | After (tokens) | Reduction |\r\n|----------|----------------|----------------|-----------|\r\n| Code review (3 files) | ~18,000 | ~1,200 | **15x** |\r\n| Debug a function | ~8,000 | ~400 | **20x** |\r\n| Plan a feature (5+ files) | ~35,000 | ~1,800 | **19x** |\r\n| Full monorepo analysis | ~80,000 | ~3,500 | **22x** |\r\n\r\n## Benchmarks\r\n\r\nReal results on **Health Sync** (private fitness app — 130 files, React + Firebase + shadcn/ui):\r\n\r\n| Task | With optimizer | Without (full src/) | Reduction |\r\n|------|----------------|---------------------|-----------|\r\n| Fix auth bug | 4,629 tokens | 175,229 tokens | **37x** |\r\n| Debug food scanner | 6,656 tokens | 175,229 tokens | **26x** |\r\n| Add dashboard widget | 8,805 tokens | 175,229 tokens | **20x** |\r\n| Update nutrition UI | 13,363 tokens | 175,229 tokens | **13x** |\r\n| **Average** | | | **~24x** |\r\n\r\n*Without optimizer: 130 files loaded into context. With optimizer: manifest-first, 3 files max per task.*\r\nReproduce: `python3 tools/context_mapper.py /your/project`\r\n\r\n## How it works in practice\r\n\r\nWithout Context Optimizer, Claude reads every file it thinks\r\nmight be relevant — often 10–15 files before answering.\r\n\r\nWith Context Optimizer, Claude reads the manifest first,\r\nfetches 2–3 targeted files, then answers. Same result.\r\nFraction of the context.\r\n\r\n## Quick Start\r\n\r\n**Option A — One command (Node 14+):**\r\n```bash\r\nnpx @anshmaj121/context-optimizer init ./your-project\r\n```\r\nDetects your editor (Cursor, Windsurf, Cline, Claude Code) and installs the skill automatically.\r\n\r\n**Option B — Manual:**\r\n```bash\r\n# 1. Clone the repo\r\ngit clone https://github.com/anshmajumdar121/context-optimizer.git\r\ncd context-optimizer\r\n\r\n# 2. Generate a manifest of your project\r\npython3 tools/context_mapper.py /path/to/your/project\r\n\r\n# 3. Upload CONTEXT_MANIFEST.md to a Claude Project (optional but recommended)\r\n\r\n# 4. Paste the one-click prompt into Claude Desktop/Web\r\ncat prompt/one-click-vertical-prompt.md | pbcopy  # macOS\r\ncat prompt/one-click-vertical-prompt.md | xclip   # Linux\r\n```\r\n\r\n## How It Works\r\n\r\n```\r\nYour Project\r\n    │\r\n    ▼\r\ncontext_mapper.py ──► CONTEXT_MANIFEST.md\r\n                            │\r\n                            ▼\r\n                    Claude Project Knowledge\r\n                            │\r\n                            ▼\r\n                    skill/claude-custom-instructions.md\r\n                    (via Custom Instructions or CLAUDE.md)\r\n                            │\r\n                            ▼\r\n                    Token-Efficient Claude Sessions\r\n```\r\n\r\n### The Three Pillars\r\n\r\n**1. CONTEXT_MANIFEST.md** — A structural index of your codebase: file paths, languages, line counts, import graphs, and blast-radius data. Claude reads this instead of scanning directories.\r\n\r\n**2. Core Skill** — Custom instructions that enforce structural reasoning, limit file fetches to 3/turn, and compress all output into a strict format.\r\n\r\n**3. Session Activator** — A one-click prompt to paste at the start of any session when you can't use Custom Instructions.\r\n\r\n## File Structure\r\n\r\n```\r\ncontext-optimizer/\r\n├── context-optimizer-skill/\r\n│   ├── SKILL.md                     # Skill with YAML frontmatter (for skill registries)\r\n│   └── LICENSE.txt\r\n├── skill/\r\n│   └── claude-custom-instructions.md  # Paste into Claude Custom Instructions\r\n├── prompt/\r\n│   └── one-click-vertical-prompt.md   # Paste at start of any session\r\n├── scripts/\r\n│   └── install.sh                   # Full-stack installer (idempotent)\r\n├── tools/\r\n│   └── context_mapper.py            # Manifest + dependency graph generator\r\n├── .claude/\r\n│   ├── COMMON_MISTAKES.md           # Project-specific bug history\r\n│   ├── QUICK_START.md               # Daily commands\r\n│   └── ARCHITECTURE_MAP.md          # High-level routing & layers\r\n├── .claudeignore                    # Files excluded from Claude's context\r\n└── docs/\r\n    ├── learnings/                   # Session insights (gitignored)\r\n    └── archive/                     # Old versions (gitignored)\r\n```\r\n\r\n## Usage Guide\r\n\r\n### Option A: Claude Projects (Recommended)\r\n1. Run `python3 tools/context_mapper.py /your/project`\r\n2. Upload `CONTEXT_MANIFEST.md` to a Claude Project as Knowledge\r\n3. Add `skill/claude-custom-instructions.md` to Project Instructions\r\n4. Start chatting — Claude will reason from the manifest automatically\r\n\r\n### Option B: Custom Instructions (Global)\r\n1. Go to Claude Settings → Custom Instructions\r\n2. Paste the contents of `skill/claude-custom-instructions.md`\r\n3. For each project, paste `CONTEXT_MANIFEST.md` into the chat or upload it\r\n\r\n### Option C: Per-Session Activation\r\n1. Open any Claude chat\r\n2. Paste `prompt/one-click-vertical-prompt.md` as your first message\r\n3. Claude confirms: `✅ Context Optimizer active.`\r\n4. Upload or paste `CONTEXT_MANIFEST.md` and start your task\r\n\r\n### Option D: Claude Code / CLAUDE.md\r\nRun the installer — it auto-detects `.claude/` and injects the skill into `CLAUDE.md`:\r\n```bash\r\n./scripts/install.sh /your/project\r\n```\r\n\r\n## Manifest Generator\r\n\r\n```bash\r\n# Basic usage\r\npython3 tools/context_mapper.py /path/to/project\r\n\r\n# Blast-radius analysis (find all files affected by a change)\r\npython3 tools/context_mapper.py /path/to/project --blast-radius src/auth.py,src/models.py\r\n```\r\n\r\n**Output files:**\r\n- `CONTEXT_MANIFEST.md` — Human + AI readable manifest\r\n- `.claude/graph.json` — Machine-readable dependency graph\r\n\r\n## Overrides & Controls\r\n\r\n| Command | Effect |\r\n|---------|--------|\r\n| `RELOAD CONTEXT OPTIMIZER` | Reset all rules for this session |\r\n| `MAX_FILES: 5` | Allow up to 5 files per turn |\r\n| `BUDGET: 2000` | Raise token budget to 2,000 |\r\n| `COMPRESSION: lite` | Less aggressive compression |\r\n| `TEMP VERBOSE` | One-turn verbose mode, then revert |\r\n\r\n## Contributing\r\n\r\nSee [CONTRIBUTING.md](CONTRIBUTING.md). PRs welcome — especially for new language parsers in `context_mapper.py`.\r\n\r\n## Ecosystem\r\n\r\n| Tool | Role |\r\n|------|------|\r\n| [Caveman](https://github.com/JuliusBrussee/caveman) | Cuts Claude **output** tokens (~75%) |\r\n| [context-optimizer](https://github.com/anshmajumdar121/context-optimizer) | Cuts Claude **input** tokens (13–37x) |\r\n| [code-review-graph](https://github.com/tirth8205/code-review-graph) | Input tokens for large monorepos with git history (8.2x) |\r\n\r\nBest results: install Caveman + Context Optimizer together. They solve opposite sides of the same problem.\r\n\r\n## License\r\n\r\nMIT — see [LICENSE](LICENSE).\r\n","readmeFilename":"README.md"}