strategic-compact

strategic-compact is a skill for Claude Code, Codex 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 CodeCodex

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.

agentmods
npx agentmods add skills/junmystery/agent-guidance-python/strategic-compact
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, Codex.

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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00027 $0.01420
Opus 5 $0.00014 $0.00710
Sonnet 5 $0.00005 $0.00284
Haiku 4.5 $0.00003 $0.00142

Measured yesterday against content hash 3eb441c2aa3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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. yesterday 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 1mo ago), licensed MIT. It adds 27 tokens to every session and 1,420 once invoked, about $0.0001 per session on Opus 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

init-workspace-documentation

Skill "init-workspace-documentation" from griddynamics/rosetta, covering agent memory.md, agent memory, preventive rules, what worked and what failed.

griddynamics/rosetta · 10 tokens

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

vault-for-llm

Connect OpenClaw to Vault Agent Memory as a local-first governed project memory layer. Search first, then bounded-read cited source ranges; propose new memories as candidates instead of writing directly into active memory.

zycaskevin/Vault-Agent-Memory · 46 tokens

c-13-install-and-onboard

After the harness starter package and MCP server are wired and the harness has restarted, run/verify runtimeinstall, set up the memory repo, bootstrap onboarding when scaffolding new, and configure providers to index the code and memory.

Foxfire1st/agents-remember · 53 tokens

mem0-api

Complete reference for building applications with the Mem0 memory API and SDK — a persistent, self-improving memory layer for LLM agents and chatbots. ALWAYS use this skill when the user mentions: "mem0", "mem0ai", "MemoryClient", "Memory()", "memory layer for AI", "persistent agent memory", "long-term memory for…

pinkpixel-dev/mem0-mcp · 186 tokens

c-04-retrieval-strategy-router

Choose retrieval strategies across memory substrates: semantics for known concepts with unknown structure, relationships for known anchors with unknown connections, and intent for hidden contracts and code truths.

Foxfire1st/agents-remember · 42 tokens