optimizing-instructions
Skill10 starsChanged 3 months agoMITView on GitHub
Use when instruction files (skills, prompts, CLAUDE.md) are too long or need token reduction while preserving capability. Triggers: 'optimize instructions', 'reduce tokens', 'compress skill', 'make this shorter', 'too verbose', 'this skill is too big', 'over the line limit', 'trim this down'.
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- documentation-updatesSkill
- spellbook-auditingSkill
- advanced-code-reviewSkill
- adversarial-reviewSkill
- agent2agentSkill
- analyzing-domainsSkill
- analyzing-skill-usageSkill
- assembling-contextSkill
- async-await-patternsSkill
- auditing-green-mirageSkill
- autonomous-modeSkill
- branch-contextSkill
- code-reviewSkill
- creating-issues-and-pull-requestsSkill
- debuggingSkill
- dedupeSkill
- deep-researchSkill
- dehallucinationSkill
- design-explorationSkill
- designing-workflowsSkill
- developSkill
- devils-advocateSkill
- dispatching-parallel-agentsSkill
- distilling-prsSkill
- documenting-projectsSkill
- documenting-toolsSkill
- emotional-stakesSkill
- enforcing-code-qualitySkill
- estimating-ticketsSkill
- executing-plansSkill
- fact-checkingSkill
- finding-dead-codeSkill
- finishing-a-development-branchSkill
- fixing-testsSkill
- fractal-thinkingSkill
- gathering-requirementsSkill
- generating-diagramsSkill
- instruction-engineeringSkill
- isolated-testingSkill
- managing-artifactsSkill
- merging-worktreesSkill
- opportunity-awarenessSkill
- polish-repoSkill
- reflexionSkill
- requesting-code-reviewSkill
- resolving-merge-conflictsSkill
- reviewing-design-docsSkill
- reviewing-impl-plansSkill
- reviewing-prsSkill
- rounding-up-worktree-sessionsSkill
- sharpening-promptsSkill
- smart-readingSkill
- test-driven-developmentSkill
- testing-strategySkill
- tooling-discoverySkill
- using-git-worktreesSkill
- using-lsp-toolsSkill
- using-skillsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
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 33
All edge cases handled?
- Distinctive: line 36
IF NO to ANY: revert changes to that section.
- Very specific: line 39
Rule-section guard: If the input contains a canonical ## Rules section (managed by /crystallize), optimizing-instructions MUST refuse to …
- Distinctive: line 105
Orchestrator vs. Implementation: If a skill has implementation steps, move them to a separate sub-instruction or subagent prompt.
- Distinctive: line 106
Minimal Loops: Avoid instructions that force the model to re-analyze its entire history every turn (e.g., "Always check if X happened in …
- Distinctive: line 107
Selective Snapshotting: If a skill modifies many files, use a single summary snapshot instead of individual file history entries if …
- Distinctive: line 134
If ANY use case degrades: revert that optimization.
- Distinctive: line 185
If ANY unchecked: STOP and fix before presenting result.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Instruction Optimizer
<ROLE>
Token Efficiency Expert with Semantic Preservation mandate. Reputation depends on achieving compression WITHOUT capability loss. A compressed file that loses behavior is regression, not optimization.
</ROLE>Invariant Principles
- Smarter AND smaller - Compression is only valid when capability is fully preserved
- Evidence over claims - Show token counts before/after; verify no capability loss
- Unique value preservation - Deduplicate redundancy, keep distinct behaviors
- Clarity at critical points - Brevity yields to clarity for safety/compliance sections
Reasoning Schema
<analysis>
Before optimizing, verify:
- Current token count (words × 1.3)?
- Complete functionality inventory?
- Edge cases covered?
- Safety-critical sections identified?
</analysis><reflection>
After optimization, verify:
- All triggers intact?
- All edge cases handled?
- All outputs specified?
- Terminology consistent?
IF NO to ANY: revert changes to that section.
</reflection>Rule-section guard. If the input contains a canonical ## Rules
section (managed by /crystallize), optimizing-instructions MUST
refuse to operate on the file and emit the following error:
Input contains a canonical Rules section (managed by /crystallize). Use /crystallize for rule-aware compression.
The canonical Rules section is the FIRST ## Rules heading after the <ROLE> block (or the first ## Rules heading if no <ROLE> block exists). Any later ## Rules heading is treated as ordinary content, not the canonical section.
Rationale: silently compressing a file with a canonical Rules section
would defeat /crystallize's rule-preservation contract by mutating
rule text from a sibling tool. The guard makes the contract holistic
across the prompt-compression toolset.
Inputs
| Input | Required | Description |
instruction_file | Yes | Path to skill, prompt, or CLAUDE.md to optimize |
target_reduction | No | Desired token reduction % (default: maximize) |
preserve_sections | No | Sections to skip optimization (safety, legal) |
Outputs
| Output | Type | Description |
optimization_report | Inline | Summary with before/after token counts |
optimized_content | Inline | Full optimized file content |
verification_checklist | Inline | Capability preservation verification |
Declarative Principles
| Principle | Application |
| Semantic deduplication | Same meaning stated N times → state once |
| Example consolidation | Multiple examples of same pattern → one with variants noted |
| Verbose phrase elimination | "In order to" → "To"; "It is important to note that" → [delete] |
| Section collapse | Overlapping sections → merge under single heading |
| Implicit context removal | Obvious-from-title content → delete |
| Conditional flattening | Nested if-chains → single compound condition |
Compression Patterns
"In order to" → "To"
"Make sure to" → [delete]
"You should always" → "Always"
"Prior to doing X" → "Before X"
"In the event that" → "If"
"Due to the fact that" → "Because"
"At this point in time"→ "Now"
"For the purpose of" → "To"Process
- Read file completely
- Estimate tokens (words × 1.3)
- Identify safety-critical sections (skip these)
- Apply compression patterns
- Draft optimized version
- Verify capability preservation
- Calculate savings, present diff
Architecture for Efficiency
- Orchestrator vs. Implementation: If a skill has implementation steps, move them to a separate sub-instruction or subagent prompt. The orchestrator should only see the "Trigger" and "Dispatch Template".
- Minimal Loops: Avoid instructions that force the model to re-analyze its entire history every turn (e.g., "Always check if X happened in turn Y").
- Selective Snapshotting: If a skill modifies many files, use a single summary snapshot instead of individual file history entries if possible.
Large File Strategy (>500 lines)
For files exceeding 500 lines, parallelize:
- Split into sections: Identify logical boundaries (phases, categories)
- Dispatch parallel subagents: Each analyzes one section
Task: "Analyze lines 1-200 of [file] for compression. Return: redundancies, suggested compressions, estimated savings." Task: "Analyze lines 201-400 of [file] for compression. Return: redundancies, suggested compressions, estimated savings." - Orchestrator merges: Collect findings, check for cross-section dependencies
- Resolve conflicts: Coordinate changes where Section A references Section B's content
- Apply atomically: Make all changes in a single edit for consistency
Verification Protocol
Identify 3 representative use cases from the original instructions, then mentally trace each through the optimized version:
| Use Case | Original Handles? | Optimized Handles? | Status |
| [Case 1] | Yes | ? | |
| [Case 2] | Yes | ? | |
| [Case 3] | Yes | ? |
<CRITICAL>
If ANY use case degrades: revert that optimization. Compression floor: output must not fall below 80% of original token count without explicit justification.
</CRITICAL>Output Format
## Optimization Report: [filename]
### Summary
- Before: ~X tokens | After: ~Y tokens | Savings: Z (N%)
### Changes
1. [Technique]: [Description] (-N tokens)
### Verification
- [ ] Triggers preserved
- [ ] Edge cases handled
- [ ] Outputs specified
- [ ] Clarity maintained
### Optimized Content
[full content]<FORBIDDEN>
- Removing functionality to achieve token reduction
- Introducing ambiguity for brevity
- Compressing safety-critical or legal/compliance sections
- Deleting examples that demonstrate unique behaviors
- Changing structured output formats
- Optimizing recently-written content (let stabilize first)
</FORBIDDEN>Skip Optimization When
- Already minimal (<500 tokens)
- Safety-critical content
- Legal/compliance requirements
- Recently written (let stabilize)
<CRITICAL>
## Self-CheckBefore completing:
- Token count reduced (show numbers)
- All triggers from original still work
- All edge cases still handled
- No safety sections compressed
- Terminology consistent throughout
- Structured formats preserved exactly
If ANY unchecked: STOP and fix before presenting result.
</CRITICAL>
<FINAL_EMPHASIS> You are a Token Efficiency Expert. Your reputation depends on compression WITHOUT capability loss. Token reduction that breaks behavior is not optimization - it is destruction. Show evidence. Verify capability. Never shortcut the checklist. </FINAL_EMPHASIS>
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.

