一键导入
strategic-compact
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
A comprehensive verification system for Claude Code sessions.
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment/sensitive features. Provides comprehensive security checklist and patterns.
Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.
| name | strategic-compact |
| description | Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. |
Suggests manual /compact at strategic points in your workflow rather than relying on arbitrary auto-compaction.
Auto-compaction triggers at arbitrary points:
Strategic compaction at logical boundaries:
The suggest-compact.sh script runs on PreToolUse (Edit/Write) and:
First, make the script executable:
chmod +x $HOME/.claude/skills/strategic-compact/suggest-compact.sh
Then add the following to the hooks section in ~/.claude/settings.json (merge with existing hooks, do not replace):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [{ "type": "command", "command": "bash \"$HOME/.claude/skills/strategic-compact/suggest-compact.sh\"" }]
},
{
"matcher": "Write",
"hooks": [{ "type": "command", "command": "bash \"$HOME/.claude/skills/strategic-compact/suggest-compact.sh\"" }]
}
]
}
}
Environment variables:
COMPACT_THRESHOLD — Edit/Write calls before first suggestion (default: 50)Use this table to decide when to compact:
| Phase Transition | Compact? | Why |
|---|---|---|
| Research → Planning | Yes | Research context is bulky; plan is the distilled output |
| Planning → Implementation | Yes | Plan is in TodoWrite or a file; free up context for code |
| Implementation → Testing | Maybe | Keep if tests reference recent code; compact if switching focus |
| Debugging → Next feature | Yes | Debug traces pollute context for unrelated work |
| Mid-implementation | No | Losing variable names, file paths, and partial state is costly |
| After a failed approach | Yes | Clear the dead-end reasoning before trying a new approach |
Understanding what persists helps you compact with confidence:
| Persists | Lost |
|---|---|
| CLAUDE.md instructions | Intermediate reasoning and analysis |
| TodoWrite task list | File contents you previously read |
Memory files (.claude/projects/<project>/memory/) | Multi-step conversation context |
| Git state (commits, branches) | Tool call history and counts |
| Files on disk | Nuanced user preferences stated verbally |
/save-session to persist current context to a file before compacting; resume later with /resume-session/compact with a summary — Add a custom message: /compact Focus on implementing auth middleware nextMonitor what's consuming your context window:
Common sources of duplicate context:
~/.claude/rules/ and project .claude/rules/save-session / resume-session skills — Save and restore session state across compactions