技能 cc-skill-strategic-compact
📦

cc-skill-strategic-compact

安全 📁 文件系统访问

Suggest Strategic Context Compaction Points

Long Claude Code sessions accumulate context that degrades performance over time. This skill identifies optimal moments to compact context without disrupting workflow momentum.

支持: Claude Codex Code(CC)
📊 71 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“cc-skill-strategic-compact”。 Tool call threshold reached (50 calls)

预期结果:

[StrategicCompact] 50 tool calls reached - consider /compact if transitioning phases

正在使用“cc-skill-strategic-compact”。 Periodic checkpoint at 75 tool calls

预期结果:

[StrategicCompact] 75 tool calls - good checkpoint for /compact if context is stale

正在使用“cc-skill-strategic-compact”。 User runs /compact after seeing suggestion

预期结果:

Conversation summary created with key decisions and code changes preserved. Context reduced from 50 messages to 12 summary points.

安全审计

安全
v1 • 2/25/2026

All static analysis findings are false positives. The skill is a benign shell script that tracks tool call counts in a temp file and outputs suggestions to stderr. No network access, no credential handling, no command injection vectors. The temp file usage is for local state tracking only.

2
已扫描文件
69
分析行数
2
发现项
1
审计总数
低风险问题 (1)
Temp directory file creation
Script creates a counter file in /tmp directory for tracking tool call counts across hook invocations

风险因素

📁 文件系统访问 (1)
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
31
社区
100
安全
91
规范符合性

你能构建什么

Extended Development Sessions

Developers working on complex multi-file refactoring tasks receive timely reminders to compact context after completing exploration phases before moving to implementation

Research to Implementation Transitions

Data scientists and analysts get checkpoint notifications when transitioning from data exploration to code generation, ensuring relevant context is preserved

Multi-Task Workflow Management

Project managers juggling multiple concurrent tasks receive periodic suggestions to compact completed work before starting new milestones

试试这些提示

Basic Compaction Request
Review our conversation and create a concise summary of key decisions, code changes, and open questions. Preserve only what's needed to continue the current task.
Phase Transition Summary
We are transitioning from exploration to implementation. Summarize the requirements and constraints discovered, then reset context for the implementation phase.
Milestone Completion Archive
Complete the current milestone and create an archival summary. Document what was accomplished, files modified, and any follow-up actions. Then compact to prepare for the next milestone.
Context Hygiene Check
Analyze our current conversation context. Identify redundant exchanges, resolved questions, and outdated information that can be safely removed while maintaining task continuity.

最佳实践

  • Compact context after completing logical workflow phases, not during active problem-solving
  • Review compaction suggestions and manually verify important context is preserved before compacting
  • Set COMPACT_THRESHOLD environment variable to match your typical session complexity and attention span

避免

  • Do not compact context in the middle of debugging sessions where full history is essential
  • Avoid setting thresholds too low (under 25) which causes premature compaction suggestions
  • Do not rely solely on automated suggestions - use judgment about task criticality before compacting

常见问题

How does this skill track tool call counts?
It maintains a simple counter file in the /tmp directory. Each hook invocation increments the counter, allowing the script to track cumulative tool usage across the session.
Does this skill automatically compact my context?
No, it only provides suggestions by writing to stderr. You must manually trigger compaction using the /compact command or by summarizing context yourself when you receive a suggestion.
Can I customize when suggestions appear?
Yes, set the COMPACT_THRESHOLD environment variable to your preferred tool call count (default is 50). After the threshold, suggestions appear every 25 tool calls.
What happens if I delete the temp counter file?
The script will create a new file and start counting from 1. You will receive suggestions based on the new count, effectively resetting the tracking for your current session.
Is this skill safe to use with sensitive projects?
Yes. The script has no network access, does not read project files, and only tracks an integer count. The temp file contains only a number with no project-specific data.
Do I need to configure hooks manually?
Yes. Add the hook configuration shown in the script comments to your ~/.claude/settings.json file to enable automatic suggestions before Edit or Write tool invocations.