affaan-m/ECC

strategic-compact

建议在逻辑间隔处手动压缩上下文,以在任务阶段中保留上下文,而非任意的自动压缩。

71Collecting
See how to use itView GitHub source
npx skills add https://github.com/affaan-m/ECC --skill "docs/zh-CN/skills/strategic-compact"
Automated source guide

Source checked Jul 28, 2026·Refresh due Oct 26, 2026

Reorganized from the pinned upstream SKILL.md

Turn strategic-compact's source instructions into a guide you can follow

According to the pinned SKILL.md from affaan-m/ECC: 建议在你的工作流程中的战略节点手动执行 /compact,而不是依赖任意的自动精简。

npx skills add https://github.com/affaan-m/ECC --skill "docs/zh-CN/skills/strategic-compact"
Check the pinned source

Best fit

  • 建议在逻辑间隔处手动压缩上下文,以在任务阶段中保留上下文,而非任意的自动压缩。

Bring this context

  • A concrete task that matches the documented purpose of strategic-compact.
  • The files, examples, or context the task depends on.
  • Your constraints, target environment, and definition of done.

Expected outputs

  • A result that follows the pinned strategic-compact instructions.
  • A concise record of assumptions, inputs used, and unresolved questions.
  • A final check against the source workflow and relevant permission signals.

Key source sections

Read strategic-compact through these 5 source sections

Sections are extracted automatically from the pinned SKILL.md and link back to the source.

01

何时激活

运行长时间会话,接近上下文限制时(200K+ tokens) 处理多阶段任务时(研究 → 规划 → 实施 → 测试) 在同一会话中切换不相关的任务时 完成一个主要里程碑并开始新工作时 当响应变慢或连贯性下降时(上下文压力)

SKILL.md · 何时激活
运行长时间会话,接近上下文限制时(200K+ tokens)处理多阶段任务时(研究 → 规划 → 实施 → 测试)在同一会话中切换不相关的任务时
02

为何采用战略精简?

通常在任务中途,丢失重要上下文 无法感知逻辑任务边界 可能中断复杂的多步骤操作

SKILL.md · 为何采用战略精简?
通常在任务中途,丢失重要上下文无法感知逻辑任务边界可能中断复杂的多步骤操作
03

工作原理

suggest-compact.js 脚本在 PreToolUse (Edit/Write) 时运行,并且:

SKILL.md · 工作原理
跟踪工具调用 — 统计会话中的工具调用次数阈值检测 — 在可配置的阈值处建议压缩(默认:50次调用)定期提醒 — 达到阈值后,每25次调用提醒一次
04

钩子设置

作为插件安装? 无需任何设置。插件的 hooks/hooks.json 已经注册了 suggest-compact.js(钩子 ID pre:edit-write:suggest-compact,在 standard 和 strict 钩子配置档中生效)。不要把下面的代码块复制到 /.claude/settings.json — 插件安装中不存在 /.claude/scripts/,并且重复注册插件钩子会导致双重执行。

SKILL.md · 钩子设置
作为插件安装? 无需任何设置。插件的 hooks/hooks.json 已经注册了 suggest-compact.js(钩子 ID pre:edit-write:suggest-compact,在 standard 和 strict 钩子配置档中生效)。不要把下面的代码块复制到 /.claude/settings.json — 插件安装中不存在 /.claude/scripts/,并且重复注册插件钩子会导致双重执行。如果是手动安装(./install.sh),添加到你的 /.claude/settings.json:
05

配置

COMPACTTHRESHOLD — 首次建议前的工具调用次数(默认:50)

SKILL.md · 配置
COMPACTTHRESHOLD — 首次建议前的工具调用次数(默认:50)

SkillSignal prompt templates

Provide the task, context, and acceptance criteria

These prompts were written by SkillSignal from the source structure; they are not upstream text.

Task-start prompt

Confirm source fit, inputs, and outputs before acting.

Use strategic-compact to help me with: [specific task]. Context: [files, data, or background]. Constraints: [environment, scope, and prohibited actions]. Before acting, check the pinned SKILL.md and explain which sections apply, what inputs are still missing, and what you will deliver.

Source-guided execution

Make the Agent explicitly follow the key extracted sections.

Apply the pinned strategic-compact source to [task]. Pay particular attention to these source sections: “何时激活”, “为何采用战略精简?”, “工作原理”, “钩子设置”, “配置”. Preserve the important decision at each step. Mark facts not covered by the source as “needs confirmation” instead of inventing them. Then verify the result against my acceptance criteria: [criteria].

Result-review prompt

Check omissions, permissions, and source drift before delivery.

Review the current strategic-compact result: (1) does it satisfy the original task; (2) were any applicable steps or limits in the pinned SKILL.md missed; (3) did it perform any unauthorized file, command, network, or data action; and (4) which conclusions remain unverified? List issues first, then fix only what the source or user authorization supports.

Output checklist

Verify each item before delivery

The task matches the purpose documented in the SKILL.md.

The source section “何时激活” has been checked.

The source section “为何采用战略精简?” has been checked.

The source section “工作原理” has been checked.

The source section “钩子设置” has been checked.

Inputs, constraints, and acceptance criteria are explicit.

Unverified facts, compatibility, and outcome claims are clearly marked.

Any file, command, network, or data action has been reviewed.

Choose a different workflow

When another Skill is the better fit

FAQ

What does strategic-compact do?

建议在你的工作流程中的战略节点手动执行 /compact,而不是依赖任意的自动精简。

How do I start using strategic-compact?

The catalog detected this source-specific install command: npx skills add https://github.com/affaan-m/ECC --skill "docs/zh-CN/skills/strategic-compact". Inspect the command and pinned source before running it.

Which Agent platforms does it declare?

No dedicated Agent platform is declared in the pinned source record.

Repository stars
234,327
Repository forks
35,711
Quality
71/100
Source repository last pushed

Quality breakdown

Based on traceable docs and repository signals; stars are not treated as quality.

71/100
Documentation20/30
Specificity11/25
Maintenance20/20
Trust signals20/25
View original Skill.mdThis page is parsed directly from the repository SKILL.md without editorial rewriting. Collected: Jul 28, 2026 · about 2 min

战略精简技能

建议在你的工作流程中的战略节点手动执行 /compact,而不是依赖任意的自动精简。

何时激活

  • 运行长时间会话,接近上下文限制时(200K+ tokens)
  • 处理多阶段任务时(研究 → 规划 → 实施 → 测试)
  • 在同一会话中切换不相关的任务时
  • 完成一个主要里程碑并开始新工作时
  • 当响应变慢或连贯性下降时(上下文压力)

为何采用战略精简?

自动精简会在任意时间点触发:

  • 通常在任务中途,丢失重要上下文
  • 无法感知逻辑任务边界
  • 可能中断复杂的多步骤操作

在逻辑边界进行战略精简:

  • 探索之后,执行之前 — 压缩研究上下文,保留实施计划
  • 完成里程碑之后 — 为下一阶段重新开始
  • 在主要上下文切换之前 — 在开始不同任务前清理探索上下文

工作原理

suggest-compact.js 脚本在 PreToolUse (Edit/Write) 时运行,并且:

  1. 跟踪工具调用 — 统计会话中的工具调用次数
  2. 阈值检测 — 在可配置的阈值处建议压缩(默认:50次调用)
  3. 定期提醒 — 达到阈值后,每25次调用提醒一次

钩子设置

作为插件安装? 无需任何设置。插件的 hooks/hooks.json 已经注册了 suggest-compact.js(钩子 ID pre:edit-write:suggest-compact,在 standardstrict 钩子配置档中生效)。不要把下面的代码块复制到 ~/.claude/settings.json — 插件安装中不存在 ~/.claude/scripts/,并且重复注册插件钩子会导致双重执行。

如果是手动安装./install.sh),添加到你的 ~/.claude/settings.json

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit",
        "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
      },
      {
        "matcher": "Write",
        "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
      }
    ]
  }
}

配置

环境变量:

  • COMPACT_THRESHOLD — 首次建议前的工具调用次数(默认:50)

压缩决策指南

使用此表来决定何时压缩:

阶段转换压缩?原因
研究 → 规划研究上下文很庞大;规划是提炼后的输出
规划 → 实施规划已保存在 TodoWrite 或文件中;释放上下文以进行编码
实施 → 测试可能如果测试引用最近的代码则保留;如果要切换焦点则压缩
调试 → 下一项功能调试痕迹会污染不相关工作的上下文
实施过程中丢失变量名、文件路径和部分状态代价高昂
尝试失败的方法之后在尝试新方法之前,清理掉无效的推理过程

压缩后保留的内容

了解哪些内容会保留有助于您自信地进行压缩:

保留的内容丢失的内容
CLAUDE.md 指令中间的推理和分析
TodoWrite 任务列表您之前读取过的文件内容
记忆文件 (~/.claude/memory/)多轮对话的上下文
Git 状态(提交、分支)工具调用历史和计数
磁盘上的文件口头陈述的细微用户偏好

最佳实践

  1. 规划后压缩 — 一旦计划在 TodoWrite 中最终确定,就压缩以重新开始
  2. 调试后压缩 — 在继续之前,清理错误解决上下文
  3. 不要在实施过程中压缩 — 为相关更改保留上下文
  4. 阅读建议 — 钩子告诉您何时,您决定是否
  5. 压缩前写入 — 在压缩前将重要上下文保存到文件或记忆中
  6. 使用带摘要的 /compact — 添加自定义消息:/compact Focus on implementing auth middleware next

令牌优化模式

触发表惰性加载

不在会话开始时加载完整的技能内容,而是使用一个将关键词映射到技能路径的触发表。技能仅在触发时加载,可将基线上下文减少 50% 以上:

触发词技能加载时机
"test", "tdd", "coverage"tdd-workflow用户提及测试时
"security", "auth", "xss"security-review涉及安全相关工作时
"deploy", "ci/cd"deployment-patterns涉及部署上下文时

上下文组合感知

监控哪些内容正在消耗你的上下文窗口:

  • CLAUDE.md 文件 — 始终加载,需保持精简
  • 已加载技能 — 每个技能增加 1-5K 令牌
  • 对话历史 — 随每次交流增长
  • 工具结果 — 文件读取、搜索结果会增加体积

重复指令检测

常见的重复上下文来源:

  • 相同的规则同时出现在 ~/.claude/rules/ 和项目 .claude/rules/
  • 技能重复了 CLAUDE.md 的指令
  • 多个技能覆盖了重叠的领域

上下文优化工具

  • token-optimizer MCP — 通过内容去重实现 95% 以上的自动令牌减少
  • context-mode — 上下文虚拟化(已演示从 315KB 减少到 5.4KB)

相关

  • 长篇指南 — Token 优化部分
  • 记忆持久化钩子 — 用于在压缩后保留状态
  • continuous-learning 技能 — 在会话结束前提取模式
Source repo
affaan-m/ECC
Skill path
docs/zh-CN/skills/strategic-compact/SKILL.md
Commit SHA
4e973d3eaf92
Repository license
MIT
Data collected