agentleFS
myths-labsmyths-labs/muse/skills/core/strategic-compact/SKILL.md

strategic-compact

Skill35 starsChanged 8 months agoMITView on GitHub

Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. Supports focus-aware compaction for targeted context preservation.

40 other projects use a version of this, 30 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use kotlin-testing, ralphinho-rfc-pipeline and 10 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

We split this skill into the rules it gives an agent

3 rules. 1 is common, 0 are distinctive, and 2 are very specific to this project.

  • 1

    Common

    Most of the 36 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Common:

    No awareness of logical task boundaries

    line 14
  2. Very specific:

    Add to your ~/.claude/settings.json:

    line 58
  3. Very specific:

    Persist: Write current task progress to memory/YYYY-MM-DD.md

    line 89

“Common” is measured: kept by at least 6 in 10 of the 36 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Strategic Compact Skill

Suggests manual /compact at strategic points rather than relying on arbitrary auto-compaction.

Why Strategic Compaction?

Auto-compaction triggers at arbitrary points:

  • Often mid-task, losing important context
  • No awareness of logical task boundaries
  • Can interrupt complex multi-step operations

Strategic compaction at logical boundaries:

  • After exploration, before execution — Compact research, keep plan
  • After completing a milestone — Fresh start for next phase
  • Before major context shifts — Clear old context before different task

Focus-Aware Compaction (inspired by OpenClaw)

Blind compaction = blind discards. Focus-directed compaction = preserving key information.

Usage: Specify what to preserve when manually compacting.

Scenario: Completed 3 hours of debugging, now starting a new feature
✅ /compact preserve root cause analysis and fix approach, discard trial-and-error debugging
❌ /compact (blind compaction may discard root cause analysis)

Common focus templates:

ScenarioFocus Directive
After debuggingPreserve root cause and fix approach, discard trial-and-error
After planningPreserve final plan and key decisions, discard alternative discussions
After code reviewPreserve items to change, discard confirmed-OK sections
After strategy discussionPreserve strategic decisions and metrics, discard brainstorming process
After multi-file editsPreserve which files changed and why, discard file content details

When to Trigger Compaction

SignalAction
Completed a full milestone✅ Good time to compact
Switching from exploration to execution✅ Good time to compact
Debugging complete, starting new feature✅ Good time to compact
In the middle of multi-step implementation❌ Do NOT compact
Still analyzing a problem❌ Do NOT compact
/ctx shows 60-70% consumed🟡 Consider compacting
/ctx observes ≥80% pressureSave the current Lane, compact if supported, verify and continue

Hook Setup

Add to your ~/.claude/settings.json:

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

Configuration

Environment variables:

  • COMPACT_THRESHOLD - Tool calls before first suggestion (default: 50)

Best Practices

  1. Compact with focus — Always specify what to preserve, never compact blindly
  2. Write memory before compacting — Save key information to memory/YYYY-MM-DD.md first
  3. Never compact mid-task — Maintain complete context during multi-step implementations
  4. Pair with /ctx — Use actual observations; ≥80% means save and reassess after compaction, not forced exit. Unknown occupancy remains unknown.

Pre-Compaction Protocol (MUSE — derived from LCM compact:before)

MUST execute in order before compaction:

  1. Persist: Write current task progress to memory/YYYY-MM-DD.md
  2. Preserve recent instructions: Save recent decisions, corrections and constraints; do not claim the client supports a protected/non-compactable zone unless its actual interface does.
  3. Extract key decisions: Scan content about to be compacted, extract key decisions/data to memory
  4. Notify user: Inform about upcoming compaction, list what will be preserved

Principle: Persist first, then compact. Never discard information without a backup.

Post-Compaction Injection (MUSE — derived from OpenClaw postCompactionSections)

MUST re-internalize the following after compaction:

  1. First 4 lines of CLAUDE.md (7 iron laws + priority chain)
  2. Currently [/] in-progress tasks from task.md
  3. Today's memory/ snapshot (just written)
  4. Any focus-aware specified preservation items

Compaction may omit information. Reconcile the selected role/Lane checkpoint and required evidence after it; do not reload all history or claim memory is lossless.

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.