claude-autopm 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autopm/.claude/agents/AGENT-REGISTRY.md +11 -2
- package/autopm/.claude/agents/core/context-optimizer.md +389 -0
- package/autopm/.claude/base.md +16 -0
- package/autopm/.claude/guides/memory-patterns.md +438 -0
- package/autopm/.claude/rules/context-compaction.md +334 -0
- package/autopm/.claude/templates/memory/active-work.template.json +15 -0
- package/autopm/.claude/templates/memory/checkpoint.template.md +58 -0
- package/lib/cli/commands/prd.js +104 -1
- package/package.json +1 -1
- package/packages/plugin-pm/commands/pm:prd-new.md +104 -4
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# Memory Patterns Guide
|
|
2
|
+
|
|
3
|
+
> Strategies for preserving critical information across Claude Code sessions without API-level memory tools.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Claude Code sessions are stateless - each `/clear` or new session starts fresh. This guide provides patterns to maintain continuity for long-running work without relying on API-level memory features.
|
|
8
|
+
|
|
9
|
+
## Core Strategies
|
|
10
|
+
|
|
11
|
+
### Strategy 1: File-Based Memory
|
|
12
|
+
|
|
13
|
+
Use project files to persist information between sessions.
|
|
14
|
+
|
|
15
|
+
#### Work State Files
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Create work state directory
|
|
19
|
+
.claude/
|
|
20
|
+
├── active-work.json # Current task state
|
|
21
|
+
├── decisions.md # Decision log
|
|
22
|
+
├── checkpoints/ # Session checkpoints
|
|
23
|
+
│ ├── 2024-01-15-auth-feature.md
|
|
24
|
+
│ └── 2024-01-16-dashboard.md
|
|
25
|
+
└── context/ # Preserved context
|
|
26
|
+
├── architecture.md
|
|
27
|
+
└── conventions.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### active-work.json Structure
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"current_task": {
|
|
35
|
+
"id": "issue-456",
|
|
36
|
+
"title": "Implement user dashboard",
|
|
37
|
+
"branch": "feature/user-dashboard",
|
|
38
|
+
"started": "2024-01-15T10:00:00Z",
|
|
39
|
+
"status": "in_progress"
|
|
40
|
+
},
|
|
41
|
+
"recent_changes": [
|
|
42
|
+
{
|
|
43
|
+
"file": "src/components/Dashboard.tsx",
|
|
44
|
+
"action": "created",
|
|
45
|
+
"description": "Initial dashboard component"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"blockers": [
|
|
49
|
+
"API endpoint returns 500 on edge case"
|
|
50
|
+
],
|
|
51
|
+
"next_steps": [
|
|
52
|
+
"Fix API error handling",
|
|
53
|
+
"Add mobile responsive styles"
|
|
54
|
+
],
|
|
55
|
+
"context_notes": "Using Chart.js for graphs, following existing component patterns"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Strategy 2: Checkpoint Files
|
|
60
|
+
|
|
61
|
+
Create snapshots at milestones for session recovery.
|
|
62
|
+
|
|
63
|
+
#### Checkpoint Template
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
# Checkpoint: [Feature/Task Name]
|
|
67
|
+
Date: [ISO timestamp]
|
|
68
|
+
Session: [N of estimated total]
|
|
69
|
+
|
|
70
|
+
## Status Summary
|
|
71
|
+
- Overall: [percentage]% complete
|
|
72
|
+
- Tests: [passing]/[total]
|
|
73
|
+
- Branch: [branch name]
|
|
74
|
+
- Last commit: [hash]
|
|
75
|
+
|
|
76
|
+
## Completed Items
|
|
77
|
+
- [x] Item 1 - [brief outcome]
|
|
78
|
+
- [x] Item 2 - [brief outcome]
|
|
79
|
+
|
|
80
|
+
## In Progress
|
|
81
|
+
- [ ] Item 3 - [current state, what's left]
|
|
82
|
+
|
|
83
|
+
## Pending
|
|
84
|
+
- [ ] Item 4
|
|
85
|
+
- [ ] Item 5
|
|
86
|
+
|
|
87
|
+
## Key Decisions Made
|
|
88
|
+
| Decision | Choice | Rationale |
|
|
89
|
+
|----------|--------|-----------|
|
|
90
|
+
| Auth method | JWT | Stateless, scalable |
|
|
91
|
+
| UI library | MUI | Team familiarity |
|
|
92
|
+
|
|
93
|
+
## Critical Context
|
|
94
|
+
- [Important information that must not be lost]
|
|
95
|
+
- [Constraints or requirements discovered]
|
|
96
|
+
- [Dependencies or blockers]
|
|
97
|
+
|
|
98
|
+
## Files Modified This Session
|
|
99
|
+
- `src/auth.js` - Added MFA support
|
|
100
|
+
- `src/components/Login.tsx` - Updated UI
|
|
101
|
+
|
|
102
|
+
## Commands to Resume
|
|
103
|
+
```bash
|
|
104
|
+
git checkout feature/user-dashboard
|
|
105
|
+
npm install
|
|
106
|
+
npm run dev
|
|
107
|
+
# Then: Start with "Continue dashboard implementation"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Notes for Next Session
|
|
111
|
+
- Check PR #789 status before continuing
|
|
112
|
+
- Need design review for mobile layout
|
|
113
|
+
- Performance testing after completion
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Strategy 3: Decision Log
|
|
117
|
+
|
|
118
|
+
Maintain persistent record of architectural decisions.
|
|
119
|
+
|
|
120
|
+
#### decisions.md Structure
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
# Decision Log
|
|
124
|
+
|
|
125
|
+
## Active Decisions
|
|
126
|
+
|
|
127
|
+
### DEC-001: Authentication Strategy
|
|
128
|
+
- **Date**: 2024-01-15
|
|
129
|
+
- **Status**: Active
|
|
130
|
+
- **Decision**: JWT with refresh tokens
|
|
131
|
+
- **Context**: Need stateless auth for microservices
|
|
132
|
+
- **Options Considered**:
|
|
133
|
+
- Sessions: Rejected (requires sticky sessions)
|
|
134
|
+
- JWT only: Rejected (no revocation)
|
|
135
|
+
- JWT + refresh: Selected (balance of stateless + security)
|
|
136
|
+
- **Consequences**:
|
|
137
|
+
- Must implement token rotation
|
|
138
|
+
- Need secure refresh token storage
|
|
139
|
+
- **Related**: DEC-003 (Token storage)
|
|
140
|
+
|
|
141
|
+
### DEC-002: Database Choice
|
|
142
|
+
- **Date**: 2024-01-14
|
|
143
|
+
- **Status**: Active
|
|
144
|
+
- **Decision**: PostgreSQL with Prisma ORM
|
|
145
|
+
...
|
|
146
|
+
|
|
147
|
+
## Superseded Decisions
|
|
148
|
+
|
|
149
|
+
### DEC-000: Original Auth Plan
|
|
150
|
+
- **Date**: 2024-01-10
|
|
151
|
+
- **Status**: Superseded by DEC-001
|
|
152
|
+
- **Decision**: Session-based auth
|
|
153
|
+
- **Why Changed**: Moved to microservices architecture
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Strategy 4: Context Files
|
|
157
|
+
|
|
158
|
+
Preserve project-specific knowledge.
|
|
159
|
+
|
|
160
|
+
#### architecture.md
|
|
161
|
+
|
|
162
|
+
```markdown
|
|
163
|
+
# Project Architecture
|
|
164
|
+
|
|
165
|
+
## Overview
|
|
166
|
+
[Brief description of system architecture]
|
|
167
|
+
|
|
168
|
+
## Key Components
|
|
169
|
+
- **Frontend**: React 18 + TypeScript
|
|
170
|
+
- **Backend**: Node.js + Express
|
|
171
|
+
- **Database**: PostgreSQL
|
|
172
|
+
- **Cache**: Redis
|
|
173
|
+
|
|
174
|
+
## Directory Structure
|
|
175
|
+
```
|
|
176
|
+
src/
|
|
177
|
+
├── components/ # React components
|
|
178
|
+
├── hooks/ # Custom hooks
|
|
179
|
+
├── services/ # API services
|
|
180
|
+
├── utils/ # Helper functions
|
|
181
|
+
└── types/ # TypeScript types
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Patterns in Use
|
|
185
|
+
- Repository pattern for data access
|
|
186
|
+
- Custom hooks for state management
|
|
187
|
+
- Error boundaries for resilience
|
|
188
|
+
|
|
189
|
+
## Critical Paths
|
|
190
|
+
- Auth flow: Login → JWT → Refresh → Logout
|
|
191
|
+
- Data flow: Component → Hook → Service → API
|
|
192
|
+
|
|
193
|
+
## Known Constraints
|
|
194
|
+
- Must support IE11 (legacy users)
|
|
195
|
+
- Max response time: 200ms
|
|
196
|
+
- Database connections limited to 100
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### conventions.md
|
|
200
|
+
|
|
201
|
+
```markdown
|
|
202
|
+
# Project Conventions
|
|
203
|
+
|
|
204
|
+
## Naming
|
|
205
|
+
- Components: PascalCase (UserProfile.tsx)
|
|
206
|
+
- Hooks: camelCase with 'use' prefix (useAuth.ts)
|
|
207
|
+
- Utils: camelCase (formatDate.ts)
|
|
208
|
+
- Constants: SCREAMING_SNAKE (MAX_RETRIES)
|
|
209
|
+
|
|
210
|
+
## File Organization
|
|
211
|
+
- One component per file
|
|
212
|
+
- Co-locate tests with source
|
|
213
|
+
- Index files for public exports
|
|
214
|
+
|
|
215
|
+
## Code Style
|
|
216
|
+
- Prefer functional components
|
|
217
|
+
- Use TypeScript strict mode
|
|
218
|
+
- Async/await over promises
|
|
219
|
+
|
|
220
|
+
## Git Conventions
|
|
221
|
+
- Branch: feature/issue-number-short-desc
|
|
222
|
+
- Commit: type(scope): message
|
|
223
|
+
- PR: Link to issue, include tests
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Implementation Workflows
|
|
227
|
+
|
|
228
|
+
### Workflow 1: Starting a New Task
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# 1. Check for existing work state
|
|
232
|
+
cat .claude/active-work.json
|
|
233
|
+
|
|
234
|
+
# 2. If resuming, load checkpoint
|
|
235
|
+
cat .claude/checkpoints/latest.md
|
|
236
|
+
|
|
237
|
+
# 3. Update work state
|
|
238
|
+
# Claude updates active-work.json with new task
|
|
239
|
+
|
|
240
|
+
# 4. Reference context files as needed
|
|
241
|
+
# Claude reads architecture.md, conventions.md
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Workflow 2: Mid-Session Checkpoint
|
|
245
|
+
|
|
246
|
+
```markdown
|
|
247
|
+
# When to create checkpoint:
|
|
248
|
+
- Before lunch/break
|
|
249
|
+
- After completing major milestone
|
|
250
|
+
- Before risky operation
|
|
251
|
+
- Every 30-45 minutes of active work
|
|
252
|
+
|
|
253
|
+
# Claude creates:
|
|
254
|
+
.claude/checkpoints/YYYY-MM-DD-task-name.md
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Workflow 3: Session Handoff
|
|
258
|
+
|
|
259
|
+
```markdown
|
|
260
|
+
# Before /clear or ending session:
|
|
261
|
+
|
|
262
|
+
1. Update active-work.json with current state
|
|
263
|
+
2. Create checkpoint if significant work done
|
|
264
|
+
3. Update decisions.md if new decisions made
|
|
265
|
+
4. Note any blockers or urgent items
|
|
266
|
+
|
|
267
|
+
# After /clear or new session:
|
|
268
|
+
|
|
269
|
+
1. Read active-work.json first
|
|
270
|
+
2. Load latest checkpoint
|
|
271
|
+
3. Review any new decisions
|
|
272
|
+
4. Continue from documented state
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Workflow 4: Completing a Task
|
|
276
|
+
|
|
277
|
+
```markdown
|
|
278
|
+
# On task completion:
|
|
279
|
+
|
|
280
|
+
1. Archive checkpoint to completed/
|
|
281
|
+
2. Clear active-work.json current_task
|
|
282
|
+
3. Update decisions.md if needed
|
|
283
|
+
4. Run /clear for fresh context
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## File Templates
|
|
287
|
+
|
|
288
|
+
### Quick Start Template
|
|
289
|
+
|
|
290
|
+
Create `.claude/templates/session-start.md`:
|
|
291
|
+
|
|
292
|
+
```markdown
|
|
293
|
+
# Session Start Checklist
|
|
294
|
+
|
|
295
|
+
## Load Context
|
|
296
|
+
- [ ] Read .claude/active-work.json
|
|
297
|
+
- [ ] Check latest checkpoint in .claude/checkpoints/
|
|
298
|
+
- [ ] Review recent decisions in .claude/decisions.md
|
|
299
|
+
|
|
300
|
+
## Verify State
|
|
301
|
+
- [ ] Correct branch checked out
|
|
302
|
+
- [ ] Dependencies up to date (npm install)
|
|
303
|
+
- [ ] Tests passing (npm test)
|
|
304
|
+
- [ ] No uncommitted changes (unless expected)
|
|
305
|
+
|
|
306
|
+
## Resume Work
|
|
307
|
+
Current task: [from active-work.json]
|
|
308
|
+
Last checkpoint: [file name]
|
|
309
|
+
Next steps: [from checkpoint or active-work]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Issue Memory Template
|
|
313
|
+
|
|
314
|
+
For tracking work per issue:
|
|
315
|
+
|
|
316
|
+
```markdown
|
|
317
|
+
# Issue #[number]: [title]
|
|
318
|
+
|
|
319
|
+
## Overview
|
|
320
|
+
- **Created**: [date]
|
|
321
|
+
- **Priority**: [P0-P3]
|
|
322
|
+
- **Estimated**: [hours/points]
|
|
323
|
+
|
|
324
|
+
## Progress Log
|
|
325
|
+
| Date | Action | Notes |
|
|
326
|
+
|------|--------|-------|
|
|
327
|
+
| MM-DD | Started | Initial analysis |
|
|
328
|
+
| MM-DD | Checkpoint | Auth complete |
|
|
329
|
+
|
|
330
|
+
## Implementation Notes
|
|
331
|
+
[Technical details discovered during implementation]
|
|
332
|
+
|
|
333
|
+
## Blockers Encountered
|
|
334
|
+
- [blocker 1]: [how resolved]
|
|
335
|
+
|
|
336
|
+
## Final Solution
|
|
337
|
+
[Brief description of implementation]
|
|
338
|
+
|
|
339
|
+
## Files Changed
|
|
340
|
+
- file1.ts: [what changed]
|
|
341
|
+
- file2.ts: [what changed]
|
|
342
|
+
|
|
343
|
+
## Tests Added
|
|
344
|
+
- test1.spec.ts: [what it tests]
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Commands Integration
|
|
348
|
+
|
|
349
|
+
### PM Commands for Memory
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# Save current state
|
|
353
|
+
/pm:checkpoint "milestone name"
|
|
354
|
+
|
|
355
|
+
# Load last checkpoint
|
|
356
|
+
/pm:resume
|
|
357
|
+
|
|
358
|
+
# View work history
|
|
359
|
+
/pm:history
|
|
360
|
+
|
|
361
|
+
# Clear with checkpoint
|
|
362
|
+
/pm:clear-safe
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Suggested Aliases
|
|
366
|
+
|
|
367
|
+
Add to `.bashrc` or `.zshrc`:
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
alias cc-checkpoint='echo "Creating checkpoint..." && cat > .claude/checkpoints/$(date +%Y-%m-%d-%H%M).md'
|
|
371
|
+
alias cc-resume='cat .claude/active-work.json && cat .claude/checkpoints/$(ls -t .claude/checkpoints/ | head -1)'
|
|
372
|
+
alias cc-state='cat .claude/active-work.json'
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Best Practices
|
|
376
|
+
|
|
377
|
+
### DO
|
|
378
|
+
- Create checkpoints at natural breakpoints
|
|
379
|
+
- Keep active-work.json always current
|
|
380
|
+
- Document decisions when made
|
|
381
|
+
- Reference context files in prompts
|
|
382
|
+
- Archive completed work
|
|
383
|
+
|
|
384
|
+
### DON'T
|
|
385
|
+
- Rely on conversation history alone
|
|
386
|
+
- Skip checkpoints for "quick" tasks
|
|
387
|
+
- Let decisions go undocumented
|
|
388
|
+
- Ignore context files after creation
|
|
389
|
+
- Delete checkpoints without archiving
|
|
390
|
+
|
|
391
|
+
## Memory Hierarchy
|
|
392
|
+
|
|
393
|
+
| Level | Location | Persistence | Use Case |
|
|
394
|
+
|-------|----------|-------------|----------|
|
|
395
|
+
| 1. Conversation | In-session | Until /clear | Active work |
|
|
396
|
+
| 2. Active Work | JSON file | Until task done | Current task state |
|
|
397
|
+
| 3. Checkpoints | MD files | Until archived | Session recovery |
|
|
398
|
+
| 4. Decisions | Log file | Permanent | Architectural choices |
|
|
399
|
+
| 5. Context | Doc files | Permanent | Project knowledge |
|
|
400
|
+
|
|
401
|
+
## Recovery Procedures
|
|
402
|
+
|
|
403
|
+
### Lost Session Recovery
|
|
404
|
+
|
|
405
|
+
```markdown
|
|
406
|
+
1. Check active-work.json for last known state
|
|
407
|
+
2. Find most recent checkpoint
|
|
408
|
+
3. Check git log for recent commits
|
|
409
|
+
4. Reconstruct from these sources
|
|
410
|
+
5. Create new checkpoint with recovered state
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Corrupted State Recovery
|
|
414
|
+
|
|
415
|
+
```markdown
|
|
416
|
+
1. Check git for last known good state of .claude/
|
|
417
|
+
2. Restore from git or backup
|
|
418
|
+
3. Verify against actual code state
|
|
419
|
+
4. Update files to match reality
|
|
420
|
+
5. Create fresh checkpoint
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Summary
|
|
424
|
+
|
|
425
|
+
File-based memory patterns provide:
|
|
426
|
+
- **Persistence** across sessions
|
|
427
|
+
- **Recovery** from interruptions
|
|
428
|
+
- **Audit trail** of decisions
|
|
429
|
+
- **Context** for future work
|
|
430
|
+
- **Continuity** for long tasks
|
|
431
|
+
|
|
432
|
+
**Key files to maintain:**
|
|
433
|
+
1. `.claude/active-work.json` - Current state
|
|
434
|
+
2. `.claude/checkpoints/*.md` - Session snapshots
|
|
435
|
+
3. `.claude/decisions.md` - Decision log
|
|
436
|
+
4. `.claude/context/*.md` - Project knowledge
|
|
437
|
+
|
|
438
|
+
**Remember**: The goal is not to remember everything, but to remember what matters enough to continue work effectively.
|