Skip to content
Back to skills

Strategic Compact

ASecurity

Decision guide for when and how to compact context strategically, preserving critical state while reclaiming token budget.

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added October 26, 2026
code-qualitygobashdebugginggit

Works with

  • mcp

Security analysis

A100/100

Scanned October 26, 2026

npx -y skills add nhan03bit/ultrathink --skill strategic-compact --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Strategic Compact?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Strategic Compact
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nhan03bit-strategic-compact/badge)](https://www.skillsdirectory.com/skills/nhan03bit-strategic-compact)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: strategic-compact
description: Decision guide for when and how to compact context strategically, preserving critical state while reclaiming token budget.
layer: utility
category: optimization
triggers:
  - compact
  - strategic compact
  - context management
  - free up context
  - running out of context
  - compaction
linksTo:
  - context-budget
riskLevel: low
---

# Strategic Compact — Context Management

Know when to compact and what to preserve. Bad compaction loses critical state. Good compaction extends your effective session length.

## When to Compact

### Trigger Points

1. **Phase transition**: Finished planning → starting implementation
2. **After big reads**: Explored many files, now know what to change
3. **Before new task**: Switching focus within same session
4. **Context pressure**: Responses slowing, hitting limits
5. **After debugging**: Root cause found, fix applied, debug trace no longer needed
6. **Post-review**: Code review complete, feedback incorporated

### When NOT to Compact

- Mid-debug with active hypothesis
- Holding multiple file contents needed for cross-file refactor
- Waiting for user decision on alternatives presented
- Active error context not yet resolved

## Survival Rules

### What Survives Compaction

| Category | Examples | Why |
|----------|----------|-----|
| Current task | Goal, acceptance criteria | Core mission |
| Files modified | Paths + what changed | Resume point |
| Decisions made | Architecture choices, trade-offs | Avoid re-debating |
| Pending work | Next steps, blockers | Continuity |
| Debug context | Root cause if still fixing | Don't re-diagnose |
| Breadcrumbs | `// intent:` comments in code | Persistent context |

### What Gets Dropped

| Category | Examples | Why |
|----------|----------|-----|
| Exploratory reads | Files read but not modified | Can re-read via VFS |
| Verbose tool output | Full `git log`, large diffs | Reference by summary |
| Rejected drafts | Discarded approaches | Decision recorded, draft irrelevant |
| CLAUDE.md contents | Project instructions | Auto-reloaded on compact |
| Full file contents | Entire source files | Reference by path + line range |
| Resolved errors | Stack traces from fixed bugs | Fix applied, trace stale |

## Pre-Compact Checklist

Before compacting, ensure:

- [ ] **Breadcrumbs planted**: Modified files have `// intent:` / `// status:` comments
- [ ] **Plan updated**: If using a plan, current progress is recorded
- [ ] **Key paths noted**: List all files actively being modified
- [ ] **Decisions documented**: Important choices are in breadcrumbs or plan, not just conversation
- [ ] **No pending output**: All critical tool results have been acted on
- [ ] **Memory saved**: Important learnings flushed to memory system if applicable

## Compact Strategy by Scenario

### After Exploration
```
Preserve: target files identified, architecture understanding, chosen approach
Drop: all file contents read during exploration, rejected paths
```

### After Implementation Phase
```
Preserve: what was built, remaining tasks, test results
Drop: intermediate drafts, build output, resolved lint errors
```

### After Debugging
```
Preserve: root cause, fix applied, files changed, any remaining issues
Drop: failed hypotheses, stack traces, exploratory reads
```

### Task Switch
```
Preserve: summary of completed task, files touched
Drop: all implementation details of completed task
```

## UltraThink Integration

- **Memory system**: Save important context to memory before compacting
  ```bash
  npx tsx memory/scripts/memory-runner.ts save --scope project --content "..."
  ```
- **VFS recovery**: After compaction, use `mcp__vfs__extract` to cheaply re-examine files (~200 tokens vs ~3000)
- **Breadcrumbs**: Code comments survive compaction — they're in the files, not the conversation
- **Auto-memory**: Check `/tmp/ultrathink-memories/` for auto-saved context before compacting

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.