Tutorial: Compaction-Resilient Projects
Long-running features inevitably hit context limits. This tutorial shows how to structure your project and workflow so nothing critical is lost when compaction occurs.
The Problem
Section titled “The Problem”Without preparation, compaction loses:
- Nuanced decisions made early in the session
- Exact file contents read earlier
- The reasoning behind architectural choices
- Progress on multi-step implementations
- Relationships between changes
The Solution: External Persistence
Section titled “The Solution: External Persistence”The key insight: anything that must survive compaction must exist outside the context window — in files, not in chat history.
Setting Up the Infrastructure
Section titled “Setting Up the Infrastructure”-
Create the .sdlc directory
Terminal window mkdir -p .sdlc/{specs,plans,research,progress} -
Add compaction instructions to your agent configuration file
Add the following to your agent configuration file:
## Compaction InstructionsWhen compacting, always preserve:- References to active .sdlc/ files- The full list of modified files- Current step in any active plan- All test commands that have been run- Any architectural decisions made this sessionAfter compaction, re-read the active PROGRESS.md if one exists. -
Create a progress tracking template
.sdlc/progress/TEMPLATE.md:# Progress: [Feature Name]## Status: [In Progress / Blocked / Complete]## Started: [Date]## Spec.sdlc/specs/[feature].md## Plan.sdlc/plans/[feature].md## Current StepStep [N] of [total]: [description]## Completed Steps- [x] Step 1: [description] — [files modified]- [x] Step 2: [description] — [files modified]- [ ] Step 3: [description]## Modified Files- src/path/to/file.ts (new/modified)- src/path/to/other.ts (modified)## Decisions Made- Chose sliding window over fixed window because [reason]- Using Redis for distributed state because [reason]## BlockersNone / [Description of blocker]## Next Action[What to do next when resuming]
The Compaction-Resilient Workflow
Section titled “The Compaction-Resilient Workflow”Starting a Feature
Section titled “Starting a Feature”Create a progress tracker at .sdlc/progress/rate-limiting.mdusing the template. We're implementing rate limiting based on.sdlc/specs/rate-limiting.md with the plan at.sdlc/plans/rate-limiting.md.During Implementation
Section titled “During Implementation”After each significant step:
Update .sdlc/progress/rate-limiting.md:- Mark step 3 as complete- Add src/middleware/rateLimit.ts to modified files- Record decision: using lua scripts for atomic Redis operations- Set next action: implement step 4 (test infrastructure)After Compaction
Section titled “After Compaction”When you notice compaction has occurred (or start a new session):
Read .sdlc/progress/rate-limiting.md to restore context.Continue from the next action listed there.The progress file contains everything needed to resume:
- Where you are in the plan
- What files have been modified
- What decisions were made and why
- What to do next
Completing a Feature
Section titled “Completing a Feature”Mark .sdlc/progress/rate-limiting.md as complete.Move it to .sdlc/progress/archive/ for reference.Multi-Session Features
Section titled “Multi-Session Features”For features spanning multiple days or sessions, use named sessions if your tool supports them. See the Tool Configuration Reference for your tool’s session commands.
# Day 1: Start a named session for research# Research phase, save to .sdlc/research/
# Day 2: Start a named session for planning# Planning phase, save to .sdlc/plans/
# Day 3-4: Start a named session for implementation# Implementation with progress trackingCheck your agent’s documentation for how to resume or switch between named sessions. Most tools provide a way to continue a previous session or select from recent history.
What Goes Where
Section titled “What Goes Where”| Information | Storage Location | Survives |
|---|---|---|
| Active progress | .sdlc/progress/[feature].md | Everything |
| Feature specification | .sdlc/specs/[feature].md | Everything |
| Implementation plan | .sdlc/plans/[feature].md | Everything |
| Research findings | .sdlc/research/[topic].md | Everything |
| Code changes | Git commits | Everything |
| Session context | Context window | Only current session |
Testing Your Setup
Section titled “Testing Your Setup”- Start a multi-step task
- Complete 2-3 steps, updating progress
- Clear your context or start a fresh session to simulate compaction (see Tool Configuration Reference)
- Resume using only the progress file
- Verify you can continue seamlessly
If step 4 works without confusion, your setup is compaction-resilient.