Iteratively optimizes prompts for token efficiency by maximizing information density - reduces verbosity, removes redundancy, tightens phrasing while preserving semantic content. Use when asked to compress, shorten, reduce tokens, tighten, maximize density, increase information density, or make a prompt more concise.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Iteratively optimizes prompts for token efficiency by maximizing information density - reduces verbosity, removes redundancy, tightens phrasing while preserving semantic content. Use when asked to compress, shorten, reduce tokens, tighten, maximize density, increase information density, or make a prompt more concise.
metadata
{"internal":true}
Optimize Prompt Token Efficiency
Iteratively optimize prompt token efficiency by maximizing information density through verification loops. Primary goal: reduce token consumption while preserving all semantic content for AI-consumed prompts (CLAUDE.md, skills, agent prompts, specs).
Overview
This skill transforms verbose prompts into token-efficient versions through:
Verification First - prompt-token-efficiency-verifier checks for inefficiencies before any changes
Optimization - Apply targeted compression based on verifier feedback
Re-verification - Verify compression is lossless, iterate if issues remain (max 5 iterations)
Output - Atomic replacement only after verification passes
Loop: Read → Verify → (Exit if efficient) → Optimize based on feedback → Re-verify → (Iterate if issues) → Output
Key principle: Don't try to optimize in one pass. The verifier drives all changes - if it finds no inefficiencies, the prompt is already token-efficient.
Workflow
Phase 0: Create Task List (use task management immediately)
Create todos tracking workflow phases. List reflects areas of work, not fixed steps.
prompt: "Verify prompt token efficiency. File: {working_path}. Check for redundancy, verbose phrasing, filler words, structural inefficiencies, and compression opportunities. Report VERIFIED if already efficient, or INEFFICIENCIES_FOUND with specific details."
Step 2.3: Handle verifier response
If "VERIFIED": Mark todo completed, proceed directly to Phase 4 (Output) with message: "Prompt is already token-efficient. No changes needed."
If "INEFFICIENCIES_FOUND": Mark todo completed, save the issues list, add "Optimization iteration 1" todo and proceed to Phase 3
If verifier fails or returns unexpected format: Retry once with identical parameters. If retry fails, report error: "Verification failed - cannot proceed without verifier."
Step 2.4: Display verifier findings
If inefficiencies found, show user summary and proceed:
Verifier found {count} token efficiency issues. Proceeding with optimization...
Mark "Initial verification" todo completed.
Phase 3: Optimization Loop (Verifier-Driven)
Mark "Optimization iteration 1" todo in_progress.
Key principle: All fixes are driven by verifier feedback. Do NOT analyze the prompt independently - only fix the specific inefficiencies the verifier reported.
For each iteration from 1 to 5:
Apply compressions from verifier feedback: For each inefficiency in the verifier's report, apply the suggested compression. Write optimized version to working_path.
Only fix inefficiencies the verifier identified - do not add your own improvements
Re-verify: Launch prompt-token-efficiency-verifier agent via Task tool:
prompt: "Verify compression is lossless. Original file: {original_path}. Compressed file: {working_path}. Compare semantic content - check for missing facts, altered meaning, lost emphasis, removed nuance. Report VERIFIED if lossless, or ISSUES_FOUND with specific gaps."
Handle response:
If "VERIFIED": mark todo completed, exit loop, proceed to Phase 4
If "ISSUES_FOUND" and iteration < 5: mark todo completed, save new issues list, add "Optimization iteration {next}" todo, continue to next iteration
If "ISSUES_FOUND" and iteration = 5: mark todo completed with note about unresolved issues, proceed to Phase 4 with warning
If verifier fails or returns unexpected format: display error to user, retry once with identical parameters. If retry fails, proceed to Phase 4 with warning: "Verification incomplete - manual review recommended."
Compression Techniques
Apply these techniques to fix inefficiencies flagged by the verifier:
Technique
Description
Before → After
Redundancy removal
Eliminate repeated concepts
"It is important to note that you should always remember to..." → "Always..."
Terse phrasing
Replace verbose constructions
"In order to accomplish this task, you will need to..." → "To do this:"
Filler elimination
Remove hedging, qualifiers, throat-clearing
"Make sure that you do not forget to include..." → "Include:"
Structural optimization
Merge/reorganize sections
"First X. After that Y. Then Z." → "Steps: X → Y → Z"