Skip to content
Back to skills

Examples

ASecurity

Smart context compaction that preserves critical information. Apply when context usage approaches 60-80% to recover usable context without losing important decisions, progress, or reasoning.

  • 201 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 7, 2026
ai-agentsbashdebugginggitdocumentation

Works with

  • claude code

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add ThamJiaHe/claude-code-handbook --skill examples --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Examples?

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

Security grade badge for Examples
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thamjiahe-examples-1f16f4c3/badge)](https://www.skillsdirectory.com/skills/thamjiahe-examples-1f16f4c3)

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: "Smart context compaction that preserves critical information. Apply when context usage approaches 60-80% to recover usable context without losing important decisions, progress, or reasoning."
allowed-tools: Read, Write, Edit, Bash
version: 2.1.0
compatibility: Claude Opus 4.6, Sonnet 4.6, Claude Code v2.1.x
updated: 2026-03-26
---

# Strategic Compact

Smart context compaction that preserves what matters and discards what doesn't.

## Overview

Running `/compact` blindly can lose critical context — architecture decisions, debugging hypotheses, partial progress. This skill teaches **when** and **how** to compact strategically.

## When to Compact

| Context Usage | Action |
|:---:|--------|
| < 50% | Continue working. No action needed. |
| 50-60% | Finish current task, then compact. |
| 60-70% | Run `/compact` now — recovers ~70% of usable context. |
| 70-80% | Save state first, then `/compact`. |
| > 80% | Save session immediately. Consider starting fresh. |

## Pre-Compact Checklist

Before running `/compact`, ensure these survive:

1. **Architecture decisions** — Why you chose approach A over B
2. **Current task progress** — What step you're on, what's left
3. **File modification list** — Which files have been changed
4. **Known issues** — Bugs found, workarounds applied
5. **Blocked items** — What needs user input or external resolution

## Compact Strategy

### Step 1: Persist Critical State

```
"Before compacting, write a brief summary to .compact-state.md:
- Current task and progress (step X of Y)
- Files modified: [list]
- Key decisions: [list]
- Next steps: [list]
- Known issues: [list]"
```

### Step 2: Run Compact with Custom Summary

```
/compact "Preserve: working on [feature], modified [files], next step is [X]"
```

The custom prompt tells `/compact` what to prioritize in the summary.

### Step 3: Re-inject After Compact

```
"Read .compact-state.md to restore context about our current work."
```

## Post-Compact Hook (Automation)

Auto-remind yourself of project essentials after every compaction:

```json
{
  "hooks": {
    "SessionStart": [{
      "matcher": "compact",
      "hooks": [{
        "type": "command",
        "command": "cat .compact-state.md 2>/dev/null || echo 'No saved state found'"
      }]
    }]
  }
}
```

## What's Safe to Compact Away

- File contents you've already read (can be re-read)
- Search results (can be re-searched)
- Verbose tool output (git log, test output)
- Exploratory analysis that led to dead ends
- Conversation about approach options (after decision is made)

## What Must Be Preserved

- The decision itself (not the discussion leading to it)
- Current task state and progress markers
- Error messages and stack traces being debugged
- User preferences stated in this session
- Partial implementations not yet committed

## Integration with Session Management

For long-running work, combine with session management:

```
# At 70% context:
/save-session              # Persist full state
/compact "Preserve: [key context]"  # Compress

# If starting fresh:
/resume-session            # Restore from saved state
```

## Sources

- [Everything Claude Code — Strategic Compact](https://github.com/anthropics/everything-claude-code)
- [Claude Code Documentation — Context Management](https://code.claude.com/docs/en/)

Files in this skill

  • accessibility-ux.md9.9 KB
  • api-development-skill.md10.1 KB
  • api-security-hardening-skill.md6.9 KB
  • aws-cloud-infrastructure-skill.md9.8 KB
  • build-error-resolver-skill.md4.2 KB
  • code-review.md9.4 KB
  • cybersecurity-threat-modeling-skill.md8.2 KB
  • database-migrations.md10.1 KB
  • docker-containerization-skill.md3.7 KB
  • example-feedback-analyzer.md10.1 KB
  • git-workflow-skill.md9.6 KB
  • google-cloud-platform-skill.md12.3 KB
  • incident-response-skill.md5.1 KB
  • monitoring-logging-skill.md11.6 KB
  • neon-serverless-skill.md9.8 KB
  • nextauth-authentication-skill.md11.7 KB
  • nextjs-app-router-skill.md12.3 KB
  • owasp-security-audit-skill.md12 KB
  • penetration-testing-skill.md7.5 KB
  • performance-optimization-skill.md9.3 KB

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

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