一键导入
context-optimization
Optimizes context window via MECW principles and memory tiering. Use when context exceeds 30% or before long multi-step tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Optimizes context window via MECW principles and memory tiering. Use when context exceeds 30% or before long multi-step tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Detects AI-generated writing patterns in prose. Use when reviewing docs for slop, vague language, or identity leaks before publishing.
Audits Rust code for unsafe blocks, ownership issues, and Cargo dependency risks. Use when reviewing Rust code or before merging Rust changes.
Recommends context compression strategies for bloated or quota-heavy sessions. Use when context feels sluggish or quota burns faster than expected.
Guide minimal code via a decision ladder with full safety, edge, and negative-case coverage. Use when adding code, choosing a dependency, or auditing a diff.
Generates or remediates documentation with human-quality writing. Use when creating new docs, rewriting AI-generated content, or applying style profiles.
Converts external documents (PDF, DOCX, PPTX, XLSX, HTML) into editable markdown. Use when ingesting external files for rewriting or project integration.
| name | context-optimization |
| description | Optimizes context window via MECW principles and memory tiering. Use when context exceeds 30% or before long multi-step tasks. |
| alwaysApply | false |
| category | conservation |
| token_budget | 150 |
| progressive_loading | true |
| modules | ["modules/context-waiting.md","modules/findings-format.md","modules/mecw-assessment.md","modules/mecw-principles.md","modules/memory-tiers.md","modules/session-routing.md","modules/subagent-coordination.md","modules/belief-clarity.md","modules/cache-aligned-prefixes.md"] |
| hooks | {"PreToolUse":[{"matcher":"Read","command":"echo \"[skill:context-optimization] 📊 Context analysis started: $(date)\" >> ${CLAUDE_CODE_TMPDIR:-/tmp}/skill-audit.log\n","once":true}],"PostToolUse":[{"matcher":"Bash","command":"# Track context analysis tools\nif echo \"$CLAUDE_TOOL_INPUT\" | grep -qE \"(wc|tokei|cloc|context)\"; then\n echo \"[skill:context-optimization] Context measurement executed: $(date)\" >> ${CLAUDE_CODE_TMPDIR:-/tmp}/skill-audit.log\nfi\n"}],"Stop":[{"command":"echo \"[skill:context-optimization] === Optimization completed at $(date) ===\" >> ${CLAUDE_CODE_TMPDIR:-/tmp}/skill-audit.log\n# Could export: context pressure events over time\n"}]} |
| model_hint | standard |
| role | hook-target |
def select_optimal_modules(context_situation, task_complexity):
if context_situation == "CRITICAL":
return ['mecw-assessment', 'subagent-coordination']
elif task_complexity == 'high':
return ['mecw-principles', 'subagent-coordination']
else:
return ['mecw-assessment']
| Utilization | Status | Action |
|---|---|---|
| < 30% | LOW | Continue normally |
| 30-50% | MODERATE | Monitor, apply principles |
| > 50% | CRITICAL | Immediate optimization required |
Behavior Change: Large bash command and tool outputs are saved to disk instead of being truncated; file references are provided for access.
| Scenario | Before 2.1.2 | After 2.1.2 |
|---|---|---|
| Large test output | Truncated, partial data | Full output via file reference |
| Verbose build logs | Lost after 30K chars | Complete, accessible on-demand |
| Context pressure | Less from truncation | Same - only loaded when read |
head, tail, or grep on file references.modules/mecw-principles.md for core concepts, the 50% rule, and quick-start code examples.modules/mecw-assessment.md for risk identification.modules/subagent-coordination.md for decomposition patterns.modules/context-waiting.md for deferred loading strategies.modules/cache-aligned-prefixes.md for ordering context so provider KV caches hit (stable prefix first, volatile last).If context usage remains high after optimization, check for large files that were read entirely rather than selectively. If MECW assessments fail, ensure that your environment provides accurate token count metadata. For permission errors when writing output logs to /tmp, verify that the project's temporary directory is writable.
modules/cache-aligned-prefixes.md (stable first, volatile last)