Back to skills
SKILL.md
Strategic Compact Hashgraph Online
ASecurity> 上下文优化技能,通过 trigger-based 懒加载和 context composition awareness 自动重组长会话上下文。
- 3 stars
- 0 votes
- 0 copies
- 2 views
- Added September 12, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add thedixitjain/the-mega-skill-library --skill strategic-compact--hashgraph-online --agent claude-codeAre you the author of Strategic Compact Hashgraph Online?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/thedixitjain-strategic-compact-hashgraph-online)---
name: strategic-compact
description: "> 上下文优化技能,通过 trigger-based 懒加载和 context composition awareness 自动重组长会话上下文。"
category: general-purpose
source_repo: hashgraph-online/awesome-codex-plugins
source_path: "plugins/Colin4k1024/tsp/skills/strategic-compact/SKILL.md"
source_url: https://github.com/hashgraph-online/awesome-codex-plugins/blob/HEAD/plugins/Colin4k1024/tsp/skills/strategic-compact/SKILL.md
---
# Strategic Compact Skill
上下文优化技能,通过 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` - 显示压缩计划而不执行
---
**Source:** [`hashgraph-online/awesome-codex-plugins`](https://github.com/hashgraph-online/awesome-codex-plugins) → `plugins/Colin4k1024/tsp/skills/strategic-compact/SKILL.md`
Files in this skill
- SKILL.md
- agents/openai.yaml
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.