DEV Community

decker
decker

Posted on • Edited on

I Lost 3 Hours of AI Coding Progress Because I Had No System. Here's What I Do Now.

Last month I spent an afternoon building out a feature with Claude Code. Solid session — the AI had full context, I was making good decisions, we iterated fast. Then I closed my laptop.

Next morning I opened a new session and typed: "Let's continue the auth work from yesterday."

Blank slate. No memory. I had to re-explain the entire project architecture, the decisions we'd made, why we'd ruled out the OAuth approach, the weird edge case in the token refresh logic. It took the better part of an hour just to get back to where I was.

That was the moment I realized I needed an actual system for managing AI coding sessions — not just vibes.

Here's what I've settled on after a few months of iteration.


The Core Problem: AI Sessions Are Stateless

This is obvious once you say it out loud, but it took me a while to internalize: every new Claude Code or Cursor session starts completely fresh. The AI has no memory of your last conversation, your architecture decisions, your half-finished thoughts.

You are the only continuity between sessions.

That means the burden of maintaining context falls entirely on you. If you don't externalize it somewhere, it's gone.


My Session Management System

1. Start Every Session With a Context File

I keep a AI_CONTEXT.md file at the root of each project. Before I start a session, I paste it in or reference it. It contains:

# Project: [Name]

## Current Status
- What's working: [brief description]
- What's in progress: [current feature/bug]
- What's blocked: [anything stuck]

## Architecture Decisions
- Using Postgres (not SQLite) because of concurrent writes
- Auth is JWT-based, refresh tokens stored in httpOnly cookies
- No ORM — raw SQL with a thin query builder

## Current Task
Building the webhook handler for Stripe events. Need to:
1. Verify signatures
2. Handle `payment_intent.succeeded` and `payment_intent.failed`
3. Update order status in DB

## Known Quirks
- The `processOrder()` function has a race condition we're ignoring for now
- Tests in `/api/__tests__` are flaky — skip them for this session
Enter fullscreen mode Exit fullscreen mode

Takes 5 minutes to write, saves 45 minutes of re-explanation.

2. Name Your Sessions Intentionally

In Cursor, you can see your chat history. In Claude Code, you can use /compact to compress and effectively checkpoint what you've done.

Before starting a new topic, I write one line at the top of the chat: SESSION: Stripe webhook handler - Feb 2026.

Silly? Maybe. But when I'm scrolling back through old chats to remember what approach I took for something, that one line saves me from reading through 200 messages.

3. Use /compact at the Right Moments

In Claude Code, /compact compresses your conversation history while keeping the AI's working context. I've learned to use it strategically:

Good times to /compact:

  • You've finished a sub-task and are moving to the next one
  • The conversation has hit 50+ messages and is slowing down
  • You just debugged something gnarly and want a clean slate for the next feature

Bad times to /compact:

  • You're mid-debug and the AI is holding onto a specific stack trace
  • You just established a complex constraint ("never use X because Y") that needs to stay in context
  • You're about to do a tricky refactor that requires full file awareness

When I do compact, I immediately follow up with: Quick summary of where we are: [2-3 sentences]. This ensures the compressed context isn't missing anything critical.

4. End Sessions With a Handoff Note

This one changed everything for me. Before I close my laptop, I type:

Before we wrap up, give me a 5-bullet handoff note: 
current status, what we decided, what's next, any gotchas, 
and anything I should tell you at the start of the next session.
Enter fullscreen mode Exit fullscreen mode

The AI generates it, I paste it into AI_CONTEXT.md, and my next session starts from that note instead of from nothing.

Example output:

## Handoff - Feb 22
- STATUS: Webhook handler is functional for happy path
- DECIDED: Using HMAC-SHA256 for signature verification (not the Stripe SDK)
- NEXT: Handle failed payment events + write integration tests
- GOTCHA: Stripe sends duplicate events — add idempotency key check before processing
- TELL AI: We're intentionally not using the Stripe Node SDK to keep the bundle small
Enter fullscreen mode Exit fullscreen mode

5. Keep a Decisions Log (Separate From Code Comments)

Code comments explain what the code does. I want a record of why decisions were made.

I keep a DECISIONS.md that looks like:

# Architecture Decisions

## 2026-02-10: Switched from Redis to Postgres for job queue
Was using Bull + Redis but ops complexity wasn't worth it for our scale.
Using pg-boss now. Revisit if we hit > 1000 jobs/min.

## 2026-02-15: No TypeScript strict mode
Started mid-project. Too many any types to fix before launch.
Revisit after v1 ships.
Enter fullscreen mode Exit fullscreen mode

When I start a new AI session on a tricky problem, I paste the relevant decision. It stops the AI from suggesting I switch to Redis or enable strict mode (again).


What I've Seen Others Do

Poking around dev communities, a few other patterns come up:

Project-level CLAUDE.md files — Claude Code actually has built-in support for this. If you put a CLAUDE.md at your project root, it gets loaded automatically. Some devs treat this as their persistent context file.

Session recordings — Some people screenshot or export chat logs to a folder. Low-tech but it works.

Checklists in the chat itself — Starting each session by pasting a running checklist, letting the AI check off items as you go, then copying the updated list before closing.


The Meta-Problem: Remembering to Do This

The system only works if you actually use it. The hardest part isn't designing a good workflow — it's building the habit of ending sessions with a handoff note instead of just closing the tab.

I set a reminder in my task manager: every time I stop a coding session, I run the handoff prompt before I close anything. After a few weeks it became automatic.


A Tool That Helps With This

For developers who want this kind of session management handled automatically rather than manually, Mantra is worth looking at. It's a session management tool for Claude Code that handles naming, context persistence, and session switching — basically the system I described above but without having to maintain it yourself.

I still maintain my own AI_CONTEXT.md files for project-level context (that's always going to be project-specific), but for the session organization layer it removes the friction.


The Takeaway

AI coding tools are genuinely powerful, but they're stateless by design. Treating every session like it starts fresh — and building a lightweight system to carry context forward — makes a bigger difference than any prompt engineering trick I've tried.

The system I use:

  1. AI_CONTEXT.md at project root with current status + decisions
  2. Named sessions with one-line headers
  3. Strategic /compact usage at natural breakpoints
  4. Handoff notes before closing
  5. Separate DECISIONS.md for architectural choices

None of this is complex. It's just the habit of treating the AI as a stateless tool that you have to keep oriented — because that's exactly what it is.


🛠️ How I Actually Solved This: Mantra

After losing those 3 hours and building the manual system above, I eventually wanted a tool that handled the hard parts automatically. Mantra covers three problems I kept hitting:

▶ Replay — Click any message in your session and the code snaps back to exactly that state. The TimberLine scrubber works like a video timeline — no more trying to reconstruct what the AI was working on from memory or git blame.

⚙️ Control — One MCP gateway that Claude Code, Cursor, Gemini CLI, and Codex all share. Add a tool once, every assistant uses it. Skills Hub keeps prompt context consistent across projects without manual copy-pasting.

🔒 Secure — A local Rust engine automatically detects API keys, passwords, and tokens in your sessions before you share them. One-click redaction. Nothing goes to the cloud.

No cloud. No sign-up. Free. → https://mantra.gonewx.com?utm_source=devto&utm_medium=article&utm_campaign=devto-article-launch

Top comments (1)

Collapse
 
mia_aria_fb101348d27f315c profile image
Mia Aria

Police Clearance Online Appointment is a system that lets applicants book, manage, and confirm police clearance visits online, saving time and avoiding long queues at police stations.