Shadows Context Optimizer
by @nakedoshadow
Token and context window optimization — compact prompts, reduce redundancy, prioritize critical context. Use when hitting context limits or to improve agent...
clawhub install shadows-context-optimizer📖 About This Skill
name: context-optimizer description: "Token and context window optimization — compact prompts, reduce redundancy, prioritize critical context. Use when hitting context limits or to improve agent efficiency." metadata: { "openclaw": { "emoji": "⚡", "homepage": "https://clawhub.ai/NakedoShadow", "os": ["darwin", "linux", "win32"] } }
Context Optimizer — Token Economy Protocol
Version: 1.1.0 | Author: Shadows Company | License: MIT
WHEN TO TRIGGER
WHEN NOT TO TRIGGER
PREREQUISITES
No binaries required. This is a pure reasoning skill about optimizing context window usage. It provides strategies and patterns — it does not execute commands or access external systems.
PRINCIPLES
1. Reference Over Inline
Instead of reading entire files into context, reference them:
src/auth/index.ts handles..." instead of pasting 500 linesRead file.py lines 45-80 instead of the whole file2. DRY Prompts — Zero Duplication
3. Lazy-Load Strategy
4. Smart File Reading
WRONG: Read the entire 2000-line file
RIGHT: Read lines 150-200 where the function is definedWRONG: Read all 15 config files
RIGHT: Read only the config relevant to current task
WRONG: Grep the entire codebase for "import"
RIGHT: Grep specific directories for specific patterns
5. Output Compression
When reporting results:
TECHNIQUES
Technique 1 — Context Audit
Assess current context usage: 1. Count how many files have been read in this session 2. Identify which file contents are still relevant to the current task 3. Determine what information can be summarized instead of kept verbatim 4. Flag redundant tool results that repeat already-known information
Technique 2 — Compaction
When context is high: 1. Summarize completed work (keep outcomes, drop process details) 2. Drop file contents that are no longer needed for the active task 3. Keep only active task context in working memory 4. Preserve critical state: decisions made, errors encountered, current objectives
Technique 3 — Subagent Delegation
For research-heavy tasks: 1. Spawn a subagent for codebase exploration 2. Subagent returns only findings (not raw file contents) 3. Main context stays clean for implementation 4. Multiple subagents can run in parallel for independent queries
Technique 4 — Structured Responses
WRONG (100 tokens):
"I've looked at the file and after careful analysis I believe that
the issue is related to the authentication middleware where the
token validation function doesn't properly handle expired tokens."RIGHT (30 tokens):
"Bug: validateToken() in auth middleware doesn't handle expired
tokens. Fix: add expiry check at line 45."
ANTI-PATTERNS TO AVOID
| Anti-Pattern | Fix | |-------------|-----| | Reading whole files when you need 10 lines | Use offset + limit | | Listing all MCP servers | Agent already knows them | | Repeating deny rules | Already in settings | | Describing the OS/environment | Already in system context | | Re-reading files read earlier | Summarize and reference | | Multiple searches for one query | One well-crafted search | | Verbose status updates | Concise milestone updates |
RULES
1. Minimum viable context — load only what's needed NOW 2. Summarize, don't accumulate — compress completed work 3. Delegate exploration — use subagents for research 4. Direct answers — skip preamble, lead with the point 5. 3-search maximum — never use more than 3 search tools for one query
SECURITY CONSIDERATIONS
This skill is purely advisory — it provides strategies for token optimization. It does not execute commands, read files, make network calls, modify configuration, or store data. Zero risk profile.
OUTPUT FORMAT
Apply the techniques above inline during agent operation. No separate report is generated — the skill manifests as improved efficiency in the agent's behavior: shorter responses, fewer tool calls, targeted file reads, and minimal context consumption.
Published by Shadows Company — "We work in the shadows to serve the Light."
⚙️ Configuration
No binaries required. This is a pure reasoning skill about optimizing context window usage. It provides strategies and patterns — it does not execute commands or access external systems.
🔒 Constraints
1. Minimum viable context — load only what's needed NOW 2. Summarize, don't accumulate — compress completed work 3. Delegate exploration — use subagents for research 4. Direct answers — skip preamble, lead with the point 5. 3-search maximum — never use more than 3 search tools for one query