home / skills / duc01226 / easyplatform / compact

compact skill

/.claude/skills/compact

This skill compresses conversation context to optimize token usage, preserving essential details while removing redundancy for smoother long-running sessions.

npx playbooks add skill duc01226/easyplatform --skill compact

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.9 KB
---
name: compact
description: "[Tooling & Meta] Compress conversation context to optimize tokens"
infer: true
---

# Compact Context

Proactively compress the current conversation context to optimize token usage.

## When to Use

- Before starting a new task in a long session
- When working on multiple unrelated features
- At natural workflow checkpoints (after commits, PR creation)
- When context indicator shows high usage

## Actions

1. **Summarize completed work** - What was done, key decisions made
2. **Preserve essential context** - Active file paths, current task, blockers
3. **Clear redundant history** - Old exploration, superseded plans
4. **Update memory** - Save important patterns to `.claude/memory/`

## Best Practices

- Use `/compact` at natural breakpoints, not mid-task
- After compacting, briefly restate the current objective
- Check that critical file paths are still accessible
- If working on a bug, preserve error messages and stack traces

## Context Preservation Checklist

Before compacting, ensure you've saved:

- [ ] Current branch and uncommitted changes status
- [ ] Active file paths being modified
- [ ] Any error messages or stack traces
- [ ] Key decisions and their rationale
- [ ] Pending items from todo list

## Example Usage

```
User: /compact
Claude: Compacting context...

## Session Summary
- Implemented employee export feature
- Fixed validation bug in SaveEmployeeCommand
- Created unit tests for EmployeeHelper

## Active Context
- Branch: feature/employee-export
- Files: Employee.Application/Commands/ExportEmployees/
- Current task: Add pagination to export

## Cleared
- Exploration of unrelated notification code
- Superseded implementation approaches

Ready to continue with pagination implementation.
```

## IMPORTANT Task Planning Notes

- Always plan and break many small todo tasks
- Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

Overview

This skill compresses the active conversation context to optimize token usage and keep sessions focused. It creates a concise session summary, preserves essential artifacts, and clears redundant history so future prompts remain efficient. Use it to maintain a compact, actionable context at workflow checkpoints.

How this skill works

The skill inspects the current conversation and identifies completed work, active tasks, and noise that can be removed. It generates a short session summary, records critical items (file paths, branch, errors, blockers), and prunes exploratory or superseded content. Optionally it updates a persistent memory store with important patterns or decisions for future sessions.

When to use it

  • Before starting a new task in a long session
  • After finishing a feature, creating a commit, or opening a PR
  • When switching between unrelated features or files
  • When the context indicator shows high token usage
  • At natural workflow checkpoints (end of day, end of sprint)

Best practices

  • Invoke compact at natural breakpoints, not mid-task
  • Briefly restate the current objective immediately after compacting
  • Ensure branch and uncommitted change status are saved before pruning
  • Preserve error messages, stack traces, and reproduction steps for active bugs
  • Record file paths and current task IDs so context can be rehydrated quickly

Example use cases

  • Finish an implementation and compact before starting a code review to keep context clear
  • Switch from a UI task to a backend task and compress unrelated history to reduce noise
  • After fixing a bug, compact while preserving stack traces and the failing test to speed follow-up work
  • Use compact at the end of a work session to summarize progress and save key decisions to memory
  • Run compact when token usage grows near limits to avoid truncated prompts

FAQ

What does compact remove versus preserve?

Compact removes exploratory notes, superseded plans, and redundant messages while preserving summaries, active file paths, branch status, blockers, and critical error logs.

Will compact lose important details I might need later?

Follow the checklist: save branch status, active files, errors, and key decisions before compacting. The skill also offers optional memory updates for long-term retrieval.