affaan-m avatar

Strategic Compact

This hooks into Claude Code's PreToolUse events and watches two signals: total context tokens and tool call counts. When you hit 160k tokens (or 250k on a 1M window) or 50 tool calls, it suggests running /compact manually instead of letting auto-compaction fire mid-task. The idea is sound: compact after you finish planning but before implementation, or after debugging is done, not when you're 30 tool calls deep into a refactor. It reads the session transcript to calculate real context size, which is smarter than just counting tool invocations. The guide on what survives compaction (TodoWrite, memory files, git state) versus what doesn't (conversation context, file contents you read earlier) is the most useful part here.

skills.sh installs
6K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill strategic-compact --agent claude-code

Installs into .claude/skills of the current project.

Files

Strategic Compact Skill

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

When to Activate

  • Running long sessions that approach context limits (200K+ tokens)
  • Working on multi-phase tasks (research → plan → implement → test)
  • Switching between unrelated tasks within the same session
  • After completing a major milestone and starting new work
  • When responses slow down or become less coherent (context pressure)

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 context, keep implementation plan
  • After completing a milestone — Fresh start for next phase
  • Before major context shifts — Clear exploration context before different task

How It Works

The suggest-compact.js script runs on PreToolUse (Edit/Write) and combines two signals:

Sponsors

Details

Repository
github.com/affaan-m/ecc
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263

Recommended

1juliusbrussee avatarcavemanjuliusbrussee/cavemanUltra-compressed communication mode. Cuts output tokens 65% (measured) by speaking like caveman while keeping full technical accuracy. Supports intensity levels618.3Kskills.sh installs
2mattpocock avatargrill-memattpocock/skillsA relentless interview to sharpen a plan or design.1.5Mskills.sh installs
3shadcn avatarimproveshadcn/improveSurvey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on s40Kskills.sh installs
4obra avatarsystematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes326.7Kskills.sh installs
5forrestchang avatarkarpathy-guidelinesforrestchang/andrej-karpathy-skillsBehavioral guidelines to reduce common LLM coding mistakes through explicit assumptions, simplicity, and verifiable success criteria.17.9Kskills.sh installs
6vercel-labs avatarfind-skillsvercel-labs/skillsHelps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express int4.3Mskills.sh installs