
strategic-compact
当用户需要在长会话的逻辑边界手动压缩上下文、做 context engineering、目标复述、上下文审计、外部 scratchpad、handoff 或 compaction policy 时使用。
- Installs
- 54
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/majiayu000/spellbook --skill strategic-compact- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads strategic-compact automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Strategic Compact
概述
在长会话中,上下文窗口有限且会腐烂。此 skill 指导何时压缩、保留什么、丢弃什么,以及如何把 durable state 外部化。
核心原则:在逻辑边界压缩,不在任意时刻压缩。
Lightweight Context Engineering Guard
在重大阶段开始、handoff、压缩前,用一段短文本执行:
objective:
plan_5_steps_or_less:
context_audit:
- keep:
- externalize:
- discard:
- stale_or_conflicting:
next_boundary:
计划最多 5 步。若无法用 5 步表达,先收敛当前 tranche,不要扩大范围。
压缩决策表
| 当前阶段 | 下一阶段 | 是否压缩 | 理由 |
|---|---|---|---|
| 研究/探索 | 规划 | 是 | 探索细节不需要带入规划 |
| 规划 | 实现 | 是 | 保留计划,丢弃规划过程 |
| 实现步骤 N | 实现步骤 N+1 | 否 | 实现中途压缩会丢失上下文 |
| 实现完成 | 验证 | 可选 | 如果上下文接近上限 |
| 验证 | 提交 | 否 | 验证结果需要带入提交 |
| 任务 A 完成 | 任务 B 开始 | 是 | 不同任务间压缩 |
Context Audit
压缩前必须分类:
- keep: 目标、约束、当前分支、修改文件、关键决策、最新验证结果、下一步
- externalize: 原始日志、大 diff、宽泛搜索结果、CI 全量输出、长 JSON
- discard: 已解决错误的完整堆栈、探索过程、失败假设的重复细节
- stale_or_conflicting: 旧计划、旧 head SHA、过期 CI、与当前文件冲突的记忆
外部化优先使用 repo artifact、checkpoint、issue/PR 描述、run log 或用户指定 scratchpad。不要把 raw session logs 当成当前事实来源。
压缩后保留清单
必须保留:
- 当前任务目标和约束
- 不超过 5 步的当前计划
- 已做的架构决策及理由
- 已修改的文件列表
- 未完成的步骤
- 发现的问题和 TODO
- VibeGuard 约束(始终保留)
- fresh verification evidence
- review gate decision when landing is next
可以丢弃:
- 文件内容的完整引用(保留路径即可)
- 搜索过程中的中间结果
- 已解决的错误的完整堆栈
- 探索性的代码阅读记录
使用方式
当感觉上下文即将耗尽时:
- 判断当前处于哪个阶段
- 查压缩决策表,确认是否适合压缩
- 执行 context audit,决定 keep / externalize / discard / stale_or_conflicting
- 如果适合,按保留清单整理摘要
- 执行压缩
反模式
- 在实现中途压缩 → 丢失关键上下文,导致重复工作
- 压缩时丢弃约束 → 后续步骤违反规则
- 不压缩直到溢出 → 被动截断比主动压缩更危险
- 把旧总结当远端真相 → 需要重新 fetch、检查文件或查询 API
FAQ
What does the strategic-compact skill do?
当用户需要在长会话的逻辑边界手动压缩上下文、做 context engineering、目标复述、上下文审计、外部 scratchpad、handoff 或 compaction policy 时使用。
How do I install strategic-compact?
Run npx skills add https://github.com/majiayu000/spellbook --skill strategic-compact in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/strategic-compact/ (personal) or .claude/skills/strategic-compact/ (project).
Which AI agents can use strategic-compact?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is strategic-compact safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains strategic-compact?
It is published by majiayu000 in majiayu000/spellbook. It has 54 recorded installs.
More from majiayu000/spellbook
github-trending
majiayu000/spellbook
GitHub Trending 探索与分析。用于发现热门开源项目、技术趋势、开发者偏好,帮助理解技术社区的兴趣走向。使用场景包括“看看今天 GitHub 什么火了”、“Rust 最近热门项目”、“AI 领域趋势日报”、“这个方向有没有值得关注的开源项目”、“帮我做个 GitHub trending 分析”。
app-ui-design
majiayu000/spellbook
Mobile app UI design expert for iOS and Android. Use when designing app interfaces, creating design systems, ensuring accessibility, or following platform guidelines. Covers Material Design 3, Human Interface Guidelines, color theory, typography, and 2025 trends.
harmonyos-app
majiayu000/spellbook
HarmonyOS application development expert. Use when building HarmonyOS apps with ArkTS, ArkUI, Stage model, and distributed capabilities. Covers HarmonyOS NEXT (API 12+) best practices.
technical-spec
majiayu000/spellbook
Open the skill to read its SKILL.md instructions.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.