Skip to content

Memory & Persistence

Context windows are ephemeral — everything in them is lost when the session ends or context compacts. Memory and persistence strategies ensure critical information survives these boundaries.

MechanismSurvives CompactionSurvives Session EndShared with Team
Context windowNoNoNo
Scratchpad files (NOTES.md)YesYesIf committed
.sdlc/ artifactsYesYesYes
Agent config filesAlways loadedAlways loadedYes
SkillsLoaded on demandYesYes
Git commitsN/AYesYes
Per-user memory storeYesYesNo

For active work that spans compaction events, use scratchpad files:

Create PROGRESS.md to track this implementation.
After each completed step, update it with:
- What was done
- Files modified
- Test results
- Next steps
After any compaction, read PROGRESS.md to restore context.

When to use: Multi-step implementations, debugging sessions, any task longer than one context window.

For structured development workflows:

.sdlc/research/auth-analysis.md
## Summary
The auth system uses JWT with Redis-backed refresh tokens.
## Key Files
- src/middleware/auth.ts — Token validation middleware
- src/services/auth.ts — Login, logout, refresh logic
- src/repos/sessions.ts — Redis session store
## Flow
1. Client sends JWT in Authorization header
2. auth.ts validates signature and expiration
3. If expired, checks refresh token in Redis
4. If valid refresh, issues new JWT
5. If invalid refresh, returns 401

The Three-Level Agent Configuration Hierarchy

Section titled “The Three-Level Agent Configuration Hierarchy”

Many AI coding agents support a layered configuration system that loads context at different scopes. The general pattern has three levels:

See the Tool Configuration Reference for the exact file names and locations your tool uses at each level.

Personal preferences that apply across all projects, stored in your tool’s global config file:

# Personal Preferences
- I prefer concise responses without trailing summaries
- Always use conventional commits
- Run tests before committing

Project-specific conventions shared with the team, stored in the root agent configuration file:

# MyProject
## Stack
TypeScript, Hono, Drizzle, Vitest, pnpm
## Commands
[project-specific commands]

Domain-specific conventions loaded when working in a particular directory — stored in a configuration file within that subdirectory (e.g., src/api/):

# API Conventions
- All endpoints return { data, error, meta }
- Use zod for request validation
- Auth middleware applied via route groups

AI coding agents handle session continuity differently. Some support resuming via CLI flags; others maintain session state within their IDE panels. Check your tool’s documentation for session persistence options.

Some tools support named sessions. Named sessions are easier to find and resume. Treat sessions like branches — different workstreams get separate sessions.

Information TypePersist ToWhy
Active task progressPROGRESS.md or NOTES.mdSurvives compaction, easy to update
Research findings.sdlc/research/Reusable across sessions
Implementation plans.sdlc/plans/Survive compaction, reviewable
Architectural decisionsGit commit messagesPermanent, searchable history
Project conventionsAgent config fileLoaded every session
Domain knowledgeSkills / snippets directoryOn-demand, doesn’t bloat every session
Personal preferencesUser-global agent configGlobal, personal

Add instructions to your agent configuration file:

## Compaction Instructions
When compacting, always preserve:
- The full list of modified files
- All test commands that have been run
- Current plan progress and next steps
- Any architectural decisions made this session
- Active NOTES.md or PROGRESS.md file references