strategic-compact

Suggests manual context compaction at logical workflow phase boundaries using a tool-call counter hook.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill strategic-compact-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/strategic-compact
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill strategic-compact-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Auto-compaction in long AI coding sessions triggers at arbitrary points, often mid-task, discarding important context like file paths and partial state. This Skill helps you compact context at logical phase transitions instead, preserving what matters across research, planning, implementation, and testing phases. ## Core Features & Use Cases - Tool-Call Threshold Detection: A PreToolUse hook script counts Edit/Write invocations per session and suggests running /compact once a configurable threshold (default 50 calls) is reached, with reminders every 25 calls afterward. - Compaction Decision Guide: A built-in table tells you when compacting is safe (research to planning, after debugging) and when it is costly (mid-implementation). - Context Survival Reference: Documents what persists across compaction (CLAUDE.md, TodoWrite lists, memory files, git state) versus what is lost, so you can save key context to files before compacting. - Use Case: During a long feature build, after finalizing your plan in a todo list, the hook reminds you at 50 tool calls to run /compact with a summary message, freeing context for implementation without losing the plan. ## Quick Start Install the suggest-compact hook in your Claude settings for Edit and Write tool events, then ask the AI to remind you when a strategic compaction point is reached during long sessions.

Frequently Asked Questions about strategic-compact

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

FAQPage Schema
How do I set up strategic context compaction reminders in Claude Code?▼

Add a PreToolUse hook in ~/.claude/settings.json matching Edit and Write tools that runs the suggest-compact script. The script counts tool calls per session and prints a suggestion to stderr when the threshold is reached.

When should I compact context during a long coding session?▼

Compact at logical phase boundaries: after research before planning, after finalizing a plan, after debugging, or after a failed approach. Avoid compacting mid-implementation, since losing variable names, file paths, and partial state is costly.

What survives context compaction in Claude Code?▼

CLAUDE.md instructions, TodoWrite task lists, memory files, git state, and files on disk persist across compaction. Intermediate reasoning, previously read file contents, conversation context, and tool call history are lost.

How do I change the tool call threshold for compaction suggestions?▼

Set the COMPACT_THRESHOLD environment variable to your desired number of tool calls. The default is 50 calls before the first suggestion, with periodic reminders every 25 calls afterward.

Why is manual compaction better than auto-compaction?▼

Auto-compaction triggers at arbitrary points with no awareness of task boundaries, often interrupting multi-step operations mid-task. Manual compaction at phase transitions lets you save important context to files first and keep only what the next phase needs.