strategic-compact

Suggests manual context compaction at logical task boundaries using token and tool-call thresholds.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/diazMelgarejo/orama-system --skill strategic-compact-diazmelgarejo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/diazMelgarejo/orama-system/tree/main/.cursor/.agents/skills/strategic-compact
Command: npx skills add https://github.com/diazMelgarejo/orama-system --skill strategic-compact-diazmelgarejo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Auto-compaction in long AI coding sessions triggers at arbitrary points, often mid-task, losing important context like file paths, variable names, and partial reasoning. This Skill helps you compact at logical phase boundaries instead, preserving the context that matters. ## Core Features & Use Cases - Context-size monitoring: Reads token usage from the session transcript and suggests /compact at window-scaled thresholds (160k on a 200k window, 250k on a 1M window), re-reminding every 60k tokens of growth. - Tool-call counting: Tracks tool invocations per session and suggests compaction at a configurable threshold (default 50 calls, then every 25). - Compaction decision guidance: Provides a phase-transition table (research → planning → implementation → testing) and a list of what survives compaction (CLAUDE.md, TodoWrite, memory files, git state) versus what is lost. - Use Case: During a long multi-phase feature build, the PreToolUse hook fires before an Edit and reminds you to run /compact after finalizing your plan, so implementation starts with a fresh context window. ## Quick Start Add the suggest-compact.js hook to your Claude settings for Edit and Write tool calls, then follow its suggestions to run /compact at logical phase boundaries.

Frequently Asked Questions about strategic-compact

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compact context in Claude Code at the right time?

Run /compact manually at logical phase boundaries, such as after research before planning, or after finalizing a plan before implementation. The strategic-compact hook suggests timing based on token usage and tool-call counts, but you decide when to compact.

How do I set up the strategic compaction hook in Claude settings?

Add a PreToolUse hook in ~/.claude/settings.json matching Edit and Write tools, pointing to the suggest-compact.js script. The hook then evaluates context size and tool-call counts before each edit and prints a suggestion when thresholds are reached.

What survives a /compact in Claude Code?

CLAUDE.md instructions, the TodoWrite task list, memory files under ~/.claude/memory/, git state, and files on disk all persist. Intermediate reasoning, previously read file contents, conversation context, and tool-call history are lost.

Can I configure the context compaction thresholds?

Yes, via environment variables: COMPACT_THRESHOLD sets tool calls before the first suggestion (default 50), COMPACT_CONTEXT_THRESHOLD sets the token trigger (default 160000 on a 200k window), and COMPACT_CONTEXT_INTERVAL controls repeat reminders (default 60000).

When should I avoid compacting context mid-task?

Avoid compacting mid-implementation, because losing variable names, file paths, and partial state is costly. Compact after completing milestones, after debugging sessions, or after a failed approach before trying a new one.