Skip to content

Multi-Day Sessions: Maintaining Context Across Days

intermediate 12 min 📋 Copy-paste ready
Sources not yet verified
sessionscontinuityslash-commandsworkflowclaude-code

Scenario

Context: You're working on a feature that spans multiple days and need to maintain context between sessions

Goal: Learn techniques and commands for maintaining continuity across multi-day AI-assisted development

Anti-pattern: Starting each session from scratch with no context, repeating explanations

Tools: Claude CodeGitHub Copilot

Conversation

The Multi-Day Session Problem

AI assistants don't remember previous sessions by default. Each conversation starts fresh. This creates friction when working on features that span days or weeks.

Solutions:

  1. CLAUDE.md files - Persistent context loaded automatically
  2. Session tracking commands - Document progress in-conversation
  3. Resume flags - Continue previous conversations
  4. Scratchpad files - Track state in version control

Day 1: Starting a Feature with Session Tracking

Using the claude-sessions extension or similar custom commands:

👤 You

/project:session-start auth-system-refactor

Starting a named session creates a tracking file and timestamps your work.
🤖 AI

Session started: auth-system-refactor
Timestamp: 2024-01-15 09:00:00
Tracking file: .claude/sessions/auth-system-refactor.md

I'm ready to help with the auth system refactor. What's the current state and goal?

The session is now being tracked. Progress will be logged to a file you can reference later.
👤 You

We need to migrate from session-based auth to JWT. Current codebase uses express-session with Redis. Goals:

  1. Replace session middleware with JWT verification
  2. Add refresh token rotation
  3. Keep backward compatibility during migration
Provide comprehensive context at session start - this will be captured for future reference.
🤖 AI

Understood. Let me outline the migration plan:

JWT Migration Plan

Phase 1: Add JWT Infrastructure (today)

  • Create JWT service (sign, verify, refresh)
  • Add new auth middleware that accepts both session AND JWT
  • Database: Add refresh_tokens table

Phase 2: Dual-Mode Operation (this week)

  • Update login endpoint to issue JWTs alongside session
  • Clients can opt-in to JWT mode
  • Monitor adoption metrics

Phase 3: Deprecation (next week)

  • Log warnings for session-only requests
  • Set sunset date for session auth

Phase 4: Removal

  • Remove express-session middleware
  • Clean up Redis session store

Shall I start with the JWT service?

The AI establishes a clear multi-phase plan that naturally spans multiple days.
👤 You

Yes, start with the JWT service. I'll need to stop for the day after this component.

Signaling session end helps the AI provide a good stopping point with context capture.
🤖 AI

[Implements JWT service with sign, verify, refresh methods...]

// src/services/jwt.service.ts
export class JWTService {
  async signAccessToken(userId: string): Promise<string> { ... }
  async signRefreshToken(userId: string): Promise<string> { ... }
  async verifyAccessToken(token: string): Promise<TokenPayload> { ... }
  async rotateRefreshToken(oldToken: string): Promise<TokenPair> { ... }
}

Created:

  • src/services/jwt.service.ts - Core JWT logic
  • src/types/auth.ts - Token type definitions
  • migrations/20240115_refresh_tokens.sql - Database schema

Ready for day-end wrap-up when you are.

The AI provides a clear summary of what was created, making resumption easier.
👤 You

/project:session-end

Ending the session triggers an automatic summary that captures state for resumption.
🤖 AI

Session Summary: auth-system-refactor

Duration: 2 hours 15 minutes
Date: 2024-01-15

Completed

  • JWT service implementation
  • Refresh token rotation logic
  • Database migration for refresh_tokens
  • Type definitions for tokens

In Progress

  • Dual-mode auth middleware
  • Login endpoint JWT issuance

Next Steps

  1. Create hybrid auth middleware (accepts session OR JWT)
  2. Update /auth/login to return tokens
  3. Add /auth/refresh endpoint

Key Decisions Made

  • Access token expiry: 15 minutes
  • Refresh token expiry: 7 days
  • Refresh token rotation: Single-use (invalidate on use)

Files Modified

src/services/jwt.service.ts (new)
src/types/auth.ts (new)
migrations/20240115_refresh_tokens.sql (new)

Session saved to .claude/sessions/auth-system-refactor.md
Resume tomorrow with /project:session-start auth-system-refactor

The session summary captures everything needed to resume: completed work, next steps, and key decisions.

Day 2: Resuming with Full Context

The next morning, you can resume with full context preserved:

👤 You

claude --continue

The `--continue` flag resumes your most recent conversation with full context.
🤖 AI

Welcome back! Resuming session: auth-system-refactor

Yesterday we completed the JWT service. Today's focus:

  1. Create hybrid auth middleware
  2. Update login endpoint
  3. Add refresh endpoint

Shall I start with the hybrid middleware?

With session files or --continue, the AI remembers exactly where you left off.

Alternative: Using CLAUDE.md for Persistent Context

If you prefer not to use session commands, maintain a CLAUDE.md file that Claude loads automatically:

# Auth System Refactor

## Current Status
Phase 1 complete (JWT service). Working on Phase 2 (dual-mode).

## Key Files
- src/services/jwt.service.ts - JWT sign/verify/refresh
- src/middleware/auth.ts - TODO: Add JWT support

## Decisions
- Access token: 15min, Refresh token: 7 days
- Refresh rotation: Single-use

## Next Actions
1. Hybrid auth middleware
2. Login endpoint JWT issuance

Update this file at the end of each session. Claude reads it automatically on startup.


Programmatic Session Resumption

For automated workflows, capture and resume sessions by ID:

# Capture session ID from first interaction
session_id=$(claude -p "Start auth refactor" --output-format json | jq -r '.session_id')

# Later, resume with that session
claude --resume "$session_id" -p "Continue with the middleware"

This is useful for CI/CD pipelines or scripts that need multi-step AI assistance.

👤 You

/project:session-update Added hybrid middleware, tests passing

Mid-session updates capture progress without ending the session.
🤖 AI

Progress logged:

[2024-01-16 14:30] Added hybrid middleware, tests passing

Git status:
- Modified: src/middleware/auth.ts
- Added: tests/middleware/auth.test.ts
- 4 files changed, 127 insertions

Notes appended to .claude/sessions/auth-system-refactor.md

Remaining for today:

  • Login endpoint JWT issuance
  • Refresh endpoint
Session updates capture git state automatically, creating an audit trail of your work.

Key Takeaways

  • Use `/project:session-start [name]` to begin tracked multi-day work
  • Use `/project:session-end` to generate summaries with next steps
  • Use `claude --continue` to resume your most recent conversation
  • Maintain `CLAUDE.md` as persistent context that loads automatically
  • Update session files at natural stopping points to capture decisions

Try It Yourself

Prompt Template

/project:session-start [feature-name]

I'm working on [describe feature]. Current state: [what exists]. Goal: [what we're building].

Let's start with [first component].

Variations to Try

  • End of day: `/project:session-end`
  • Next day: `claude --continue` or re-explain context
  • Progress update: `/project:session-update [what you accomplished]`
  • Custom: Add session commands to `.claude/commands/session-start.md`

Sources

Tempered AI Forged Through Practice, Not Hype

Keyboard Shortcuts

j
Next page
k
Previous page
h
Section home
/
Search
?
Show shortcuts
m
Toggle sidebar
Esc
Close modal
Shift+R
Reset all progress
? Keyboard shortcuts