OpenParable
Skip to content
← Back to skills

Compact Guide

Agent Building
compact-guide

Compact Guide is an Agent Skill for agent building published in the jh941213/my-cc-harness repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Context window management and token optimization guide. Triggers on: context, tokens, compact, memory management. NOT for: code writing, debugging.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/jh941213/my-cc-harness/blob/HEAD/skills_en/compact-guide/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/compact-guide, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Context Management Guide

Context is like fresh milk. It goes bad over time.

Core Rules

  • Reset before exceeding 80-100k tokens
  • Clean up context every 3-5 tasks
  • /clear after 3 /compact operations

Commands

/compact

  • Summarizes and compresses conversation content
  • Retains important information, reduces tokens only
  • Does not interrupt workflow

/clear

  • Complete reset
  • Risky without HANDOFF.md!
  • Use when you want a clean start

Recommended Pattern

Start work
    |
Complete 3-5 tasks
    |
/compact (token compression)
    |
Complete 3-5 tasks
    |
/compact
    |
Complete 3-5 tasks
    |
/compact
    |
/handoff (generate HANDOFF.md)
    |
/clear (reset)
    |
Read HANDOFF.md in new session

Warning

You can use up to 200k tokens, but quality degrades beyond 80-100k!

Context Management from a Cache Perspective

Why /compact Is Advantageous

  • System prompt + tool definition prefix cache is preserved
  • Only conversation messages are summarized, so cache hits are possible every turn
  • Significantly lower cost than /clear

Hidden Cost of /clear

  • Invalidates the entire prefix cache (system prompt + tools + CLAUDE.md + rules/ all recomputed)
  • Additional tokens generated when loading HANDOFF.md
  • Cache warmup needed from the next API call

Compaction Timing Guide

  • 50-70k tokens: First /compact (do it early while there's room)
  • 80-100k tokens: Second /compact or prepare /handoff
  • If still above 80k after /compact: /handoff -> /clear -> new session
  • Do not compact above 150k (risk of insufficient buffer)