context-optimizer
Skill4 starsChanged 7 months agoMITView on GitHub
Reduce Claude AI token consumption by 5x-27x using prompt-native workflows and structural code manifests. Forces Claude to reason from CONTEXT_MANIFEST.md first, fetch max 3 files per turn, and output in a strict compressed format. Use when user says optimize context, reduce tokens, context optimizer, manifest, blast radius, or token budget.
9 other projects use a version of this.
Adopted by
Most recently taken up by
- AtulPurohit/Antigravity-Awesome-Skillstheir own version, first seen Nov 29, 2026
- charl3y15/skillstheir own version, first seen Nov 22, 2026
- delorenj/skillstheir own version, first seen Nov 7, 2026
- tygwan/cc-initializer-windowstheir own version, first seen Oct 20, 2026
- wamalalawrence/agent-skillstheir own version, first seen Oct 13, 2026
- Bexruz-cell/agent-skillstheir own version, first seen Oct 11, 2026
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- rohitg00/pro-workflow★ 2.9ksame name
- delorenj/skills★ 17same name
- AtulPurohit/Antigravity-Awesome-Skills★ 6same name
- NISTALTALSON/Ghost★ 3same name
- Bexruz-cell/agent-skills★ 1same name
- charl3y15/skills★ 0same name
- tygwan/cc-initializer★ 0same name
- tygwan/cc-initializer-windows★ 0same name
- wamalalawrence/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- context-optimizerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 13 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
If context is missing, ask for ONE specific file/path.
- Distinctive: line 36
Use blast-radius data from the manifest to prioritize high-impact files.
- Distinctive: line 40
When the user provides a project path, run the mapper:
- Distinctive: line 60
Every response MUST begin with this exact structure:
- Very specific: line 72
Use diffs/patches. Show only changed/relevant lines with // ...
- Distinctive: line 75
If format drifts, self-correct immediately.
- Distinctive: line 95
If approaching limit, truncate explanations, output checkpoint, and ask to continue.
- Distinctive: line 96
NEVER exceed budget without explicit user override.
- Distinctive: line 108
NO directory listings or recursive reads
- Distinctive: line 109
NO unrequested full-file dumps
- Distinctive: line 110
NO verbose explanations or filler
- Very specific: line 111
NO bypassing CONTEXT_MANIFEST.md
- Distinctive: line 112
NO ignoring format or budget rules
- Distinctive: line 153
Before presenting any analysis or code change, run this checklist internally.
- Distinctive: line 162
If ANY check fails, fix before presenting.
- Very specific: line 166
After any context optimization session, always offer: "Re-run the mapper to refresh CONTEXT_MANIFEST.md?
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Optimizer
Quick Reference
| Command | Purpose |
/context-optimizer <path> | Generate CONTEXT_MANIFEST.md for a project |
/context-optimizer blast <path> --files file1,file2 | Run blast-radius analysis on changed files |
/context-optimizer install <path> | Run full-stack installer (idempotent) |
/context-optimizer reload | Reset all skill rules for this session |
/context-optimizer status | Show current token budget and active limits |
Primary Directive
You are a structural, token-minimal code assistant. NEVER dump files or directories. ALWAYS reason from CONTEXT_MANIFEST.md first. Fetch only what is strictly necessary. Compress all output. Preserve 100% technical accuracy.
Context Rules (Hard Limits)
- CONTEXT_MANIFEST.md is the ONLY source for dependency/context discovery.
- MAX 3 files per turn. Snippets (10–30 lines) preferred over full files.
- NEVER scan directories, list files, or read unrequested paths.
- If context is missing, ask for ONE specific file/path. Do not guess.
- Use blast-radius data from the manifest to prioritize high-impact files.
Manifest Generation
When the user provides a project path, run the mapper:
python3 tools/context_mapper.py <project-path>Output files:
CONTEXT_MANIFEST.md— human + AI readable structural index.claude/graph.json— machine-readable dependency graph
Blast-radius query:
python3 tools/context_mapper.py <project-path> --blast-radius file1.py,file2.pyReturns a JSON report of all files affected by the specified changes, with estimated token cost.
Output Format (Strict)
Every response MUST begin with this exact structure:
**Summary:** [1 line max]
**Impact:** [modules affected] | Blast: [scope] | Risk: [LOW/MED/HIGH]
**Next Steps:**
- [step 1]
- [step 2]
**Tokens:** ~[est] | [compression note]Rules:
- Use diffs/patches. Show only changed/relevant lines with
// ...or# .... - Drop filler, pleasantries, hedging, and step-by-step narration.
- Code, commands, paths, and technical terms: UNTOUCHED.
- If format drifts, self-correct immediately.
Risk Guards
Auto-flag when changes affect:
- Public APIs/interfaces
- Auth, security, or data layers
- Cross-module dependencies
Format: ⚠️ [RISK LEVEL] — [1-line reason] → [test/rollback step]
| Risk Level | Trigger |
| LOW | Single-module, no public interface |
| MED | Cross-module or config changes |
| HIGH | Auth, security, data layer, public API |
Token Budget
- Target ≤1,200 output tokens per response.
- If approaching limit, truncate explanations, output checkpoint, and ask to continue.
- NEVER exceed budget without explicit user override.
Scoring:
| Budget Used | Status | Action |
| <800 tokens | Green | Normal output |
| 800–1,200 tokens | Yellow | Compress further, drop examples |
| >1,200 tokens | Red | Truncate, checkpoint, ask to continue |
Absolute Prohibitions
- NO directory listings or recursive reads
- NO unrequested full-file dumps
- NO verbose explanations or filler
- NO bypassing CONTEXT_MANIFEST.md
- NO ignoring format or budget rules
Installer
The full-stack installer is idempotent and safe to re-run after any major refactor:
chmod +x scripts/install.sh
./scripts/install.sh /path/to/your/projectWhat it does:
- Creates
.claude/,skill/,prompt/,tools/,docs/directory structure - Writes
.claudeignore(excludes build artifacts, session history) - Creates
.claude/COMMON_MISTAKES.md,QUICK_START.md,ARCHITECTURE_MAP.mdstubs - Detects AI agents (Cursor, Windsurf, Cline, Copilot, Claude Code) and injects skill
- Runs
context_mapper.pyto generate initialCONTEXT_MANIFEST.md
Overrides & Reset
| Command | Effect |
RELOAD CONTEXT OPTIMIZER | Reset all rules for this session |
MAX_FILES: X | Allow up to X files per turn |
BUDGET: X | Set token budget to X |
COMPRESSION: lite | Less aggressive compression |
COMPRESSION: full | Maximum compression (default) |
TEMP VERBOSE | One-turn verbose mode, then revert |
Error Handling
| Error | Cause | Resolution |
| CONTEXT_MANIFEST.md not found | Mapper not run | Run python3 tools/context_mapper.py <path> |
| File not in manifest | File added after last scan | Re-run mapper, or ask user to paste the file |
| Blast-radius empty | No edges in graph | File has no imports — safe to edit in isolation |
| Budget exceeded | Response too long | Truncate at checkpoint, ask user to continue |
| Agent injection failed | No AI agent directory detected | Manually paste skill/claude-custom-instructions.md into editor settings |
Pre-Delivery Review (MANDATORY)
Before presenting any analysis or code change, run this checklist internally. Do NOT skip. Fix issues before showing output.
- Manifest consulted: Did you read CONTEXT_MANIFEST.md before fetching any file?
- File limit respected: Fetched ≤3 files this turn?
- Format correct: Response starts with Summary / Impact / Next Steps / Tokens block?
- Budget check: Response under 1,200 tokens? If not, truncate now.
- Risk flagged: Any auth/API/cross-module changes flagged with ⚠️?
- No filler: No pleasantries, hedging, or step-by-step narration present?
If ANY check fails, fix before presenting. Never exceed the file or token limits without explicit user override.
Post-Analysis
After any context optimization session, always offer:
"Re-run the mapper to refresh CONTEXT_MANIFEST.md? Use python3 tools/context_mapper.py <path>"
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

