strategic-compact

Prompt manual context compaction before Edit or Write tool use.

1.8k|303|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/xu-xiang/everything-claude-code-zh --skill strategic-compact-xu-xiang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/xu-xiang/everything-claude-code-zh/tree/main/docs/zh-TW/skills/strategic-compact
Command: npx skills add https://github.com/xu-xiang/everything-claude-code-zh --skill strategic-compact-xu-xiang

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

It prevents context loss in complex AI-assisted workflows by prompting manual context compaction at strategic milestones.

Core Features & Use Cases

  • Pre-tool-use prompts: Suggests manual compression before tool execution to preserve essential context.
  • Milestone-driven workflow: Applies across exploration, planning, execution, and transition phases where context risks accumulate.
  • Configurable thresholds: Allows tuning with COMPACT_THRESHOLD to control prompting frequency.

Quick Start

  • Add the skill to your Claude Code setup and ensure the script path exists at ~/.claude/skills/strategic-compact/suggest-compact.sh.
  • In your ~/.claude/settings.json, configure a PreToolUse hook to call the suggested script when using Edit or Write tools.
  • Set COMPACT_THRESHOLD to adjust prompt frequency (default 50). For example, set COMPACT_THRESHOLD=50.

Frequently Asked Questions about strategic-compact

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

FAQPage Schema
How do I prevent context loss in multi-step AI workflows?

Manual context compaction at strategic workflow milestones prevents context loss by prompting compression before tool execution. It uses a PreToolUse hook to suggest compaction when Edit or Write tools are invoked, preserving essential context across multi-step AI workflows.

How do I configure a PreToolUse hook for manual context compaction?

You configure manual context compaction by adding a PreToolUse hook in your ~/.claude/settings.json to call the suggest-compact.sh script when using Edit or Write tools. Ensure the script exists at ~/.claude/skills/strategic-compact/suggest-compact.sh.

Can I control the frequency of manual context compression prompts?

Yes, you can control the prompting frequency by setting the COMPACT_THRESHOLD variable. The default value is 50, allowing you to tune how often the context compaction suggestion appears during your workflow.

When should I use manual context compaction instead of automatic compression?

You should use manual context compaction when context risks accumulate across complex, multi-step workflows spanning exploration, planning, and execution. It allows you to preserve critical information at strategic transition points rather than relying on automatic lossy compression.

Does manual context compaction work with any development tools?

Manual context compaction is configured to work specifically with Edit and Write tools within your Claude Code setup. It triggers a PreToolUse hook to call a shell script, requiring the script path to exist locally.