Strategic Compact Skill
SkillDev tools上下文优化技能,通过 trigger-based 懒加载和 context composition awareness 自动重组长会话上下文。
Use Strategic Compact Skill in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Strategic Compact Skill and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Strategic Compact Skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by hashgraph-online/awesome-codex-plugins in plugins/Colin4k1024/tsp/skills/strategic-compact/SKILL.md and read by Ahel’s review.
上下文优化技能,通过 trigger-based 懒加载和 context composition awareness 自动重组长会话上下文。
何时激活
- Claude Code 触发原生自动或手动 compact
- 原生 auto-compact 被显式关闭,且会话上下文超过 65% 使用率
- 需要重组上下文以保留关键信息
- 长会话中需要压缩早期对话
- 需要按重要性重新组织 specialist 输出
核心功能
1. Trigger-Based 懒加载
Claude Code 默认由原生 auto-compact 决定压缩时机;下列百分比 trigger 只用于手动兜底模式:
| Trigger | 条件 | 行为 |
|---|---|---|
context_65% | 上下文使用 > 65% | 触发 advisory 压缩建议 |
context_70% | 上下文使用 > 70% | 触发压缩建议 |
context_85% | 上下文使用 > 85% | 强烈建议手动压缩 |
logical_break | 检测到逻辑断点 | 建议整理 |
specialist_done | specialist 完成 | 归档输出 |
2. Context Composition Awareness
理解上下文不同部分的价值:
高价值(总是保留):
- 决策和结论
- 任务输出和验证结果
- 待处理项和 hints
- 架构决策记录 (ADR)
中等价值(根据大小决定):
- 工具输出(超过阈值时压缩)
- 对话历史(保留首尾,压缩中间)
- 文件内容(保留路径和关键符号)
低价值(安全丢弃):
- 纯搜索结果
- 重复信息
- 工具调用追踪
压缩策略
Phase 1: 保存决策到内存
提取所有决策,保存到 ~/.claude/memory/error_experience/decisions/
Phase 2: 保存待办到摘要
提取 pending items 和 next hints,保存到 session summary
Phase 3: 压缩对话
保留系统提示和最近 20 轮对话,压缩中间部分
Phase 4: 精简工具输出
将长工具输出替换为摘要:[File X read, Y lines]
与 Other Skills 的关系
| Skill | 关系 |
|---|---|
| Memory Persistence | Strategic Compact 使用其存储来保存决策和摘要 |
| Error Experience Library | 从压缩的上下文中提取错误模式 |
| Continuous Learning | Instincts 从归档的上下文中生成 |
使用场景
场景 1:长会话自动整理
用户:连续工作 2 小时后
Claude Code:上下文接近原生 auto-compact 阈值
系统:触发 PreCompact(auto),保存 compact 轮次并清理旧计量缓存
Claude Code:自动执行压缩
系统:下一轮只读取压缩后的新 usage,不复用压缩前的高水位
场景 2:Specialist 输出归档
用户:运行 /code-review
Specialist:输出详细代码审查报告
系统:检测到 specialist_done trigger
系统:提取关键结论,丢弃详细追踪
系统:保存结论到 memory store
Context 计算与 Compact 轮次
- 运行时使用
scripts/lib/context-window.js统一计算上下文压力。 - Claude
context_window.used_percentage/remaining_percentage是官方预计算值,直接使用,不再重复扣除 auto-compact buffer;context_window_size用于区分 200K 与 1M 窗口。 - 优先消费 CCometixLine-compatible remaining context,例如
ccometixline.context_window.remaining_percentage、ccometixline_context_window.remaining_tokens、TSP_CONTEXT_WINDOW_JSON或CCOMETIXLINE_CONTEXT_FILE。 - 如果没有外部 remaining 信号,则退回 Claude
context_window、transcript JSONL usage、bridge file 和 transcript size fallback。 scripts/hooks/pre-compact.js同时匹配auto|manual,每次 PreCompact 会递增.tsp/context/compact-state.json的 session / total compact count,并清除压缩前的 bridge / debounce 状态。- transcript 遇到 compact summary 后不会回读 summary 前的 usage;等待下一次 API 响应提供新窗口指标。
suggest-compact.js默认auto模式,不注入人工/compact提示;仅在DISABLE_AUTO_COMPACT=1或STRATEGIC_COMPACT_MODE=manual时启用下表的手动兜底。
手动兜底阈值
| 使用率 | 紧迫度 | 建议操作 |
|---|---|---|
| < 65% | low | 无需操作 |
| 65-70% | advisory | 提醒控制上下文增长 |
| 70-85% | medium | 建议压缩,可选择性执行 |
| 85-95% | high | 强烈建议压缩 |
| > 95% | critical | 必须立即压缩 |
命令接入
/compact- 手动触发压缩/compact status- 显示当前上下文使用率/compact plan- 显示压缩计划而不执行
Signals
- GitHub stars
- 1k
- Forks
- 316
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
strategic-compact-hashgraph-online- Source
- github.com/hashgraph-online/awesome-codex-plugins
github.com/hashgraph-online/awesome-codex-plugins