strategic-compact

strategic-compact is a skill for Claude Code from JunMystery/Agent-Guidance-Python. It costs 27 tokens per session (1,420 once invoked), scanned B, a copy of strategic-compact, MIT.

A workflow guide that tells the agent when to manually shorten the conversation context during long tasks. It focuses on natural boundaries such as finishing research or a major milestone.

In plain words
What is it for?
It is for deciding when to use the /compact command during multi-step work, task changes, or sessions nearing the context limit.
Why use it?
It helps prevent automatic context cleanup from happening in the middle of a task and losing useful information. This keeps later work focused when a session becomes very long or changes direction.

Skill for Claude Code

Written for Claude Code: PreToolUse hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; names the TodoWrite tool.

Good fit It is for deciding when to use the /compact command during multi-step work, task changes, or sessions nearing the context limit.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/junmystery/agent-guidance-python/strategic-compact
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add JunMystery/Agent-Guidance-Python --skill strategic-compact
Clone the repo
git clone --depth 1 https://github.com/JunMystery/Agent-Guidance-Python

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for strategic-compact

README.md
[![agentmods](https://agentmods.dev/badge/skills/junmystery/agent-guidance-python/strategic-compact/github.svg)](https://agentmods.dev/skills/junmystery/agent-guidance-python/strategic-compact)
Your own site
<a href="https://agentmods.dev/skills/junmystery/agent-guidance-python/strategic-compact"><img src="https://agentmods.dev/badge/skills/junmystery/agent-guidance-python/strategic-compact/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for strategic-compact

Your own site · 80×15
<a href="https://agentmods.dev/skills/junmystery/agent-guidance-python/strategic-compact"><img src="https://agentmods.dev/badge/skills/junmystery/agent-guidance-python/strategic-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,420 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.01420
Opus 5.5 $0.00011 $0.00568
Sonnet 5.5 $0.00005 $0.00284
Haiku 4.5 $0.00003 $0.00142

Measured 1mo ago against content hash 3eb441c2aa3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

strategic-compact scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

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

This is a copy

86% identical to strategic-compact — 37 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/strategic-compact/SKILL.md · 137 lines

How it starts

The opening of the file, as written. The whole thing — 137 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

Read the full file on GitHub · 137 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 137 lines · 27 tokens per session scan B 3eb441c2aa3a

Subscribe to this mod's changes

strategic-compact is a skill published in the GitHub repository JunMystery/Agent-Guidance-Python (2 stars, last pushed 3mo ago), licensed MIT. It adds 27 tokens to every session and 1,420 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). It is 86% identical to strategic-compact, differing in 37 lines, and is treated as a copy.

Related

Other skills, from other repositories

memorix-sessions

Use when resuming work, preparing handoff context, binding an HTTP control-plane project, or deciding whether sessionstart is useful.

AVIDS2/memorix · 31 tokens

cortex-consolidate

Run memory maintenance — decay old memories, compress stale content, consolidate episodic memories into semantic knowledge, and run sleep-like replay. Use when the user says 'clean up memories', 'consolidate', 'run maintenance', 'compress old memories', 'memory cleanup', or periodically to keep the memory system…

cdeust/Cortex · 84 tokens

cortex-profile

View and manage your cognitive profile — how you think, work patterns, blind spots, and cross-domain connections. Use when the user says 'show my profile', 'how do I work', 'what are my patterns', 'cognitive style', 'blind spots', 'methodology', or at the start of a session to load context. Also use 'rebuild profile'…

cdeust/Cortex · 98 tokens

Memory recall and capture

Use this skill when the user wants to recall something from past conversations, project decisions, or learned preferences across sessions — or when they want to explicitly save something to long-term memory. Trigger keywords include "remember", "recall", "what did we decide", "you forgot", "save this", or any…

alibaizhanov/mengram · 80 tokens

memoire-design-tooling

Use when a task spans interface understanding, design-system memory, UI audits, design CI, Figma, shadcn or Tailwind code generation, research, or agent design workflows and needs the correct Memi capability selected.

memi-design/memi · 51 tokens

onescience-knowledge-harvester

A research workflow that fills a stated knowledge gap by searching papers, extracting supported findings, and saving them as reusable knowledge cards.

onescience-ai/OneSkills · 198 tokens