Compact hygiene

From OnlyTerp/windsurf-unlocked · View interactive version

Compact hygiene is an AI agent skill from the GitHub repository OnlyTerp/windsurf-unlocked. Guides proactive /compact usage with preservation instructions to prevent context rot in long Cascade sessions. Triggers when context reaches ~50% of window, before large tool outputs, or when the user mentions "context", "compact", "drift", or "forgetting".

How to use this skill

Skill file

Compact Hygiene

Long sessions rot. Most users only run /compact when the warning light is already red — and by then the earliest (most foundational) context is already being summarized away. You run it proactively, with explicit preservation instructions.

When to Run

How to Compact With Preservation

Run /compact with a clear list of what to keep verbatim and what to drop. Example:

/compact
Preserve verbatim:
- The current plan file path: plans/2026-04-17-stripe-webhooks.md
- The 3 AGENTS.md invariants I cited this session (testing ≥80%, no PII logging, API shape)
- The 2 design decisions from @architect: (1) use Stripe PaymentIntents not Charges, (2) webhook idempotency via Redis INCR
- The current plan's checkbox state (which are done, which are next)
- All error messages from the last failed test run

Discard:
- Tool outputs from exploration that didn't lead anywhere
- File contents I've already edited
- Previous grep results we superseded
- Verbose npm install logs

Preservation Checklist — What You Almost Always Want to Keep

Things Safe to Drop

Agent Protocol

  1. Monitor context size silently. At ~50%, suggest a compact and list what you'd preserve.
  2. Ask first if the session has made novel design decisions not yet written to the plan. Compact can summarize these away.
  3. Write decisions to vault/ FIRST. Anything worth preserving long-term goes to vault/decisions/ before you compact — the vault survives forever, the session doesn't.
  4. After compact, re-read the preserved plan file and any cited vault pages to ground yourself before continuing.

Never

Credits

Pattern from MindStudio's /compact writeup (Apr 2026) and Anthropic's automatic context compaction cookbook.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.