agentleFS
codelablycodelably/harmony-claude-code/skills/strategic-compact/SKILL.md

strategic-compact

Skill43 starsChanged 10 months agoMITView on GitHub

建议在逻辑间隔进行手动上下文压缩(Context Compaction),以便在任务阶段中保留上下文,而不是依赖随机的自动压缩。

40 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use kotlin-testing, ralphinho-rfc-pipeline and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tpavanipradeepSkill

    kotlin-testing

    Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.

    Also in 6 projects that use this

  • InfopibeSkill

    ralphinho-rfc-pipeline

    RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.

    Also in 10 projects that use this

  • mryeastcodeSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 5 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 12 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 11 projects that use this

  • mryeastcodeSkill

    santa-method

    Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.

    Also in 6 projects that use this

  • +3 more from Infopibe

The file

Files
SKILL.md

策略性压缩技能 (Strategic Compact Skill)

建议在工作流(Workflow)的关键点手动执行 /compact,而不是依赖随机触发的自动压缩。

为什么需要策略性压缩?

自动压缩会在随机时间点触发:

  • 经常在任务进行中触发,导致丢失重要的上下文
  • 无法识别逻辑上的任务边界
  • 可能会中断复杂的多步操作

在逻辑边界处进行策略性压缩:

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

工作原理

suggest-compact.sh 脚本在工具调用前(PreToolUse,针对 Edit/Write 工具)运行,并且:

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

钩子 (Hook) 配置

添加至您的 ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "tool == \"Edit\" || tool == \"Write\"",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
      }]
    }]
  }
}

配置

环境变量:

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

最佳实践

  1. 在规划后压缩 —— 一旦计划最终确定,进行压缩以全新状态开始执行
  2. 在调试后压缩 —— 在继续开发前清理错误修复相关的上下文
  3. 不要在实现过程中压缩 —— 为相关变更保留上下文
  4. 关注建议 —— 钩子(Hook)告诉您“何时”可以压缩,而“是否”压缩由您决定

相关资源

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.