Day 3 with Claude Code: How I Stopped Losing My Work to Compaction (Real Workflow)
Source: Dev.to
The Problem No One Warns You About
You are 90 minutes into a complex refactoring session with Claude Code. Everything is clicking. You have established the patterns, worked through the edge cases, and you are close to done.
Then compaction hits.
Claude summarizes the session, loses half the context, and comes back confused about decisions you made an hour ago. In the worst case, it starts re‑doing work you already finished — or even undoes it. I lost three hours of work this way on three separate occasions before I built a proper workflow around it.
Context loss during compaction is not random. It consistently wipes:
- Decisions and rejections – things you told Claude not to do get forgotten.
- Established patterns – coding conventions you negotiated session‑specific.
- In‑flight work – tasks that were 80 % done but not committed.
- File relationships – which modules touch which, discovered through exploration.
The summary Claude generates is optimistic: it captures tasks but not the reasoning behind them. It knows what you were doing, not why or what to avoid.
Solution: Session Management Workflow
Create a SESSION.md in the project root
# Session Context
## Active Goal
One sentence: what are we trying to accomplish
## Key Decisions Made
- Decision 1 and the reason
- Decision 2 and the reason
## What NOT To Do
- Approach we rejected and why
## Current State
Files changed, state of in‑progress work
This file acts as compaction insurance—Claude loads it fresh each time.
Update SESSION.md regularly
- Refresh every 20–30 minutes.
- Takes ~2 minutes but saves hours of rework.
Use a custom compact prompt
When the context gets long, run:
/compact "Please include in your summary: all rejected approaches, all active decisions with reasoning, all files currently being modified, and the exact current state of any in‑progress task."
Custom compact prompts dramatically improve summary quality.
Verify Claude’s understanding before proceeding
Instead of jumping straight back into the task, ask:
What is the current state of what we are working on, and what decisions have we made so far?
If the answer is wrong or incomplete, correct it before moving on.
Take full session snapshots with Mantra
For critical work sessions, use Mantra to capture a “save state” of the entire Claude Code conversation. Before any risky operation or natural breakpoint, Mantra records the full context so you can restore it exactly.
- Think of it as a quick‑save function in a video game.
- The tool stores snapshots locally, works across Claude Code, Cursor, and Windsurf, and lets you browse snapshots visually to see what was in context at any point.
- Free download:
Why session management matters
Losing a session is a sign that you’re using Claude Code for real, complex work. The most ambitious developers have built robust session‑management workflows; those still losing work to compaction have not yet adopted the habit.
Getting started
- Add a
SESSION.mdfile to your project (cost = 0, immediate benefit). - Update it every half hour.
- Use custom
/compactprompts as needed. - When the stakes are high, incorporate Mantra snapshots.
What session management strategies are you using?