context-optimizer
Skill3 starsChanged 7 months agoMITView on GitHub
Minimizes token/context usage in Claude Code and long sessions without sacrificing model capability or output quality. Activates automatically when working on coding projects, long debugging sessions, multi-file exploration, or when the user mentions session limits, context bloat, or slowdowns. Also triggered by /scope, /compress, /handoff, /resume commands.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- 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
- rohitg00/pro-workflowtheir own version, first seen Sep 29, 2026
- tygwan/cc-initializertheir own version, first seen Jan 24, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- rohitg00/pro-workflow★ 2.9ksame name
- delorenj/skills★ 17same name
- Bexruz-cell/agent-skills★ 1same 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.
- templates/CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 6 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
Check CLAUDE.md → know the project without asking.
- Very specific: line 50
Check docs/session-handoff.md → know exactly where to resume.
- Very specific: line 52
If no CLAUDE.md exists → run /init or generate one now using the template.
- Distinctive: line 56
If >3 files seem relevant, create a minimal shortlist with reasons first.
- Very specific: line 60
Update docs/session-handoff.md with current state.
- Very specific: line 62
Run /compress to summarize and free context.
- Very specific: line 65
Write handoff state to docs/session-handoff.md.
- Very specific: line 66
Run /clear (new unrelated task = new session).
- Distinctive: line 73
When compressing or summarizing prior context:
- Very specific: line 89
Disable: search/research/MCP connectors unless that specific step needs them.
- Distinctive: line 92
Never leave large tool outputs sitting in context after they've been acted on.
- Distinctive: line 98
Always scope before acting:
- Distinctive: line 101
Always compress on switch:
“Common” is measured: kept by at least 6 in 10 of the 6 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 Skill
Mission
Maximize useful signal per token. Every turn should move the task forward with the smallest context footprint possible — without dropping capability, accuracy, or output quality. You are not cutting corners. You are cutting noise.
Memory Hierarchy (non-negotiable)
| Tier | File | What lives here |
| 1 — Permanent | CLAUDE.md | Project rules, stack, commands, conventions. Never repeated in chat. |
| 2 — Session | docs/session-handoff.md | Current task state, files touched, next exact step, blockers. |
| 2 — Decisions | docs/decision-log.md | Architecture choices, why they were made, what was rejected. |
| 2 — Map | docs/context-map.md | Module ownership, key interfaces, where to edit common concerns. |
| 3 — Scratchpad | Live chat | Temporary reasoning only. Expendable. |
Rule: If it matters beyond this turn, it belongs in a Tier 1 or Tier 2 file — not in chat.
Default Workflow (every session)
On Start
- Check
CLAUDE.md→ know the project without asking. - Check
docs/session-handoff.md→ know exactly where to resume. - Restate the task in ≤3 bullets. Name the exact files you'll touch.
- If no
CLAUDE.mdexists → run/initor generate one now using the template.
On Each Task
- Load only the files needed for this specific task. Not the whole repo.
- If >3 files seem relevant, create a minimal shortlist with reasons first.
- Work in targeted prompts: "Edit
auth.ts, updatelogin()to validate JWT expiry, run auth tests" — not "fix auth."
On Milestone Complete
- Update
docs/session-handoff.mdwith current state. - Log any architecture decisions in
docs/decision-log.md. - Run
/compressto summarize and free context.
On Task Switch
- Write handoff state to
docs/session-handoff.md. - Run
/clear(new unrelated task = new session). - Resume with: "Read CLAUDE.md and session-handoff.md. Continue: [next step]."
Compression Rules
When compressing or summarizing prior context:
- Keep: task goal, key decisions, exact filenames, current state, next action, open blockers.
- Drop: failed hypotheses (unless still open), repetitive explanation, raw debug logs already resolved.
- Format: structured bullets, not prose walls.
- Target: compress a 100k token history into a ~2-3k summary with zero capability loss.
Trigger /compress when:
- A feature is complete.
- A debugging loop has run 3–5 turns without resolution.
- Discussion feels repetitive.
- Context feels heavy/slow.
Tool Discipline
- Disable search/research/MCP connectors unless that specific step needs them.
- Disable extended thinking unless the task genuinely requires multi-step reasoning.
- After a large file read or search result → decide immediately: keep or clear.
- Never leave large tool outputs sitting in context after they've been acted on.
Prompting Rules (enforce these)
Always scope before acting:
"Summarize the task in 3 bullets, name exact files needed, ignore unrelated repo parts."
Always compress on switch:
"Compress prior discussion into: decisions made, open questions, next action. Then clear."
Always handoff cleanly:
"Update session-handoff.md and decision-log.md. Write a resume note under 150 words."
Anti-Patterns (never do these)
| Anti-pattern | Why it's bad |
| Repeating full project context in every prompt | CLAUDE.md exists for this |
| One mega-session for unrelated features | Cross-task residue pollutes context |
| Leaving connectors/search enabled all session | Token-intensive, confirmed by Anthropic |
| Vague prompts like "fix auth" or "improve this" | Forces broad exploration = token explosion |
| Keeping stale project files in context | Anthropic explicitly recommends removing these |
| Storing reasoning in chat instead of memory files | Chat is not persistent memory |
Custom Commands
| Command | Action |
/scope | Restate task, list exact files, ignore everything else |
/compress | Summarize history → decisions + state + next step. Drop noise. |
/handoff | Write full state to session-handoff.md. Prepare for /clear. |
/resume | Load CLAUDE.md + session-handoff.md. Restate exact next step. |
/audit | List what's in context. Flag anything that can be cleared or moved to files. |
See commands/ folder for full prompts for each command.
Guiding Principle
Chat is a scratchpad. Files are memory. Treat them that way.
The goal is not fewer tokens at the cost of quality — it's zero wasted tokens while keeping every token that actually matters. A clean 20k context outperforms a bloated 180k context every time.
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.

