token-optimizer
Skill28 starsChanged 6 months agoMITView on GitHub
Reduce token count in prompts, docs, and prose. Covers prompt compression (40-60% savings), doc formatting, TOON data serialization, and Strunk's prose clarity rules. Use when compressing prompts, optimizing docs for LLM context, or writing clear technical prose.
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
- vatevstoil/claude-self-learning-ostheir own version, first seen Jul 4, 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
- 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
- vatevstoil/claude-self-learning-os★ 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 repository63 other files it gives its agents.
- .claude/skills/composition-patterns/AGENTS.mdAGENTS.md
- .claude/skills/react-best-practices/AGENTS.mdAGENTS.md
- .claude/skills/vercel-react-native-skills/AGENTS.mdAGENTS.md
- agy-cliSkill
- aws-cliSkill
- better-authSkill
- brainstormSkill
- claude-seoSkill
- code-qualitySkill
- codex-cliSkill
- color-accessibility-auditSkill
- vercel-composition-patternsSkill
- data-wranglerSkill
- doc-navigatorSkill
- domain-checkerSkill
- fastapi-senior-devSkill
- file-converterSkill
- firebase-cliSkill
- firecrawlSkill
- frontend-designSkill
- gemini-cliSkill
- github-cliSkill
- materialreacttable-masterySkill
- mcp-builderSkill
- mermaid-diagramSkill
- monday-comSkill
- mongodb-atlas-cliSkill
- multi-agent-patternsSkill
- n8n-cliSkill
- natural-languageSkill
- neon-postgres-agent-platformsSkill
- next-cache-componentsSkill
- nextjs-senior-devSkill
- next-upgradeSkill
- notebooklmSkill
- obsidian-skillsSkill
- owasp-securitySkill
- parallel-agentsSkill
- planning-with-filesSkill
- plan-to-tddSkill
- project-change-logSkill
- pydantic-modelSkill
- react-best-practicesSkill
- salesforce-cliSkill
- semantic-codingSkill
- senior-backendSkill
- skill-creatorSkill
- stripe-best-practicesSkill
- supabase-cliSkill
- swift-concurrency-6-2Skill
- swiftui-patternsSkill
- system-architectSkill
- terraformSkill
- testing-automation-expertSkill
- test-levelsSkill
- trailofbits-securitySkill
- ui-ux-pro-maxSkill
- uiux-toolkitSkill
- upgrade-packages-jsSkill
- vercel-cliSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
7
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 97
Remove when possible: "basically", "essentially", "actually", "really"
- Distinctive: line 157
Remove comments that restate the code.
- Very specific: line 179
Keep error codes and stack traces exact.
- Distinctive: line 191
Use comma after each term in series except last
- Distinctive: line 192
Don't join independent clauses by comma (use semicolon or period)
- Distinctive: line 200
Keep related words together
- Distinctive: line 201
Place emphatic words at end of sentence
- Distinctive: line 205
When context is tight: write draft, dispatch subagent with draft + these rules, have subagent copyedit and return revision.
“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
Reduce tokens in prompts, docs, and prose while preserving meaning.
When to Use
- Prompt >1500 tokens or contains redundant phrasing
- Docs/markdown need compression for LLM context
- Writing prose for humans (docs, commits, PRs, error messages)
- Converting JSON/YAML/XML data for LLM input (TOON)
Quick Routing
| Input Type | Go To |
| User prompt / chat message | Section 1: Prompt Compression |
| Docs / markdown / README | Section 2: Doc Formatting |
| Commits / PRs / error messages | Section 3: Prose Clarity |
| JSON / YAML / XML data | Section 4: TOON Format |
Compression Levels
| Level | Reduction | Use When |
| Light | 20-30% | Keep readability, human-facing prose |
| Medium | 40-50% | Default for LLM context |
| Heavy | 60-70% | Max compression, symbols over words |
1. Prompt Compression
Process
- Identify core intent
- Extract essential context only
- Remove filler phrases
- Apply abbreviations & symbols
- Output compressed version w/ token savings %
Remove Phrases
| Remove | Transform To |
| "Please help me with" | (delete) |
| "I need you to" | (delete) |
| "Could you please" | (delete) |
| "I would like to" | (delete) |
| "I think", "Maybe", "Perhaps" | (delete) |
| "This might be a dumb question" | (delete) |
| "For your reference" | (delete) |
| "As I mentioned before" | (delete) |
Transform Patterns
| Verbose | Compressed |
| "I want to create a fn that takes X and returns Y" | fn(X) -> Y |
| "The error message says..." | Error: ... |
| "In the file located at..." | File: ... |
| "I'm trying to..." | Goal: ... |
| "Here is my code..." | Code: |
| "The problem is that..." | Issue: ... |
Example
Before (847 tokens):
Hello! I hope you're doing well. I was wondering if you could help me.
I'm trying to build a React app and I need a custom hook that fetches
user data from /api/users. It returns JSON. I'd like loading, error
states, and caching. I think useEffect and useState but not sure...After (156 tokens):
Goal: React hook for user data fetching
- Endpoint: /api/users -> JSON user obj
- Handle: loading, error states
- Cache response
Stack: React (useEffect, useState)2. Doc Formatting
Remove Filler Words
Remove when possible: "basically", "essentially", "actually", "really"
| Verbose | Compressed |
| "in order to" | "to" |
| "due to the fact that" | "because" |
| "at this point in time" | "now" |
| "in the event that" | "if" |
| "has the ability to" | "can" |
| "it is important to note that" | (remove) |
Compress Lists
Before:
The following features are included:
- User authentication with JWT tokens
- Role-based access control for authorization
- Password hashing using bcrypt algorithmAfter:
Features:
- JWT auth
- RBAC authz
- bcrypt passwordsStructured Data Over Prose
Before:
The API accepts three parameters. The first is "userId" which is a
required string. The second is "limit", optional number, defaults to 10.After:
Params:
- userId: str (req) - user ID
- limit: num (opt, def=10)Heading Compression
Before: # Comprehensive Guide to User Authentication and Authorization
After: # Auth Guide
Table Compression
Shorten column headers, use abbreviations in cells:
| Param | Type | Req | Def | Desc |
| userId | str | Y | - | user ID |
| limit | num | N | 10 | max results |
Code Block Compression
Remove comments that restate the code. Collapse trivial logic:
Before:
// Check if email is valid
const isEmailValid = emailRegex.test(email);
// Check if password is at least 8 characters
const isPasswordValid = password.length >= 8;
// Return true if both are valid
return isEmailValid && isPasswordValid;After:
return emailRegex.test(email) && password.length >= 8;URL & Path Compression
Replace full home paths: /Users/username/Documents/Projects/MyApp/config/settings.json -> ~/Projects/MyApp/config/settings.json
Error Message Compression
Keep error codes and stack traces exact. Compress surrounding prose:
Err: Invalid/expired token. Re-authenticate at /auth/login
3. Prose Clarity (Strunk's Rules)
Apply when writing prose for humans (docs, commits, PRs, errors).
Grammar Essentials
- Form possessive singular by adding 's
- Use comma after each term in series except last
- Don't join independent clauses by comma (use semicolon or period)
- Participial phrase at beginning refers to grammatical subject
Composition Essentials
- One paragraph per topic
- Begin paragraph with topic sentence
- Express coordinate ideas in similar form
- Keep related words together
- Place emphatic words at end of sentence
Limited Context Strategy
When context is tight: write draft, dispatch subagent with draft + these rules, have subagent copyedit and return revision.
Core Principles
Omit needless words:
| Wordy | Concise |
| the question as to whether | whether |
| there is no doubt but that | no doubt |
| he is a man who | he |
| the reason why is that | because |
Use active voice:
| Passive | Active |
| The file was deleted by the user | The user deleted the file |
| Errors are logged by the system | The system logs errors |
Positive form over negative:
| Negative | Positive |
| did not remember | forgot |
| not important | trifling |
| not honest | dishonest |
Specific over vague:
| Vague | Specific |
| A period of unfavorable weather set in | It rained every day for a week |
| The data was processed | The server parsed 10,000 records |
Technical Writing
# Commit: Bad
Made some changes to fix the bug that was causing issues
# Commit: Good
Fix null pointer in user authentication
# Error: Bad
An error occurred while processing your request
# Error: Good
Database connection failed: timeout after 30s
# Doc: Bad
This function is used for the purpose of validating user input
# Doc: Good
Validates user inputEditing Checklist
- Unnecessary words (especially "that", "very", "really", "just")
- Passive voice -> convert to active
- Negative statements -> make positive
- Vague language -> make specific
- Long sentences -> break up or simplify
4. TOON Format (Data Serialization)
TOON replaces JSON/YAML/XML data serialization when sending to LLMs. ~40% fewer tokens.
Convert to TOON: JSON, YAML, XML (data objects/arrays only) Keep as-is: Markdown, plain text, code files, CSV
Precedence note: TOON converts the data format structure (braces, quotes, colons). The "Never Compress" rules protect values inside data (API keys, URLs, version numbers). Both apply: convert structure to TOON, but preserve exact values.
JSON:
{"users":[{"id":1,"name":"John","role":"admin"},{"id":2,"name":"Jane","role":"user"}]}TOON:
users[2]{id,name,role}:
1,John,admin
2,Jane,userSee: .claude/skills/document-skills/toon/SKILL.md
Never Compress
See references/never_compress.md for full list:
- Auth tokens, API keys, credentials, secrets
- Error stack traces (keep full)
- Code blocks, inline code, regex
- URLs, UUIDs, version numbers
- SQL queries, shell commands
- JSON keys, config values, date formats
- Legal text, mathematical formulas
Abbreviations
fn=function ret=return str=string num=number
bool=boolean arr=array obj=object param=parameter
config=configuration env=environment
auth=authentication authz=authorization
db=database repo=repository dir=directory
req=required opt=optional def=default
max=maximum min=minimum ex=example
impl=implementation docs=documentation
app=application info=informationSymbols
-> = returns/produces & = and
| = or w/ = with
w/o = without ~ = approximately
=> = therefore bc = because
Y = yes N = no
- = none/nullOutput Format
## Compressed
[Content]
---
Original: X tokens | Compressed: Y tokens | Saved: Z%Scripts
# Compress text
python scripts/compress.py input.md > compressed.md
python scripts/compress.py input.md --stats
python scripts/compress.py --level 2 < input.md
# Count tokens
python scripts/count_tokens.py document.md
# Compress prompt
python scripts/compress_prompt.py "your prompt text"
python scripts/compress_prompt.py --file prompt.txt --level heavyIntegration
Called by: brainstorm (Phase 5 docs), any skill producing documentation
Pairs with: document-skills/toon (data serialization)
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.

