Module 5: Advanced TechniquesLesson 1 of 6
0%
Lesson 1ยท3 min

Using /compact for Long Sessions

Manage context in lengthy conversations

Using /compact for Long Sessions

Long conversations use tokens. /compact helps you work longer without losing context.

The Problem

Claude has a context window (how much it can remember). As you chat:

Terminal
> /cost
Context used: 180,000 / 200,000 tokens
โš ๏ธ Approaching context limit!
โ–Œ

When you hit the limit, Claude forgets early parts of the conversation.

The Solution: /compact

Terminal
> /compact
Compacting conversation...
Summary created:
- Project: Aussie Coffee Finder
- Tech: Next.js, Tailwind, Supabase
- Completed: Homepage, menu, cart
- In progress: Checkout flow
- Current file: src/app/checkout/page.tsx
Context reduced: 180,000 โ†’ 45,000 tokens
โ–Œ

Tip

Use /compact when you see token usage above 60-70%. Don't wait until you hit the limit!

When to Compact

Good times to compact:

SituationAction
Tokens > 70%/compact
Switching features/compact
Claude seems confused/compact
Long debugging session/compact
Starting new phase/compact

What Gets Preserved

After compacting, Claude remembers:

  • โœ… Project structure and tech stack
  • โœ… Key decisions made
  • โœ… Current task context
  • โœ… Important file locations
  • โœ… Your preferences and rules

What gets summarized:

  • ๐Ÿ”„ Step-by-step conversation
  • ๐Ÿ”„ Intermediate code attempts
  • ๐Ÿ”„ Debugging exploration
  • ๐Ÿ”„ Rejected alternatives

Aussie Note

Think of /compact like taking meeting notes. You don't remember every word, but you remember the decisions! ๐Ÿ“

Manual Summaries

Sometimes, add your own context:

Terminal
> /compact
> To clarify: we're building a checkout that:
> 1. Shows cart items with GST breakdown
> 2. Collects Australian shipping addresses
> 3. Integrates with Stripe (AUD)
> 4. Sends order confirmation email
>
> We've completed steps 1-2, now doing step 3.
โ–Œ

Key Takeaways

  • /compact reduces token usage while keeping context
  • Use when approaching 70% of context limit
  • Claude preserves key decisions and project state
  • Add your own summary for important details