Agent Skillssangrokjung/claude-forge › strategic-compact

strategic-compact

GitHub

通过Hook在编辑/写入前监控工具调用,在逻辑边界建议手动上下文压缩,避免自动压缩打断任务或丢失关键信息,优化长对话中的上下文管理。

skills/strategic-compact/SKILL.md sangrokjung/claude-forge

Trigger Scenarios

需要手动管理上下文长度时 在多步骤开发流程中需要清理历史上下文时

Install

npx skills add sangrokjung/claude-forge --skill strategic-compact -g -y
More Options

Use without installing

npx skills use sangrokjung/claude-forge@strategic-compact

指定 Agent (Claude Code)

npx skills add sangrokjung/claude-forge --skill strategic-compact -a claude-code -g -y

安装 repo 全部 skill

npx skills add sangrokjung/claude-forge --all -g -y

预览 repo 内 skill

npx skills add sangrokjung/claude-forge --list

SKILL.md

Frontmatter
{
    "name": "strategic-compact",
    "description": "Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction."
}

Strategic Compact Skill

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

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.sh script runs on PreToolUse (Edit/Write) and:

  1. Tracks tool calls - Counts tool invocations in session
  2. Threshold detection - Suggests at configurable threshold (default: 50 calls)
  3. Periodic reminders - Reminds every 25 calls after threshold

Hook Setup

Add to your ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "tool == \"Edit\" || tool == \"Write\"",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
      }]
    }]
  }
}

Configuration

Environment variables:

  • COMPACT_THRESHOLD - Tool calls before first suggestion (default: 50)

Best Practices

  1. Compact after planning - Once plan is finalized, compact to start fresh
  2. Compact after debugging - Clear error-resolution context before continuing
  3. Don't compact mid-implementation - Preserve context for related changes
  4. Read the suggestion - The hook tells you when, you decide if

Related

  • The Longform Guide - Token optimization section
  • Memory persistence hooks - For state that survives compaction

Version History

  • 1642dc5 Current 2026-07-25 09:24

Same Skill Collection

skills/build-system/SKILL.md
skills/cc-dev-agent/SKILL.md
skills/continuous-learning-v2/SKILL.md
skills/debugging-strategies/SKILL.md
skills/dependency-upgrade/SKILL.md
skills/eval-harness/SKILL.md
skills/evaluating-code-models/SKILL.md
skills/evaluating-llms-harness/SKILL.md
skills/frontend-code-review/SKILL.md
skills/korean-character-count/SKILL.md
skills/korean-spell-check/SKILL.md
skills/manage-skills/SKILL.md
skills/relay/SKILL.md
skills/review-loop/SKILL.md
skills/security-compliance/SKILL.md
skills/security-pipeline/SKILL.md
skills/session-wrap/SKILL.md
skills/skill-factory/SKILL.md
skills/stride-analysis-patterns/SKILL.md
skills/summarize/SKILL.md
skills/systematic-debugging/SKILL.md
skills/team-orchestrator/SKILL.md
skills/using-superpowers/SKILL.md
skills/verification-engine/SKILL.md
skills/verify-implementation/SKILL.md
skills/blind-spot-pass/SKILL.md
skills/cache-components/SKILL.md
skills/humanize-korean/SKILL.md
skills/loop-forge/SKILL.md
skills/prompts-chat/SKILL.md
skills/extract-errors/SKILL.md

Metadata

Files
0
Version
43fb666
Hash
1258d720
Indexed
2026-07-25 09:24

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-22 07:27
浙ICP备14020137号-1 $mapa de visitantes$