Query and manage RALPH's persistent memory layer
Query and manage RALPH's persistent cross-session memory.
| Command | Description |
|---|---|
/ralph-memory |
Show memory stats and recent insights |
/ralph-memory query "term" |
Search memory for a term |
/ralph-memory insights |
Show all insights |
/ralph-memory entities |
Show all entities |
/ralph-memory add-insight "learning" |
Add a manual insight |
/ralph-memory export |
Export memory to file |
/ralph-memory cleanup |
Clean old entries |
/ralph-memoryRALPH stores knowledge in three JSON files:
.ralph/memory/
āāā entities.json # Files, functions, classes, patterns
āāā relationships.json # How entities relate to each other
āāā insights.json # Learnings and gotchas
Things RALPH knows about:
{
"type": "file",
"name": "src/types/user.ts",
"properties": {
"exports": ["User", "CreateUserInput"],
"imports": ["zod"],
"lastModified": "2026-01-25T10:00:00Z"
}
}
Entity Types:
file - Source files and their contentsfunction - Functions and their signaturesclass - Classes and their methodspattern - Architectural patterns usedconfig - Configuration filestest - Test files and coverageHow entities connect:
{
"fromId": "src/types/user.ts",
"toId": "src/services/user.service.ts",
"type": "imports",
"properties": {
"symbols": ["User", "CreateUserInput"]
}
}
Relationship Types:
imports - File imports anotherexports - File exports symbolsuses - Function uses anotherextends - Class extends anotherimplements - Class implements interfacetests - Test file tests sourceLearnings from implementation:
{
"context": "Implementing user authentication",
"learning": "Always export new types from index.ts immediately",
"tags": ["types", "exports", "patterns"],
"occurrences": 3,
"createdAt": "2026-01-25T10:00:00Z",
"lastSeen": "2026-01-25T15:00:00Z"
}
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā RALPH Memory ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Entities: 45 total
- Files: 28
- Functions: 12
- Patterns: 5
Relationships: 67 total
- imports: 34
- exports: 22
- tests: 11
Insights: 15 total
- Unique tags: 8
- Total occurrences: 42
Recent Insights:
1. "Always export new types from index.ts" (Ć3)
2. "Use Zod for runtime validation" (Ć2)
3. "Prefer async/await over raw promises"
Top Tags: types, patterns, validation, testing, exports
/ralph-memory query "validation"
Output:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Memory Query: "validation" ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Entities (3 matches):
[file] src/schemas/user.schema.ts
Properties: uses Zod validation
[pattern] runtime-validation
Properties: Use Zod for all runtime checks
[function] validateUserInput
Properties: Located in src/services/user.service.ts
Relationships (2 matches):
src/services/user.service.ts --uses--> src/schemas/user.schema.ts
src/routes/user.routes.ts --uses--> validateUserInput
Insights (2 matches):
- "Use Zod for runtime validation" (Ć2)
Tags: validation, zod, patterns
- "Validate inputs at API boundaries"
Tags: validation, api, security
/ralph-memory insights
Output:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā All Insights ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
By Frequency:
1. "Always export new types from index.ts" (Ć5)
Tags: types, exports, patterns
Context: Multiple type definition tasks
2. "Use Zod for runtime validation" (Ć3)
Tags: validation, zod
Context: User input validation
3. "Prefer async/await over raw promises" (Ć2)
Tags: async, patterns
Context: Service layer implementation
By Tag:
[patterns] 5 insights
[types] 3 insights
[validation] 3 insights
[testing] 2 insights
[security] 1 insight
/ralph-memory add-insight "Database migrations should be run before tests"
Use AskUserQuestion:
? What was the context for this learning?
> Running integration tests
? Add tags (comma-separated):
> database, migrations, testing
Output:
ā Insight added:
"Database migrations should be run before tests"
Context: Running integration tests
Tags: database, migrations, testing
/ralph-memory export
Output:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Memory Export ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Exporting to: .ralph/memory-export-2026-01-25.json
Contents:
- 45 entities
- 67 relationships
- 15 insights
ā Export complete
This file can be:
- Shared with team members
- Imported into another project
- Backed up for safety
/ralph-memory cleanup
Output:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Memory Cleanup ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Analyzing memory entries older than 90 days...
Candidates for removal:
- 5 entities (not referenced in 90+ days)
- 8 relationships (orphaned)
- 2 insights (single occurrence, old)
? Proceed with cleanup?
ā Yes, remove old entries
ā No, keep everything
Cleanup Results:
ā Removed 5 entities
ā Removed 8 relationships
ā Kept 15 insights (frequently occurring)
Memory size reduced by 12%
Queries memory before planning:
Loading memory context...
Relevant patterns found:
- "Use service layer pattern for business logic"
- "Separate types from implementation"
Past similar implementations:
- US-005: User authentication (similar patterns)
- US-012: Payment processing (related concepts)
Applying learnings to plan...
Logs patterns during implementation:
Implementation complete.
Insights logged:
+ "This project uses barrel exports (index.ts)"
+ "Error handling uses custom AppError class"
Entities tracked:
+ [file] src/services/payment.service.ts
+ [function] processPayment
+ [function] validateCard
Logs recurring issues:
QA validation complete.
Recurring issues detected:
ā "Missing exports" - 3rd occurrence
ā Consider adding to pre-commit hook
Insight logged:
+ "Export statements should be added immediately after creating types"
Agents include memory context in their prompts:
## Memory Context
### Relevant Insights
- "Always export new types from index.ts"
- "Use Zod for runtime validation"
- "Prefer async/await over raw promises"
### Related Entities
- src/types/user.ts (exports User, CreateUserInput)
- src/schemas/user.schema.ts (Zod validation)
### Past Patterns
- Service layer pattern used in src/services/
- Repository pattern for data access
| Error | Action |
|---|---|
| Memory not initialized | Run initMemory() automatically |
| Query returns nothing | Suggest broader search terms |
| Export fails | Check disk space, permissions |
| Cleanup too aggressive | Offer to restore from backup |