MEMORY.md Setup Guide
MEMORY.md files help AI agents remember context between sessions. They're the "working memory" that persists after conversations end.
# why_memory_files
AI agents start fresh each session. Without memory files, you waste time re-explaining context. Memory files solve this by:
- ✓ Preserving decisions and their rationale
- ✓ Tracking work in progress across sessions
- ✓ Documenting project-specific knowledge
- ✓ Recording known issues and workarounds
# basic_example
A simple MEMORY.md for quick context:
# Project Memory ## Current Sprint - Working on: User authentication feature - Blocked: Waiting on API spec from backend team - Next up: Dashboard redesign ## Recent Decisions - 2024-01-15: Chose NextAuth over custom auth - 2024-01-10: Switched from REST to tRPC - 2024-01-05: Adopted Tailwind over styled-components ## Known Issues - Login redirect sometimes fails on Safari - Performance issue on /dashboard with large datasets ## Context for AI Currently implementing auth. Main files: - src/app/api/auth/[...nextauth]/route.ts - src/components/auth/LoginForm.tsx - src/lib/auth.ts
# session_memory
A session-focused MEMORY.md that tracks where you left off:
# Session Memory
## Last Session Summary
Date: 2024-01-15
Duration: 2 hours
Focus: Authentication implementation
### What We Did
1. Set up NextAuth with GitHub provider
2. Created login/logout UI components
3. Added protected route middleware
4. Fixed session persistence issue
### Where We Left Off
- Auth basics working
- Need to add: email provider, role-based access
- Bug: Session not refreshing on token expiry
### Files Modified
- src/app/api/auth/[...nextauth]/route.ts
- src/middleware.ts
- src/components/auth/LoginForm.tsx
- src/components/auth/UserMenu.tsx
## Open Questions
- Should we store user preferences in session or DB?
- How to handle auth in API routes vs server components?
## Architecture Notes
```
Auth Flow:
User → Login Page → NextAuth → GitHub OAuth → Callback → Session Created
↓
Protected Page ← Middleware Check ← Session Valid? ←───────┘
```
## Test Accounts
- [email protected] (admin role)
- [email protected] (basic role)
Note: Use GitHub OAuth in development # project_knowledge_base
A comprehensive knowledge base for larger projects:
# Project Knowledge Base
## Business Context
This is an internal tool for the marketing team to manage campaigns.
Users: 15 marketing team members
Usage: Daily, peak during campaign launches
## Domain Terminology
- Campaign: A marketing initiative with start/end dates
- Asset: Any creative (image, video, copy)
- Flight: A scheduled deployment of assets
- Attribution: Tracking conversion source
## Technical Architecture
### Frontend
- Next.js 14 with App Router
- React Query for server state
- Zustand for client state
- Tailwind + shadcn/ui components
### Backend
- API routes in Next.js
- PostgreSQL database
- Prisma ORM
- Redis for caching
### Infrastructure
- Vercel for hosting
- Supabase for database
- Uploadthing for file uploads
- Resend for emails
## Key Patterns
### Data Fetching
Always use React Query with proper error handling:
```tsx
const { data, isLoading, error } = useQuery({
queryKey: ['campaigns'],
queryFn: fetchCampaigns,
});
```
### Form Handling
Use react-hook-form + zod:
```tsx
const form = useForm<FormData>({
resolver: zodResolver(schema),
});
```
## Deployment
- Push to main → Vercel auto-deploys
- Database migrations run manually
- Environment variables in Vercel dashboard
## Historical Context
- v1 was a spreadsheet (2022)
- v2 was Airtable (2023)
- v3 is this custom app (2024)
- Migration from v2 completed Jan 2024 # memory_vs_claude_md
Both files serve different purposes:
CLAUDE.md
- • Static: Changes rarely
- • Instructions: How to work
- • Rules: What to do/not do
- • Patterns: Code examples
- • Committed: Usually in git
MEMORY.md
- • Dynamic: Updates often
- • Context: What's happening
- • State: Current progress
- • History: Past decisions
- • Optional: May be gitignored
# best_practices
Update After Each Session
Ask your AI agent to update MEMORY.md before ending a session
Be Concise
Include essential context, not every detail. AI agents have limited context windows.
Use Dates
Timestamp important decisions and session summaries
Track "Where We Left Off"
Always note the next step so you can resume quickly
Consider .gitignore
Session-specific memory might not belong in git
# automation_tips
Make memory management easier:
End-of-Session Prompt
"Please update MEMORY.md with: 1. Summary of what we accomplished 2. Where we left off 3. Any blockers or open questions 4. Files that were modified"
Start-of-Session Prompt
"Please read MEMORY.md and CLAUDE.md first. Then summarize where we left off and suggest next steps."