DEV Community

Nova Elvaris
Nova Elvaris

Posted on

The Checkpoint Pattern: Save and Resume Long AI Coding Sessions

You’re three hours into an AI-assisted refactoring session. The context window is stuffed. You ask for “one more change” and the model hallucinates a function that doesn’t exist.

Sound familiar? The problem isn’t the model — it’s that you never saved your progress.

The Pattern

A checkpoint is a small markdown file you write (or ask your assistant to write) at natural pause points during a long session. It captures:

  1. What’s done — files changed, tests passing
  2. What’s next — the immediate next task
  3. Key decisions — why you chose approach A over B
  4. Active constraints — things the model must not touch

Here’s the template:

# Checkpoint: Auth Refactor — Step 3 of 5

## Completed
- Extracted `AuthService` from `UserController`
- Added unit tests for token refresh flow
- Migrated 3/7 endpoints to new service

## Next
- Migrate `/api/users/me` endpoint
- Update integration tests

## Decisions
- Chose refresh-token rotation over sliding expiry (see PR #142 discussion)
- Keeping legacy `authenticate()` as deprecated wrapper until v3

## Constraints
- Do NOT modify `middleware/auth.js` — shared with billing service
- Keep backward compat with v2 API clients
Enter fullscreen mode Exit fullscreen mode

How I Use It

Every 30-45 minutes, I ask my assistant:

Write a checkpoint file for our current progress. Include what’s done, what’s next, and any decisions we’ve made.

I save it as checkpoint-001.md, checkpoint-002.md, etc. in the project root.

When the session dies (context overflow, timeout, new chat), I start the next session with:

Read checkpoint-003.md. This is where we left off. Continue from “Next”.

The model picks up exactly where it stopped — no re-explaining, no context drift.

Why This Works Better Than Chat History

Chat history is noisy. It contains wrong turns, debug output, your frustrated “no, that’s wrong” messages. A checkpoint is curated context — only what the model needs to continue.

Compare:

  • Chat history: 15,000 tokens of back-and-forth → model confused
  • Checkpoint: 200 tokens of clean state → model focused

Three Rules

  1. Checkpoint before you’re forced to. If you wait until the context window overflows, you’ve already lost information.

  2. Include the “why”, not just the “what”. Decisions without reasoning get reversed by the next session.

  3. Number them sequentially. When you need to backtrack, you want checkpoint-002.md, not a folder of files named progress.md and progress-final-v2.md.

The Compound Effect

After a week, your checkpoint files become a project journal. You can:

  • Onboard a teammate by sharing the last 3 checkpoints
  • Review decision history without reading 50 chat transcripts
  • Resume work after a vacation with zero ramp-up time

This isn’t complicated. It’s just discipline — the same discipline developers already apply to git commits, but extended to AI collaboration.

Start your next long session with a checkpoint template. Your future self will thank you.

Top comments (0)