Use when suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. Triggers on \"strategic-compact\", \"strategic compact\", \"compact\".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Strategic Compact?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/majinmagros-strategic-compact-magros-ai-skills)
---
name: strategic-compact
description: "Use when suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. Triggers on \"strategic-compact\", \"strategic compact\", \"compact\"."
metadata:
origin: ECC
---
# 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:
1. **Context size (primary)** — Reads the latest `usage` record from the session transcript (`transcript_path` in the hook payload) and sums `input_tokens + cache_read_input_tokens + cache_creation_input_tokens` (the true context size of the turn). Suggests `/compact` at a window-scaled threshold — 160k tokens on a 200k window, 250k on a 1M window (detected from a `[1m]` model marker, or inferred when observed tokens already exceed 200k) — and re-reminds after every additional 60k tokens of context growth
2. **Tool-call count (secondary)** — Counts tool invocations in session; suggests at a configurable threshold (default: 50 calls), then every 25 calls after
Tool count alone is a weak proxy for window pressure: a few large file reads or MCP responses can fill the window in very few calls, while many tiny calls can cross 50 with a near-empty window. The context-size signal fires when it actually matters.
## Compactacao intencional (Batch 17d, #68)
Toda compactacao perde conteudo — a automatica perde no ponto
arbitrario (meio da task, some instrucao forte do inicio). Prefira
compactar voce no limite logico com um prompt dizendo o que e
relevante manter; nunca deixe o harness resumir sozinho o que ele
acha importante.
## Hook Setup
**Installed as a plugin?** No setup is needed. The plugin's `hooks/hooks.json` already registers `suggest-compact.js` (hook id `pre:edit-write:suggest-compact`, active in the `standard` and `strict` hook profiles). Do not copy the block below into `~/.claude/settings.json` — `~/.claude/scripts/` does not exist on plugin installs, and duplicating a plugin hook causes double execution.
**If installed manually** (`./install.sh`), add to your `~/.claude/settings.json`:
```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" }]
}
]
}
}
```
## Configuration
## handoff.md e cache de 1h (leva YouTube 2026-11-11)
Fonte `ZRKAw472Nmk` (Simon Scrapes). `/compact` perde decisao; `handoff.md` preserva:
objetivo, feito, proximo, arquivos tocados, decisoes e o que falhou - escreva antes do
`/clear` e abra a sessao nova lendo o arquivo. O cache da assinatura dura **1 hora**;
retomar chat de ontem re-le tudo pelo preco cheio (~**5x** tokens). Caso medido: skill mal
configurado levou o uso a **11%** do limite sem entrega. Audite com `/context`
(CLAUDE.md < 200 linhas, plugins esquecidos) e `/usage` (skills/subagentes/MCP > 10%).