Leaves notes for future Claude sessions in .claude/breadcrumbs.md. At session end or after significant work, records what was tried, what worked, what failed, and context for next time...
Write breadcrumbs (during/end of session):
.claude/breadcrumbs.md # Project-specific (preferred)
~/.claude/breadcrumbs/ # Global breadcrumbs by project
Create .claude/ directory if it doesn't exist. Add to .gitignore if user prefers.
cat .claude/breadcrumbs.md 2>/dev/null || echo "No breadcrumbs found"
If found, summarize key points:
## Previous Session Context
**Last worked on:** [topic]
**Status:** [completed/in-progress/blocked]
**Key notes:**
- [important finding 1]
- [important finding 2]
**Warnings from past self:**
- [thing that didn't work]
Don't read the whole file aloud - summarize what's relevant.
---
## [Date] - [Brief Topic]
**What we worked on:**
[1-2 sentence summary]
**What worked:**
- [approach that succeeded]
**What didn't work:**
- [approach that failed] - [why it failed]
**Left off at:**
[current state, what's next]
**Notes for next time:**
- [important context]
- [gotcha to remember]
- [file locations worth knowing]
Discovery breadcrumb - Found something important:
## 2024-01-15 - Discovery: Auth flow
**Found:** Auth doesn't use middleware. It's in route handlers.
**Location:** src/routes/api/*.ts - each route calls `validateSession()` directly
**Why it matters:** Don't look in middleware/ for auth stuff
Dead end breadcrumb - Tried something that failed:
## 2024-01-15 - Dead End: Redis caching
**Tried:** Adding Redis cache for user sessions
**Failed because:** App uses serverless, Redis connections don't persist
**Don't try again:** Any persistent connection solution
**Instead:** Use edge-compatible cache (KV store)
Progress breadcrumb - Work in progress:
## 2024-01-15 - In Progress: API refactor
**Done:**
- [x] Moved routes to /api/v2
- [x] Updated auth middleware
**Not done:**
- [ ] Update client SDK
- [ ] Migration script
**Blocked on:** Waiting for DB schema approval
**Next steps:** Once approved, run migration then update SDK
Context breadcrumb - Important background:
## 2024-01-15 - Context: Why we use X
**Decision:** Using Prisma instead of raw SQL
**Why:** Team preference, type safety, migration tooling
**Trade-off:** Slower queries but faster development
**Don't suggest:** Switching to raw SQL (already discussed)
Pruning old breadcrumbs:
.claude/breadcrumbs-archive.mdWhen to prune:
When reading:
๐ **Breadcrumbs found** - Last session: [date]
[Brief summary of relevant context]
Ready to continue, or starting fresh?
When writing:
๐ **Breadcrumb dropped**
[What was recorded]
This will be here next session.
Session 1 ends:
---
## 2024-01-15 - Auth Bug Investigation
**What we worked on:**
Users randomly getting logged out. Investigated session handling.
**What we found:**
- Sessions stored in Redis with 1hr TTL
- TTL not refreshing on activity (bug in middleware)
- File: src/middleware/session.ts:45 - missing `touch()` call
**What didn't work:**
- Checked JWT expiry first - red herring, JWTs are fine
- Looked in auth/ directory - session logic isn't there
**Left off at:**
Found the bug, haven't fixed yet. Fix is adding `session.touch()` after validation.
**Notes for next time:**
- Session middleware is in src/middleware/session.ts, NOT src/auth/
- Redis TTL is 1hr (REDIS_SESSION_TTL env var)
Session 2 starts:
๐ Breadcrumbs found - Last session: 2024-01-15
Previous session investigated logout bug:
- Found: session TTL not refreshing (src/middleware/session.ts:45)
- Fix identified: add session.touch() call
- Note: session code is in middleware/, not auth/
Ready to apply the fix?