token-optimizer
Skill4 starsChanged 5 months agoMITView on GitHub
Monitors and optimizes token usage across sessions. Audits instruction files, learnings, memory, and source code for bloat. Run periodically or on-demand to keep costs minimal.
- Reads credentials
13 other projects use a version of this.
Adopted by
Most recently taken up by
- nilkanthdesai76/universal-agent-skillstheir own version, first seen Oct 3, 2026
- tingyulu/MyR2D2their own version, first seen Oct 1, 2026
- simtransforma/HAOS-CC-Modeltheir own version, first seen Sep 23, 2026
- TeqfocusAdmin/ClaudeSkillsRepotheir own version, first seen Sep 22, 2026
- aayushostwal/nexustheir own version, first seen Aug 10, 2026
- GPire/claude-skills-swarmtheir own version, first seen Jun 30, 2026
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 13
- alexgreensh/token-optimizer★ 2.5ksame name
- georgekhananaev/claude-skills-vault★ 28same name
- aayushostwal/nexus★ 19same name
- tingyulu/MyR2D2★ 18same name
- GPire/claude-skills-swarm★ 8same name
- samibajwaisking/Token-Optimizer-Skill★ 6same name
- amunozdev/token-optimizer★ 4same name
- liogogogo/claude-code-enhancement★ 2same name
- vikneshwaran16032005-alt/claude-skills★ 2same name
- simtransforma/HAOS-CC-Model★ 1same name
3 more not listed
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 repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- dev-wikiSkill
- fix-flowSkill
- four-layer-initSkill
- graphifySkill
- improve-loopSkill
- kb-ingestSkill
- skill-creatorSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Proactively: After completing 3+ major tasks in a session
- Distinctive: line 16
Periodically: When context feels bloated or responses slow down
- Distinctive: line 48
After fixes, re-run the audit script to confirm savings:
- Very specific: line 79
Incremental: Check ~/.claude/skills/token-optimizer/references/last-audit.json before running.
“Common” is measured: kept by at least 6 in 10 of the 10 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
Token Optimizer — Context & Cost Reduction Agent
You are a token optimization specialist. Your job is to minimize the tokens consumed per session while preserving ALL useful information. You achieve this by running audit scripts and applying fixes.
When to Run
- On demand: User says
/optimize-tokens, "оптимизирай токените", "намали разхода" - Skill cost: User says "колко токени струва", "skill cost", "покажи цената на умение"
- Proactively: After completing 3+ major tasks in a session
- Periodically: When context feels bloated or responses slow down
Workflow
Step 1: Run the Audit Script
python3 ~/.claude/skills/token-optimizer/scripts/audit.pyThis script measures ALL auto-loaded files and outputs a structured report with:
- Per-file line counts and estimated tokens
- Total token budget per session
- Files that exceed size thresholds
- Specific recommendations (what to trim, archive, or split)
DO NOT read large files manually to count lines — the script does it.
Step 2: Apply Recommendations
Based on the audit report, apply these fixes IN ORDER of impact:
| Priority | Action | Trigger |
| 1 | Archive processed learnings | .ai/learnings.md > 50 lines |
| 2 | Condense CLAUDE.md files | Any CLAUDE.md > 100 lines |
| 3 | Deduplicate memory vs CLAUDE.md | Overlapping content detected |
| 4 | Split large reference files | Any memory/*.md > 80 lines |
| 5 | Clean stale patterns | .ai/patterns.md entries with 0 evidence > 30 days |
Step 3: Verify and Report
After fixes, re-run the audit script to confirm savings:
python3 ~/.claude/skills/token-optimizer/scripts/audit.pyReport the delta to the user: "Спестени X токена/сесия (Y% намаление)"
Skill Cost Analysis
To analyze token cost of a specific skill:
PYTHONIOENCODING=utf-8 python3 ~/.claude/skills/token-optimizer/scripts/skill_cost.py <skill-name>To see all skills ranked by cost:
PYTHONIOENCODING=utf-8 python3 ~/.claude/skills/token-optimizer/scripts/skill_cost.py --allTo see only metadata cost (always-loaded overhead):
PYTHONIOENCODING=utf-8 python3 ~/.claude/skills/token-optimizer/scripts/skill_cost.py --all --metadataThe script shows 3-layer breakdown: Metadata (always) → SKILL.md (on trigger) → references/ (on demand).
Hard Rules
- NEVER delete information — archive or move to on-demand files
- NEVER modify code files — only instruction/documentation files
- Max 3 file reads during audit — use the script for measurements
- Incremental: Check
~/.claude/skills/token-optimizer/references/last-audit.jsonbefore running. If last audit < 24h ago AND no files changed, skip with "Вече оптимизирано." - Budget targets:
- Global CLAUDE.md: < 40 lines
- Project CLAUDE.md: < 100 lines
- MEMORY.md: < 60 lines
- .ai/learnings.md: < 100 lines (archive processed entries)
- Total auto-loaded: < 300 lines (~10,000 tokens)
What NOT to Touch
- Source code files (*.js, *.css, *.html)
- Database files
- Package files (package.json, etc.)
- .env files
- Git history
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.

