Skip to main content
ClaudeWave
Skill171 estrellas del repoactualizado 1mo ago

Strategic Compact

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.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/ThamJiaHe/claude-code-handbook /tmp/strategic-compact && cp -r /tmp/strategic-compact/skills/examples/strategic-compact- ~/.claude/skills/strategic-compact
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

strategic-compact-skill.md

# 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/)
API DevelopmentSkill

Build REST APIs with proper error handling, status codes, request validation, response formatting, and rate limiting. Apply when creating API routes, handling errors, validating input, or designing API responses.

API Security HardeningSkill

Harden REST and GraphQL APIs against common attack vectors. Apply when building API endpoints, implementing authentication, handling file uploads, or exposing APIs to external consumers.

AWS Cloud InfrastructureSkill

Deploy Node.js applications on AWS using EC2, RDS, and managed services with security best practices. Apply when setting up AWS infrastructure, configuring databases, managing security, or optimizing costs.

Build Error ResolverSkill

Rapidly fix build failures, type errors, and lint issues with minimal diffs. Apply when builds fail, TypeScript reports errors, or CI/CD pipelines break. Focuses on getting the build green fast.

Cybersecurity Threat ModelingSkill

STRIDE-based threat modeling for application architecture. Apply when designing new systems, reviewing architecture, or assessing security posture of existing applications.

Docker ContainerizationSkill

Production-ready Docker patterns for multi-stage builds, security hardening, and orchestration. Apply when creating Dockerfiles, docker-compose configs, or deploying containerized applications.

Git WorkflowSkill

Enforces Conventional Commits, PR standards, merge conflict resolution, and branch management. Apply when committing code, opening PRs, resolving conflicts, managing branches, or handling Git operations.

Google Cloud Platform & APIsSkill

Deploy Node.js applications on Google Cloud with Cloud Run, Cloud Firestore, and Google APIs. Implement OAuth2 authentication and manage service accounts. Apply when building serverless applications, integrating Google services, or deploying to GCP.