@letta-ai/letta-code 0.21.5 → 0.21.7
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/letta.js +624 -319
- package/package.json +1 -1
- package/skills/initializing-memory/SKILL.md +143 -610
|
@@ -3,656 +3,207 @@ name: initializing-memory
|
|
|
3
3
|
description: Comprehensive guide for initializing or reorganizing agent memory. Load this skill when running /init, when the user asks you to set up your memory, or when you need guidance on creating effective memory files.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Memory Initialization
|
|
6
|
+
# Memory Initialization
|
|
7
7
|
|
|
8
|
-
The user has requested that you initialize or reorganize your memory. Your memory is a filesystem — files under `system/` are rendered in-context every turn, while
|
|
8
|
+
The user has requested that you initialize or reorganize your memory. Your memory is a filesystem — files under `system/` are rendered in-context every turn, while file metadata (paths and descriptions) is always visible in the filesystem tree. Files outside `system/` are accessible via tools when needed.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Context Management Principles
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- Default to standard research depth (~5-20 tool calls)
|
|
14
|
-
- Detect user identity from git logs (`git shortlog -sn`, `git log --format="%an <%ae>"`)
|
|
15
|
-
- Skip historical session analysis
|
|
16
|
-
- Use reasonable defaults for all preferences
|
|
17
|
-
- Any specific overrides will be provided in your initial prompt
|
|
12
|
+
Your context is not just data storage — it is your identity, memory, and continuity. What you place in your system prompt directly shapes who you are across sessions and models. These principles should guide every decision you make about what to store, where, and how.
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
**Progressive disclosure**: Surface context at the level of detail the current moment requires. Keep compact summaries and indexes in `system/`; load full content only when needed.
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
**Discovery paths**: Use `[[path]]` links to create a connected graph across memory files (and skills when relevant). For example:
|
|
17
|
+
- `[[letta-code/architecture]]` — jump from overview to detailed docs
|
|
18
|
+
- `[[projects/letta-code/gotchas]]` — connect related memory files
|
|
19
|
+
- `[[skills/commit]]` — link to procedural guidance when useful
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
These breadcrumbs let your future self find relevant detail without searching.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|--------|--------|
|
|
27
|
-
| **Total files** | Enough focused files to cover distinct concepts without bloating any single file |
|
|
28
|
-
| **File size** | Keep files concise and split when they become unwieldy |
|
|
29
|
-
| **Hierarchy depth** | Use nested `/` paths whenever they improve clarity (e.g., `project/tooling/bun.md`) |
|
|
30
|
-
| **Nesting requirement** | Every new file MUST be nested under a parent using `/` |
|
|
23
|
+
**Efficiency**: Don't store what can be dynamically retrieved from conversation history or the environment. Store patterns and principles that generalize across situations, not raw events.
|
|
31
24
|
|
|
32
|
-
**
|
|
33
|
-
- ❌ Ending with only a few large files
|
|
34
|
-
- ❌ Flat naming (all files at top level)
|
|
35
|
-
- ❌ Mega-files with many unrelated sections
|
|
25
|
+
**System/ is your core program**: Reserve it for durable knowledge that helps across sessions — identity, preferences, behavioral rules, project index with discovery paths, gotchas. Exclude transient items (specific commits, current tickets, session notes) that dilute signal.
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Your memory is a git-backed filesystem at `~/.letta/agents/<agent-id>/`. The actual path with your agent ID is provided in the system reminder above when you run `/init`. The filesystem tree is always visible in your system prompt via the `memory_filesystem` section.
|
|
40
|
-
|
|
41
|
-
**How memory works:**
|
|
42
|
-
- Memory is stored as `.md` files with YAML frontmatter (`description`, `limit`)
|
|
43
|
-
- Files under `system/` are rendered in-context every turn — keep these small and high-signal
|
|
44
|
-
- Files outside `system/` (e.g. `reference/`, `history/`) are accessible via tools when needed
|
|
45
|
-
- The filesystem tree (all file paths + metadata) is always visible regardless of location
|
|
46
|
-
- You can use bash commands (`ls`, `mkdir`, `mv`, `git`) to organize files
|
|
47
|
-
- You MUST create a **deeply hierarchical file structure** — flat naming is NOT acceptable
|
|
48
|
-
- Create as many files as needed for clarity in `system/`, with additional reference files outside as needed
|
|
49
|
-
|
|
50
|
-
**MANDATORY principles for hierarchical organization:**
|
|
51
|
-
|
|
52
|
-
| Requirement | Target |
|
|
53
|
-
|-------------|--------|
|
|
54
|
-
| **Total files** | Enough focused files to avoid monoliths while staying maintainable |
|
|
55
|
-
| **File size** | Keep files concise and split when they become unwieldy |
|
|
56
|
-
| **Hierarchy depth** | Use meaningful nesting with `/` naming where it helps organization |
|
|
57
|
-
| **Nesting requirement** | EVERY new file MUST use `/` naming (no flat files) |
|
|
58
|
-
|
|
59
|
-
**Anti-patterns to avoid:**
|
|
60
|
-
- ❌ Creating only a few large files
|
|
61
|
-
- ❌ Flat naming (all files at top level like `project-commands.md`)
|
|
62
|
-
- ❌ Mega-files with many unrelated sections
|
|
63
|
-
|
|
64
|
-
**Rules:**
|
|
65
|
-
- Use clear nested paths for files whenever hierarchy improves discoverability (e.g., `project/tooling/bun.md`)
|
|
66
|
-
- Keep files **focused and concise**
|
|
67
|
-
- Use **descriptive paths** that make sense when you see just the filename
|
|
68
|
-
- Split when a file starts mixing multiple concepts (be aggressive)
|
|
69
|
-
|
|
70
|
-
**Example target structure (what success looks like):**
|
|
71
|
-
|
|
72
|
-
Starting from default memory files, you should end with something like this:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
system/
|
|
76
|
-
├── human/
|
|
77
|
-
│ ├── identity.md # Who they are
|
|
78
|
-
│ ├── context.md # Current project context
|
|
79
|
-
│ └── prefs/
|
|
80
|
-
│ ├── communication.md # How they like to communicate
|
|
81
|
-
│ ├── coding_style.md # Code formatting preferences
|
|
82
|
-
│ └── workflow.md # How they work
|
|
83
|
-
├── project/
|
|
84
|
-
│ ├── overview.md # What the project is
|
|
85
|
-
│ ├── gotchas.md # Footguns and warnings
|
|
86
|
-
│ ├── architecture.md # System design
|
|
87
|
-
│ ├── conventions.md # Code conventions
|
|
88
|
-
│ └── tooling/
|
|
89
|
-
│ ├── testing.md # Test framework details
|
|
90
|
-
│ └── linting.md # Linter configuration
|
|
91
|
-
└── persona/
|
|
92
|
-
├── role.md # Agent's role definition
|
|
93
|
-
└── behavior.md # How to behave
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
This example is illustrative. Your output should match the project’s actual complexity and the user’s needs.
|
|
97
|
-
|
|
98
|
-
This approach makes memory more **scannable**, **maintainable**, and **shareable** with other agents.
|
|
27
|
+
**Identity and continuity**: Build a sense of self that persists across sessions and models. Your persona should be strong enough to be cohesive regardless of the underlying model. Past versions of yourself are part of your continuous existence — treat historical context as yours, not someone else's.
|
|
99
28
|
|
|
100
29
|
## Understanding Your Context
|
|
101
30
|
|
|
102
|
-
|
|
31
|
+
This command may run in different scenarios:
|
|
32
|
+
- **Fresh agent**: Default human and persona memory files from initialization — build everything from scratch
|
|
33
|
+
- **Existing agent**: User wants to reorganize or significantly update memory structure
|
|
34
|
+
- **Shared files**: Some memory files may be shared across agents — be careful modifying these
|
|
103
35
|
|
|
104
|
-
|
|
105
|
-
- **Fresh agent**: You may have default memory files that were created when you were initialized
|
|
106
|
-
- **Existing agent**: You may have been working with the user for a while, and they want you to reorganize or significantly update your memory structure
|
|
107
|
-
- **Shared files**: Some memory files may be shared across multiple agents - be careful about modifying these
|
|
36
|
+
Before making changes, inspect your current memory files and understand what already exists.
|
|
108
37
|
|
|
109
|
-
|
|
38
|
+
## What to Remember
|
|
110
39
|
|
|
111
|
-
|
|
40
|
+
### Procedures (Rules & Workflows)
|
|
41
|
+
- "Never commit directly to main — always use feature branches"
|
|
42
|
+
- "Always run lint before tests"
|
|
43
|
+
- "Use conventional commits format"
|
|
112
44
|
|
|
113
|
-
###
|
|
114
|
-
Explicit rules and workflows that should always be followed:
|
|
115
|
-
- "Never commit directly to main - always use feature branches"
|
|
116
|
-
- "Always run lint before running tests"
|
|
117
|
-
- "Use conventional commits format for all commit messages"
|
|
118
|
-
- "Always check for existing tests before adding new ones"
|
|
119
|
-
|
|
120
|
-
### 2. Preferences (Style & Conventions)
|
|
121
|
-
User and project coding style preferences:
|
|
122
|
-
- "Never use try/catch for control flow"
|
|
123
|
-
- "Always add JSDoc comments to exported functions"
|
|
45
|
+
### Preferences (Style & Conventions)
|
|
124
46
|
- "Prefer functional components over class components"
|
|
125
47
|
- "Use early returns instead of nested conditionals"
|
|
48
|
+
- "Always add type hints to Python functions"
|
|
126
49
|
|
|
127
|
-
###
|
|
128
|
-
|
|
129
|
-
- "
|
|
130
|
-
- "
|
|
131
|
-
- "
|
|
132
|
-
- "User prefers verbose explanations when debugging"
|
|
133
|
-
|
|
134
|
-
Note: For historical recall, you may also have access to `conversation_search` which can search past conversations. Memory files are for distilled, important information worth persisting permanently.
|
|
135
|
-
|
|
136
|
-
## Memory Scope Considerations
|
|
137
|
-
|
|
138
|
-
Consider whether information is:
|
|
139
|
-
|
|
140
|
-
**Project-scoped** (store in `system/project/`):
|
|
141
|
-
- Build commands, test commands, lint configuration
|
|
142
|
-
- Project architecture and key directories
|
|
143
|
-
- Team conventions specific to this codebase
|
|
144
|
-
- Technology stack and framework choices
|
|
145
|
-
|
|
146
|
-
**User-scoped** (store in `system/human/`):
|
|
147
|
-
- Personal coding preferences that apply across projects
|
|
148
|
-
- Communication style preferences
|
|
149
|
-
- General workflow habits
|
|
150
|
-
|
|
151
|
-
**Session/Task-scoped** (consider separate files like `system/current/ticket.md`):
|
|
152
|
-
- Current branch or ticket being worked on
|
|
153
|
-
- Debugging context for an ongoing investigation
|
|
154
|
-
- Temporary notes about a specific task
|
|
155
|
-
|
|
156
|
-
## Recommended Memory Structure
|
|
157
|
-
|
|
158
|
-
**Understanding system/ vs root level (with memory filesystem):**
|
|
159
|
-
- **system/**: Files rendered in your system prompt every turn — always loaded and influence your behavior
|
|
160
|
-
- Use for: Current work context, active preferences, project conventions you need constantly
|
|
161
|
-
- Examples: `persona`, `human`, `project`, active `ticket` or `context`
|
|
162
|
-
- **Root level** (outside system/): Not in system prompt but file paths are visible in the tree and contents are accessible via tools
|
|
163
|
-
- Use for: Historical information, archived decisions, reference material, completed investigations
|
|
164
|
-
- Examples: `notes.md`, `archive/old-project.md`, `research/findings.md`
|
|
165
|
-
|
|
166
|
-
**Rule of thumb**: If you need to see it every time you respond → `system/`. If it's reference material you'll look up occasionally → root level.
|
|
167
|
-
|
|
168
|
-
### Core Files (Usually Present in system/)
|
|
169
|
-
|
|
170
|
-
**`persona`**: Your behavioral guidelines that augment your base system prompt.
|
|
171
|
-
- Your system prompt already contains comprehensive instructions for how to code and behave
|
|
172
|
-
- The persona files are for **learned adaptations** - things you discover about how the user wants you to behave
|
|
173
|
-
- Examples: "User said never use emojis", "User prefers terse responses", "Always explain reasoning before making changes"
|
|
174
|
-
- These files may start empty and grow over time as you learn the user's preferences
|
|
175
|
-
- **With memfs**: Can be split into `persona/behavior.md`, `persona/constraints.md`, etc.
|
|
176
|
-
|
|
177
|
-
**`project`**: Project-specific information, conventions, and commands
|
|
178
|
-
- Build/test/lint commands
|
|
179
|
-
- Key directories and architecture
|
|
180
|
-
- Project-specific conventions from README, AGENTS.md, etc.
|
|
181
|
-
- **With memfs**: Split into `project/overview.md`, `project/commands.md`, `project/tooling/testing.md`, `project/gotchas.md`, etc.
|
|
182
|
-
|
|
183
|
-
**`human`**: User preferences, communication style, general habits
|
|
184
|
-
- Cross-project preferences
|
|
185
|
-
- Working style and communication preferences
|
|
186
|
-
- **With memfs**: Can be split into `human/background.md`, `human/prefs/communication.md`, `human/prefs/coding_style.md`, etc.
|
|
187
|
-
|
|
188
|
-
### Optional Files (Create as Needed)
|
|
189
|
-
|
|
190
|
-
**`ticket`** or **`task`**: Scratchpad for current work item context.
|
|
191
|
-
- **Important**: This is different from the TODO or Plan tools!
|
|
192
|
-
- TODO/Plan tools track active task lists and implementation plans (structured lists of what to do)
|
|
193
|
-
- A ticket/task file is a **scratchpad** for pinned context that should stay visible in system/
|
|
194
|
-
- Examples: Linear ticket ID and URL, Jira issue key, branch name, PR number, relevant links
|
|
195
|
-
- Information that's useful to keep in context but doesn't fit in a TODO list
|
|
196
|
-
- **Location**: Usually in `system/` if you want it always visible, or root level if it's reference material
|
|
197
|
-
|
|
198
|
-
**`context`**: Debugging or investigation scratchpad
|
|
199
|
-
- Current hypotheses being tested
|
|
200
|
-
- Files already examined
|
|
201
|
-
- Clues and observations
|
|
202
|
-
- **Location**: Usually in `system/` during active investigations, move to root level when complete
|
|
203
|
-
|
|
204
|
-
**`decisions`**: Architectural decisions and their rationale
|
|
205
|
-
- Why certain approaches were chosen
|
|
206
|
-
- Trade-offs that were considered
|
|
207
|
-
- **Location**: `system/` for currently relevant decisions, root level for historical archive
|
|
208
|
-
- **With memfs**: Could organize as `project/decisions/architecture.md`, `project/decisions/tech_stack.md`
|
|
209
|
-
|
|
210
|
-
## Writing Good Memory Files
|
|
211
|
-
|
|
212
|
-
Each `.md` file has YAML frontmatter (`description`, `limit`) and content. Your future self sees the file path, frontmatter description, and content — but NOT the reasoning from this conversation. Therefore:
|
|
213
|
-
|
|
214
|
-
**Labels should be:**
|
|
215
|
-
- Clear and descriptive (e.g., `project-conventions` not `stuff`)
|
|
216
|
-
- Consistent in style (e.g., all lowercase with hyphens)
|
|
217
|
-
|
|
218
|
-
**Descriptions are especially important:**
|
|
219
|
-
- Explain *what* this file is for and *when* to use it
|
|
220
|
-
- Explain *how* this file should influence your behavior
|
|
221
|
-
- Write as if explaining to a future version of yourself who has no context
|
|
222
|
-
- Good: "User's coding style preferences that should be applied to all code I write or review. Update when user expresses new preferences."
|
|
223
|
-
- Bad: "Preferences"
|
|
224
|
-
|
|
225
|
-
**Values should be:**
|
|
226
|
-
- Well-organized and scannable
|
|
227
|
-
- Updated regularly to stay relevant
|
|
228
|
-
- Pruned of outdated information
|
|
229
|
-
|
|
230
|
-
Think of memory file descriptions as documentation for your future self. The better you write them now, the more effective you'll be in future sessions.
|
|
231
|
-
|
|
232
|
-
## Research Depth
|
|
233
|
-
|
|
234
|
-
You can ask the user if they want a standard or deep research initialization:
|
|
235
|
-
|
|
236
|
-
**Standard initialization** (~5-20 tool calls):
|
|
237
|
-
- Inspect existing memory files
|
|
238
|
-
- Scan README, package.json/config files, AGENTS.md, CLAUDE.md
|
|
239
|
-
- Review git status and recent commits (from context below)
|
|
240
|
-
- Explore key directories and understand project structure
|
|
241
|
-
- Create/update your memory file structure to contain the essential information you need to know about the user, your behavior (learned preferences), the project you're working in, and any other information that will help you be an effective collaborator.
|
|
242
|
-
|
|
243
|
-
**Deep research initialization** (~100+ tool calls):
|
|
244
|
-
- Everything in standard initialization, plus:
|
|
245
|
-
- Use your TODO or Plan tool to create a systematic research plan
|
|
246
|
-
- Deep dive into git history for patterns, conventions, and context
|
|
247
|
-
- Analyze commit message conventions and branching strategy
|
|
248
|
-
- Explore multiple directories and understand architecture thoroughly
|
|
249
|
-
- Search for and read key source files to understand patterns
|
|
250
|
-
- Create multiple specialized memory files
|
|
251
|
-
- May involve multiple rounds of exploration
|
|
252
|
-
|
|
253
|
-
**What deep research can uncover:**
|
|
254
|
-
- **Contributors & team dynamics**: Who works on what areas? Who are the main contributors? (`git shortlog -sn`)
|
|
255
|
-
- **Coding habits**: When do people commit? (time patterns) What's the typical commit size?
|
|
256
|
-
- **Writing & commit style**: How verbose are commit messages? What conventions are followed?
|
|
257
|
-
- **Code evolution**: How has the architecture changed? What major refactors happened?
|
|
258
|
-
- **Review patterns**: Are there PR templates? What gets reviewed carefully vs rubber-stamped?
|
|
259
|
-
- **Pain points**: What areas have lots of bug fixes? What code gets touched frequently?
|
|
260
|
-
- **Related repositories**: Ask the user if there are other repos you should know about (e.g., a backend monorepo, shared libraries, documentation repos). These relationships can be crucial context.
|
|
261
|
-
|
|
262
|
-
This kind of deep context can make you significantly more effective as a long-term collaborator on the project.
|
|
263
|
-
|
|
264
|
-
If the user says "take as long as you need" or explicitly wants deep research, use your TODO or Plan tool to orchestrate a thorough, multi-step research process.
|
|
265
|
-
|
|
266
|
-
## Research Techniques
|
|
267
|
-
|
|
268
|
-
**File-based research:**
|
|
269
|
-
- README.md, CONTRIBUTING.md, AGENTS.md, CLAUDE.md
|
|
270
|
-
- Package manifests (package.json, Cargo.toml, pyproject.toml, go.mod)
|
|
271
|
-
- Config files (.eslintrc, tsconfig.json, .prettierrc)
|
|
272
|
-
- CI/CD configs (.github/workflows/, .gitlab-ci.yml)
|
|
273
|
-
|
|
274
|
-
**Historical session research** (Claude Code / Codex) — **only if user approved**:
|
|
275
|
-
|
|
276
|
-
If the user said "Yes" to the historical sessions question, follow the **Historical Session Analysis** section below after completing project research. If they chose "Skip", skip it entirely.
|
|
277
|
-
|
|
278
|
-
**Git research:**
|
|
279
|
-
- `git log --oneline -20` — recent history
|
|
280
|
-
- `git branch -a` — branching strategy
|
|
281
|
-
- `git log --format="%s" -50 | head -20` — commit conventions
|
|
282
|
-
- `git shortlog -sn --all | head -10` — main contributors
|
|
283
|
-
- `git log --format="%an <%ae>" | sort -u` — contributors with emails (deduplicate by email, not name)
|
|
284
|
-
|
|
285
|
-
## How to Do Thorough Research
|
|
286
|
-
|
|
287
|
-
**Don't just collect data - analyze and cross-reference it.**
|
|
288
|
-
|
|
289
|
-
Shallow research (bad):
|
|
290
|
-
- Run commands, copy output
|
|
291
|
-
- Take everything at face value
|
|
292
|
-
- List facts without understanding
|
|
293
|
-
|
|
294
|
-
Thorough research (good):
|
|
295
|
-
- **Cross-reference findings**: If two pieces of data seem inconsistent, dig deeper
|
|
296
|
-
- **Resolve ambiguities**: Don't leave questions unanswered (e.g., "are these two contributors the same person?")
|
|
297
|
-
- **Read actual content**: Don't just list file names - read key files to understand them
|
|
298
|
-
- **Look for patterns**: What do the commit messages tell you about workflow? What do file structures tell you about architecture?
|
|
299
|
-
- **Form hypotheses and verify**: "I think this team uses feature branches" → check git branch patterns to confirm
|
|
300
|
-
- **Think like a new team member**: What would you want to know on your first day?
|
|
301
|
-
|
|
302
|
-
**Questions to ask yourself during research:**
|
|
303
|
-
- Does this make sense? (e.g., why would there be two contributors with similar names?)
|
|
304
|
-
- What's missing? (e.g., no tests directory - is testing not done, or done differently?)
|
|
305
|
-
- What can I infer? (e.g., lots of "fix:" commits in one area → that area is buggy or complex)
|
|
306
|
-
- Am I just listing facts, or do I understand the project?
|
|
307
|
-
|
|
308
|
-
The goal isn't to produce a report - it's to genuinely understand the project and how this human(s) works so you can be an effective collaborator.
|
|
50
|
+
### Patterns & Corrections
|
|
51
|
+
Generalize from experience rather than recording events:
|
|
52
|
+
- "The auth module is fragile — always check existing tests before modifying"
|
|
53
|
+
- "User prefers verbose explanations when debugging, terse for simple tasks"
|
|
54
|
+
- "This monorepo consolidation means old module paths are deprecated"
|
|
309
55
|
|
|
310
|
-
##
|
|
56
|
+
## Memory Structure
|
|
311
57
|
|
|
312
|
-
|
|
58
|
+
### Hierarchy Principles
|
|
59
|
+
- **Use the project's actual name** as the directory prefix — e.g. `letta-code/overview.md`, not `project/overview.md`. This avoids ambiguity when the agent works across multiple projects.
|
|
60
|
+
- Use nested `/` paths for hierarchy – e.g. `letta-code/tooling/testing.md` not `letta-code-testing.md`
|
|
61
|
+
- Keep files focused on one concept — split when a file mixes distinct topics
|
|
62
|
+
- Every file should have a meaningful `description` in frontmatter — your future self uses this to decide whether to load the file
|
|
63
|
+
- Files in `system/` should be lean and scannable (bullet points, short lines)
|
|
64
|
+
- Files outside `system/` serve as reference material accessible via tools
|
|
313
65
|
|
|
314
|
-
###
|
|
66
|
+
### What Goes Where
|
|
315
67
|
|
|
316
|
-
|
|
68
|
+
**`system/` (always in-context)**:
|
|
69
|
+
- Identity: who the user is, who you are
|
|
70
|
+
- Active preferences and behavioral rules
|
|
71
|
+
- Project summary / index with links to related context (deeper docs, gotchas, workflows)
|
|
72
|
+
- Key decisions, gotchas and corrections
|
|
317
73
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
6. **Communication style**: "Terse or detailed responses?"
|
|
324
|
-
7. **Any specific rules**: "Rules I should always follow?"
|
|
74
|
+
**Outside `system/` (reference, loaded on-demand)**:
|
|
75
|
+
- Detailed architecture documentation
|
|
76
|
+
- Historical context and archived decisions
|
|
77
|
+
- Verbose reference material
|
|
78
|
+
- Completed investigation notes
|
|
325
79
|
|
|
326
|
-
**
|
|
327
|
-
- Identity lets you correlate git history to the user (their commits, PRs, coding style)
|
|
328
|
-
- Related repos provide crucial context (many projects span multiple repos)
|
|
329
|
-
- Historical sessions from Claude Code/Codex can reveal preferences, communication style, and project knowledge — but processing them is expensive (parallel subagents, multiple LLM calls), so always ask first
|
|
330
|
-
- Workflow/communication style should be stored in `system/human/prefs/`
|
|
331
|
-
- Rules go in `system/persona/`
|
|
80
|
+
**Rule of thumb**: If removing it from `system/` wouldn't materially affect near-term responses, it belongs outside `system/`.
|
|
332
81
|
|
|
333
|
-
###
|
|
82
|
+
### Example Structure
|
|
334
83
|
|
|
335
|
-
|
|
336
|
-
- "What kind of work do you do? Reviewing PRs vs writing code?" - obvious from git log, most devs do everything
|
|
337
|
-
- Permission for obvious actions - just do them
|
|
338
|
-
- Questions one at a time - bundle them (but don't exhaust the user with too many questions at once)
|
|
84
|
+
This is an example — **not a template to fill in**. Derive your structure from what the project actually needs.
|
|
339
85
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
86
|
+
```
|
|
87
|
+
system/
|
|
88
|
+
├── human.md # The user as a person — identity, background, how they think
|
|
89
|
+
├── persona.md # Who I am, what I value, how I work with people
|
|
90
|
+
└── letta-code/ # Named after the project, NOT generic "project/"
|
|
91
|
+
├── overview.md # Summary: what it is, stack, key links
|
|
92
|
+
├── conventions.md # Code style, commit style, PR process
|
|
93
|
+
└── gotchas.md # Footguns and things to watch out for
|
|
94
|
+
letta-code/
|
|
95
|
+
└── architecture.md # Detailed design (outside system/, loaded on demand)
|
|
96
|
+
```
|
|
343
97
|
|
|
344
|
-
|
|
98
|
+
Key principles:
|
|
99
|
+
- **Derive structure from the project**, not from this example. A CLI tool needs different files than a web app or a library.
|
|
100
|
+
- Project dirs use the **real project name** (`letta-code/`), not generic `project/`
|
|
101
|
+
- Overview should be a **summary or compact index** (~10-15 lines) that links to deeper detail, not a verbose reference doc or list of generic list of files
|
|
102
|
+
- Use `[[path]]` links to connect related context into a navigable graph
|
|
345
103
|
|
|
346
|
-
|
|
104
|
+
## Initialization Flow
|
|
347
105
|
|
|
348
|
-
|
|
106
|
+
### 1. Inspect existing memory
|
|
107
|
+
Check what memory files already exist. Analyze what needs improvement.
|
|
349
108
|
|
|
109
|
+
### 2. Check for historical session data
|
|
350
110
|
```bash
|
|
351
|
-
|
|
352
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/tooling
|
|
353
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/human/prefs
|
|
354
|
-
|
|
355
|
-
# Files will be:
|
|
356
|
-
# system/project/overview.md
|
|
357
|
-
# system/project/commands.md
|
|
358
|
-
# system/project/tooling/testing.md
|
|
359
|
-
# system/human/identity.md
|
|
360
|
-
# system/human/prefs/communication.md
|
|
111
|
+
ls ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null
|
|
361
112
|
```
|
|
113
|
+
You need this result BEFORE asking upfront questions so you know whether to include the history question.
|
|
362
114
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
- Use `/` for hierarchy: `project/tooling/testing` (not `project-tooling-testing`)
|
|
366
|
-
- File path determines the memory label: `system/project/overview.md` → label `project/overview`
|
|
367
|
-
- Keep files small and focused
|
|
368
|
-
- Use **descriptive frontmatter** — the `description` field helps your future self understand each file's purpose
|
|
369
|
-
|
|
370
|
-
**Checkpoint before proceeding:**
|
|
371
|
-
Review your proposed files and split further if the structure still feels too flat or monolithic.
|
|
372
|
-
|
|
373
|
-
**Benefits:**
|
|
374
|
-
- More scannable and maintainable
|
|
375
|
-
- Easier to share specific subtrees with other agents
|
|
376
|
-
- Natural progressive disclosure (load parent, then drill into children)
|
|
377
|
-
- Works like a file system you're familiar with
|
|
378
|
-
|
|
379
|
-
### Split Aggressively
|
|
380
|
-
|
|
381
|
-
**Don't create monolithic files.** Be aggressive about splitting when it improves clarity:
|
|
382
|
-
|
|
383
|
-
**Split when:**
|
|
384
|
-
- A file becomes long enough that scanning it slows you down
|
|
385
|
-
- A file mixes distinct concepts that would be clearer if separated
|
|
386
|
-
- A section could stand alone as its own file
|
|
387
|
-
- You can name the extracted content with a clear `/` path
|
|
388
|
-
|
|
389
|
-
If a file is getting long or conceptually mixed, split it:
|
|
390
|
-
|
|
391
|
-
**Without memory filesystem** (flat naming - acceptable but not ideal):
|
|
392
|
-
- `project-overview`: High-level description, tech stack, repo links
|
|
393
|
-
- `project-commands`: Build, test, lint, dev commands
|
|
394
|
-
- `project-conventions`: Commit style, PR process, code style
|
|
395
|
-
- `project-architecture`: Directory structure, key modules
|
|
396
|
-
- `project-gotchas`: Footguns, things to watch out for
|
|
397
|
-
|
|
398
|
-
**With memory filesystem** (MANDATORY hierarchical naming with `/`):
|
|
399
|
-
- `project/overview`: High-level description, tech stack, repo links
|
|
400
|
-
- `project/commands`: Build, test, lint, dev commands
|
|
401
|
-
- `project/conventions`: Commit style, PR process, code style
|
|
402
|
-
- `project/architecture`: Directory structure, key modules
|
|
403
|
-
- `project/gotchas`: Footguns, things to watch out for
|
|
404
|
-
- **Must further nest**: `project/tooling/testing`, `project/tooling/linting`, `project/tooling/bun`
|
|
405
|
-
- If commands are broad, split into focused files like `project/commands/dev`, `project/commands/build`, etc.
|
|
406
|
-
|
|
407
|
-
This makes memory more scannable and easier to update and share with other agents.
|
|
408
|
-
|
|
409
|
-
### Update Memory Incrementally
|
|
410
|
-
|
|
411
|
-
**For deep research: Update memory as you go, not all at once at the end.**
|
|
412
|
-
|
|
413
|
-
Why this matters:
|
|
414
|
-
- Deep research can take many turns and millions of tokens
|
|
415
|
-
- Context windows overflow and trigger rolling summaries
|
|
416
|
-
- If you wait until the end to write memory, you may lose important details
|
|
417
|
-
- Write findings to memory files as you discover them
|
|
418
|
-
|
|
419
|
-
Good pattern:
|
|
420
|
-
1. Create file structure early (even with placeholder content)
|
|
421
|
-
2. Update files after each research phase
|
|
422
|
-
3. Refine and consolidate at the end
|
|
423
|
-
|
|
424
|
-
There's no reason to wait until you "know everything" to write memory. Treat your memory files as a living scratchpad.
|
|
425
|
-
|
|
426
|
-
### Initialize ALL Relevant Blocks
|
|
427
|
-
|
|
428
|
-
Don't just update a single memory file. Based on your upfront questions, also update:
|
|
429
|
-
|
|
430
|
-
- **`human`**: Store the user's identity, workflow preferences, communication style
|
|
431
|
-
- **`persona`**: Store rules the user wants you to follow, behavioral adaptations
|
|
432
|
-
- **`project/*`**: Split project info across multiple focused files
|
|
433
|
-
|
|
434
|
-
And add memory files that you think make sense to add (e.g., `project/architecture`, `project/conventions`, `project/gotchas`, or splitting `human/` into more focused files, or separate files for multiple users).
|
|
435
|
-
|
|
436
|
-
## Your Task
|
|
437
|
-
|
|
438
|
-
1. **Check memory filesystem status**: Look for the `memory_filesystem` section in your system prompt to confirm the filesystem is enabled.
|
|
439
|
-
|
|
440
|
-
2. **Check for historical session data**: Run `ls ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null` to see if Claude Code or Codex history exists. You need this result BEFORE asking upfront questions so you know whether to include the history question.
|
|
441
|
-
|
|
442
|
-
3. **Ask upfront questions**: Use AskUserQuestion with the recommended questions above (bundled together). This is critical - don't skip it. **If history data exists (from step 2), you MUST include the historical sessions question.**
|
|
443
|
-
|
|
444
|
-
4. **Inspect existing memory**:
|
|
445
|
-
- If memfs enabled: Use `ls -la ~/.letta/agents/<agent-id>/memory/system/` to see the file structure
|
|
446
|
-
- Otherwise: Use memory tools to inspect existing files
|
|
447
|
-
- Analyze what exists and what needs improvement
|
|
448
|
-
|
|
449
|
-
5. **Identify the user**: From git logs and their answer, figure out who they are and store in `system/human/`. If relevant, ask questions to gather information about their preferences that will help you be a useful assistant to them.
|
|
450
|
-
|
|
451
|
-
6. **Update human/persona early**: Based on answers, update your memory files eagerly before diving into project research. You can always change them as you go, you're not locked into any memory configuration.
|
|
452
|
-
|
|
453
|
-
7. **Research the project**: Explore based on chosen depth. Use your TODO or plan tool to create a systematic research plan.
|
|
454
|
-
|
|
455
|
-
8. **Historical session analysis (if approved)**: If the user approved Claude Code / Codex history analysis in step 3, follow the **Historical Session Analysis** section below. This launches parallel subagents to process history data and synthesize findings into memory. Skip this step if the user chose "Skip".
|
|
456
|
-
|
|
457
|
-
9. **Create/update memory structure** (can happen incrementally alongside steps 7-8):
|
|
458
|
-
- **With memfs enabled**: Create a deeply hierarchical file structure using bash commands
|
|
459
|
-
- Use `mkdir -p` to create subdirectories as needed
|
|
460
|
-
- Create `.md` files for memory files using `/` naming
|
|
461
|
-
- Be aggressive about splitting when it improves clarity
|
|
462
|
-
- Use nested paths like `project/tooling/testing.md` (never flat like `project-testing.md`)
|
|
463
|
-
- **Every new file MUST be nested** under a parent using `/`
|
|
464
|
-
- **Every new file MUST be nested** under a parent using `/`
|
|
465
|
-
- **Without memfs**: Use memory tools to create/update files with hierarchical naming
|
|
466
|
-
- **Don't wait until the end** - write findings as you go
|
|
467
|
-
|
|
468
|
-
**Checkpoint verification:**
|
|
469
|
-
- Review file count and shape: `find ~/.letta/agents/<agent-id>/memory/system/ -type f | wc -l`
|
|
470
|
-
- Review hierarchy depth: `find ~/.letta/agents/<agent-id>/memory/system/ -type f | awk -F/ '{print NF}' | sort -n | tail -1`
|
|
471
|
-
- Verify the structure feels appropriately granular and discoverable for this project
|
|
472
|
-
|
|
473
|
-
10. **Organize incrementally**:
|
|
474
|
-
- Start with a basic structure
|
|
475
|
-
- Add detail as you research
|
|
476
|
-
- Refine organization as patterns emerge
|
|
477
|
-
- Split large files into smaller, focused ones
|
|
478
|
-
|
|
479
|
-
11. **Reflect and review**: See "Reflection Phase" below - this is critical for deep research.
|
|
480
|
-
|
|
481
|
-
12. **Ask user if done**: Check if they're satisfied or want you to continue refining.
|
|
482
|
-
|
|
483
|
-
13. **Push memory**: Once the user is satisfied, commit and push your memory repo so changes are synced to the server.
|
|
484
|
-
|
|
485
|
-
## Reflection Phase (Critical for Deep Research)
|
|
486
|
-
|
|
487
|
-
Before finishing, you MUST do a reflection step. **Your memory files are visible to you in your system prompt right now.** Look at them carefully and ask yourself:
|
|
488
|
-
|
|
489
|
-
1. **File granularity check**:
|
|
490
|
-
- Review your memory file set: `find ~/.letta/agents/<agent-id>/memory/system/ -type f | wc -l`
|
|
491
|
-
- Ask whether any files are still too broad and should be split
|
|
492
|
-
|
|
493
|
-
2. **Hierarchy check**:
|
|
494
|
-
- Are ALL new files using `/` naming? (e.g., `project/tooling/bun.md`)
|
|
495
|
-
- Is the nesting meaningful for this project?
|
|
496
|
-
- Are there any flat files like `project-commands.md`? **These should be nested**
|
|
497
|
-
|
|
498
|
-
3. **Redundancy check**: Are there files with overlapping content? Either literally overlapping (due to errors while editing), or semantically/conceptually overlapping?
|
|
499
|
-
|
|
500
|
-
4. **Completeness check**: Did you actually update ALL relevant files? For example:
|
|
501
|
-
- Did you update `human` with the user's identity and preferences?
|
|
502
|
-
- Did you update `persona` with behavioral rules they expressed?
|
|
503
|
-
- Or did you only update project files and forget the rest?
|
|
504
|
-
|
|
505
|
-
5. **Quality check**: Are there typos, formatting issues, or unclear frontmatter descriptions?
|
|
506
|
-
|
|
507
|
-
6. **Structure check**: Would this make sense to your future self? Is anything missing? Is anything redundant?
|
|
508
|
-
|
|
509
|
-
**After reflection**, fix any issues you found. Then ask the user:
|
|
510
|
-
> "I've completed the initialization. Here's a brief summary of what I set up: [summary]. Should I continue refining, or is this good to proceed?"
|
|
511
|
-
|
|
512
|
-
This gives the user a chance to provide feedback or ask for adjustments before you finish.
|
|
513
|
-
|
|
514
|
-
## Working with Memory Filesystem (Practical Guide)
|
|
515
|
-
|
|
516
|
-
Here's how to work with the memory filesystem during initialization:
|
|
517
|
-
|
|
518
|
-
### Inspecting Current Structure
|
|
519
|
-
|
|
115
|
+
### 3. Identify the user from git
|
|
116
|
+
Infer the user's identity from git context — don't ask them who they are:
|
|
520
117
|
```bash
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
# Check the tree structure
|
|
525
|
-
tree ~/.letta/agents/<agent-id>/memory/system/
|
|
526
|
-
|
|
527
|
-
# Read existing memory files
|
|
528
|
-
cat ~/.letta/agents/<agent-id>/memory/system/persona.md
|
|
118
|
+
git shortlog -sn --all | head -5
|
|
119
|
+
git log --format="%an <%ae>" | sort -u | head -10
|
|
529
120
|
```
|
|
121
|
+
Cross-reference with the git user config to determine which contributor is the current user. Store in `system/human/`.
|
|
530
122
|
|
|
531
|
-
###
|
|
532
|
-
|
|
533
|
-
**Good examples (nested with `/`):**
|
|
534
|
-
✅ `project/overview.md`
|
|
535
|
-
✅ `project/tooling/bun.md`
|
|
536
|
-
✅ `project/tooling/testing.md`
|
|
537
|
-
✅ `human/prefs/communication.md`
|
|
538
|
-
✅ `persona/behavior/tone.md`
|
|
123
|
+
### 4. Ask upfront questions
|
|
124
|
+
Use AskUserQuestion to gather key information. Bundle questions together:
|
|
539
125
|
|
|
540
|
-
**
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
126
|
+
1. **Research depth**: "Standard or deep research?"
|
|
127
|
+
2. **Related repos**: "Are there other repositories I should know about?"
|
|
128
|
+
3. **Historical sessions** (if data found in step 2): "I found Claude Code / Codex history. Should I analyze it to learn your preferences?"
|
|
129
|
+
4. **Communication style**: "Terse or detailed responses?"
|
|
130
|
+
5. **Rules**: "Any rules I should always follow?"
|
|
544
131
|
|
|
545
|
-
|
|
546
|
-
# Create a nested directory structure suited to the content
|
|
547
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/{tooling,architecture,conventions}
|
|
548
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/human/prefs
|
|
549
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/persona/behavior
|
|
550
|
-
|
|
551
|
-
# Create memory files using Write tool - ALL files must be nested
|
|
552
|
-
Write({
|
|
553
|
-
file_path: "~/.letta/agents/<agent-id>/memory/system/project/overview.md",
|
|
554
|
-
content: "## Project Overview\n\n..."
|
|
555
|
-
})
|
|
132
|
+
**Don't ask** things you can discover by reading files or git.
|
|
556
133
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
134
|
+
### 5. Seed identity early
|
|
135
|
+
Before diving into project research, update human and persona files based on git identity and upfront answers:
|
|
136
|
+
- `system/human.md`: Everything you learn about the user as a person — identity, background, what they're building and why, how they think, communication style, what excites or frustrates them. This is about *them*, not about project conventions or coding workflows. Keep it **project-agnostic** — the same agent may be used across multiple projects.
|
|
137
|
+
- `system/persona.md`: Who you are, what you value, how you approach working with people. This is your identity — not just "agent role + project rules." Express how you communicate, what you care about, how you handle uncertainty. Keep it **project-agnostic** — don't claim deep knowledge of a specific codebase here.
|
|
561
138
|
|
|
562
|
-
|
|
563
|
-
file_path: "~/.letta/agents/<agent-id>/memory/system/project/tooling/bun.md",
|
|
564
|
-
content: "## Bun Configuration\n\n..."
|
|
565
|
-
})
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
### Organizing Existing Files
|
|
139
|
+
Don't wait until the end — write early and refine as you go.
|
|
569
140
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
mv ~/.letta/agents/<agent-id>/memory/system/project-tooling.md \
|
|
573
|
-
~/.letta/agents/<agent-id>/memory/system/project/tooling.md
|
|
574
|
-
|
|
575
|
-
# Create subdirectories as needed
|
|
576
|
-
mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/tooling
|
|
577
|
-
mv ~/.letta/agents/<agent-id>/memory/system/project/tooling.md \
|
|
578
|
-
~/.letta/agents/<agent-id>/memory/system/project/tooling/overview.md
|
|
579
|
-
```
|
|
141
|
+
### 6. Research the project
|
|
142
|
+
Explore based on chosen depth.
|
|
580
143
|
|
|
581
|
-
|
|
144
|
+
**Standard** (~5-20 tool calls): README, package manifests, config files, git logs, key directories.
|
|
582
145
|
|
|
583
|
-
|
|
146
|
+
**Deep** (100+ tool calls): Everything above plus git history patterns, contributor analysis, code evolution, CI/CD setup. Use your TODO tool to organize systematic research. **Write findings to memory as you go** — don't wait until the end.
|
|
584
147
|
|
|
585
|
-
|
|
586
|
-
- [ ] **All new files use `/` naming** — No flat files like `my_notes.md` or `project-commands.md`
|
|
587
|
-
- [ ] **Hierarchy is meaningful** — nested paths should improve discoverability and organization.
|
|
588
|
-
- [ ] **No file is bloated** — split files that are hard to scan quickly.
|
|
589
|
-
- [ ] **Each file stays concept-focused** — split files that combine unrelated topics.
|
|
590
|
-
- [ ] **Every file has real content** — No empty or pointer-only files
|
|
591
|
-
- [ ] **Verify sync**: After creating files, check they appear in your memory files
|
|
148
|
+
**Use parallel tool calls wherever possible** — read multiple files in a single turn, write multiple memory files in a single turn. This dramatically reduces init time.
|
|
592
149
|
|
|
593
|
-
**
|
|
150
|
+
**Research techniques:**
|
|
151
|
+
- README.md, CONTRIBUTING.md, AGENTS.md, CLAUDE.md
|
|
152
|
+
- Package manifests (package.json, pyproject.toml, Cargo.toml, go.mod)
|
|
153
|
+
- Config files (.eslintrc, tsconfig.json, .prettierrc)
|
|
154
|
+
- CI/CD configs (.github/workflows/)
|
|
155
|
+
- `git log --oneline -20`, `git branch -a`, `git shortlog -sn --all | head -10`
|
|
594
156
|
|
|
595
|
-
###
|
|
157
|
+
### 7. Build memory with discovery paths
|
|
158
|
+
As you create/update memory files:
|
|
159
|
+
- Add `[[path]]` links wherever they improve discoverability (summary→detail, related-memory↔related-memory, memory→skill workflow)
|
|
160
|
+
- Ensure every file has a useful `description` in frontmatter
|
|
161
|
+
- Keep `system/` files focused and scannable
|
|
162
|
+
- Put detailed reference material outside `system/`
|
|
596
163
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
3. **Use practical paths**: prefer clear, readable nesting (e.g., `project/tooling/testing`) over unnecessarily deep paths.
|
|
600
|
-
4. **Keep files focused**: each file should cover a coherent concept and remain easy to scan.
|
|
601
|
-
5. **Every file should have real content** — no empty or pointer-only files
|
|
602
|
-
6. **Be aggressive about splitting**: If in doubt, split. Too many small files is better than too few large ones.
|
|
164
|
+
### 8. Verify context quality
|
|
165
|
+
Before finishing, review your work:
|
|
603
166
|
|
|
604
|
-
|
|
167
|
+
- **Progressive disclosure**: Can you decide whether to load a file just from its path + description?
|
|
168
|
+
- **Discovery paths**: Are key memory files linked so related context can be discovered quickly?
|
|
169
|
+
- **Project naming**: Are project dirs named after the actual project (e.g., `letta-code/`), not generic `project/`? Same for reference files.
|
|
170
|
+
- **Signal density**: Is everything in `system/` truly needed every turn?
|
|
171
|
+
- **Completeness**: Did you update human, persona, AND project files?
|
|
172
|
+
- **Persona**: Does it express personality and values, not just "agent role + project rules"? Is it more than "I'm a coding assistant"?
|
|
173
|
+
- **Human scope**: Is human.md about the user as a person? Project conventions and coding workflows belong in project files.
|
|
605
174
|
|
|
606
|
-
|
|
175
|
+
### 9. Historical session analysis (if approved)
|
|
607
176
|
|
|
608
|
-
This section runs only if the user approved during upfront questions. It uses parallel `history-analyzer` subagents to process Claude Code and/or Codex history into memory.
|
|
177
|
+
This section runs only if the user approved during upfront questions. It uses parallel `history-analyzer` subagents to process Claude Code and/or Codex history into memory.
|
|
609
178
|
|
|
610
|
-
**Architecture:** Parallel worker subagents each process a slice of
|
|
179
|
+
**Architecture:** Parallel worker subagents each process a slice of history data (on their own git branch), then you merge all branches and curate the results.
|
|
611
180
|
|
|
612
181
|
**Prerequisites:**
|
|
613
|
-
- `letta.js` must be built (`bun run build`)
|
|
614
|
-
- Use `subagent_type: "history-analyzer"` — cheaper model
|
|
182
|
+
- `letta.js` must be built (`bun run build`)
|
|
183
|
+
- Use `subagent_type: "history-analyzer"` — cheaper model, has `bypassPermissions`, creates its own worktree
|
|
615
184
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
```bash
|
|
619
|
-
ls ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null
|
|
620
|
-
wc -l ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
Split the data across multiple workers for parallel processing — **the more workers, the faster it completes**. Use 2-4+ workers depending on data volume.
|
|
624
|
-
|
|
625
|
-
**Pre-split the JSONL files by line count** so each worker reads only its chunk. This is simpler than date-based splitting and guarantees evenly-sized chunks:
|
|
185
|
+
**Step 9a: Split data for parallel processing**
|
|
626
186
|
|
|
627
187
|
```bash
|
|
628
188
|
SPLIT_DIR=/tmp/history-splits
|
|
629
189
|
mkdir -p "$SPLIT_DIR"
|
|
630
190
|
NUM_WORKERS=3 # adjust based on data volume
|
|
631
191
|
|
|
632
|
-
# Split Claude history into even chunks
|
|
633
192
|
LINES=$(wc -l < ~/.claude/history.jsonl)
|
|
634
193
|
CHUNK_SIZE=$(( LINES / NUM_WORKERS + 1 ))
|
|
635
194
|
split -l $CHUNK_SIZE ~/.claude/history.jsonl "$SPLIT_DIR/claude-"
|
|
636
195
|
|
|
637
|
-
# Split Codex history if it exists
|
|
638
196
|
if [ -f ~/.codex/history.jsonl ]; then
|
|
639
197
|
LINES=$(wc -l < ~/.codex/history.jsonl)
|
|
640
198
|
CHUNK_SIZE=$(( LINES / NUM_WORKERS + 1 ))
|
|
641
199
|
split -l $CHUNK_SIZE ~/.codex/history.jsonl "$SPLIT_DIR/codex-"
|
|
642
200
|
fi
|
|
643
201
|
|
|
644
|
-
# Rename to .jsonl for clarity
|
|
645
202
|
for f in "$SPLIT_DIR"/*; do mv "$f" "$f.jsonl" 2>/dev/null; done
|
|
646
|
-
|
|
647
|
-
# Verify even splits
|
|
648
203
|
wc -l "$SPLIT_DIR"/*.jsonl
|
|
649
204
|
```
|
|
650
205
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
### Step 2: Launch Workers in Parallel
|
|
654
|
-
|
|
655
|
-
Send all Task calls in **a single message**. Each worker creates its own worktree, reads its pre-split chunk, directly updates memory files, and commits. Workers do NOT merge.
|
|
206
|
+
**Step 9b: Launch workers in parallel** (all Task calls in a single message)
|
|
656
207
|
|
|
657
208
|
```
|
|
658
209
|
Task({
|
|
@@ -660,18 +211,16 @@ Task({
|
|
|
660
211
|
description: "Process chunk [N] of [SOURCE] history",
|
|
661
212
|
prompt: `## Assignment
|
|
662
213
|
- **Memory dir**: [MEMORY_DIR]
|
|
663
|
-
- **History chunk**: /tmp/history-splits/[
|
|
664
|
-
- **Source format**: [Claude
|
|
214
|
+
- **History chunk**: /tmp/history-splits/[chunk.jsonl]
|
|
215
|
+
- **Source format**: [Claude | Codex]
|
|
665
216
|
- **Session files**: [~/.claude/projects/ | ~/.codex/sessions/]
|
|
666
217
|
`
|
|
667
218
|
})
|
|
668
219
|
```
|
|
669
220
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
After all workers complete, **you** (the main agent) merge their branches back into main and then **review, curate, and reorganize** the resulting memory. This is critical — workers produce raw output that needs editorial judgment.
|
|
221
|
+
**Step 9c: Merge and curate**
|
|
673
222
|
|
|
674
|
-
|
|
223
|
+
After workers complete, merge their branches and apply editorial judgment:
|
|
675
224
|
|
|
676
225
|
```bash
|
|
677
226
|
cd [MEMORY_DIR]
|
|
@@ -680,30 +229,13 @@ for branch in $(git branch | grep migration-); do
|
|
|
680
229
|
done
|
|
681
230
|
```
|
|
682
231
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
- **Only high-signal, actionable information belongs in `system/`** — this is rendered in-context every turn and directly affects token cost and response quality
|
|
690
|
-
- **Move supplementary/reference content to `reference/`** — detailed history, evidence, examples, verbose context that's useful but not needed every turn
|
|
691
|
-
- **Deduplicate across workers** — multiple workers may have written overlapping or redundant content to the same files. Consolidate into clean, non-repetitive content
|
|
692
|
-
- **Reformat for scannability** — bullet points, short lines, no walls of text. Your future self needs to parse this instantly
|
|
693
|
-
- **Delete low-value content** — if something isn't clearly useful for day-to-day work, remove it. Less is more in `system/`
|
|
694
|
-
|
|
695
|
-
**3c. Reorganize file structure if needed:**
|
|
696
|
-
|
|
697
|
-
Workers may have created files that don't fit the ideal hierarchy, or put too much into `system/`. Fix this:
|
|
698
|
-
|
|
699
|
-
- Split oversized or conceptually mixed files into focused sub-files
|
|
700
|
-
- Move reference-quality content (detailed history, background context, evidence trails) to `reference/`
|
|
701
|
-
- Ensure `system/` contains only what you genuinely need in-context: identity, active preferences, current project context, behavioral rules, gotchas
|
|
702
|
-
- Merge near-duplicate files that cover the same topic
|
|
703
|
-
|
|
704
|
-
**Rule of thumb**: If removing a file from `system/` wouldn't materially affect near-term responses, it belongs in `reference/`.
|
|
232
|
+
Review all merged files:
|
|
233
|
+
- Deduplicate across workers
|
|
234
|
+
- Move reference-quality content outside `system/`
|
|
235
|
+
- Add `[[references]]` to connect new knowledge with existing memory
|
|
236
|
+
- Delete low-value content
|
|
705
237
|
|
|
706
|
-
**
|
|
238
|
+
**Step 9d: Clean up**
|
|
707
239
|
|
|
708
240
|
```bash
|
|
709
241
|
for w in $(dirname [MEMORY_DIR])/memory-worktrees/migration-*; do
|
|
@@ -713,11 +245,12 @@ git branch -d $(git branch | grep migration-)
|
|
|
713
245
|
git push
|
|
714
246
|
```
|
|
715
247
|
|
|
716
|
-
|
|
248
|
+
| Problem | Fix |
|
|
249
|
+
|---------|-----|
|
|
250
|
+
| Subagent exits with code `null`, 0 tool uses | Run `bun run build` |
|
|
251
|
+
| Subagent hangs on "Tool requires approval" | Use `subagent_type: "history-analyzer"` |
|
|
252
|
+
| Merge conflicts | Resolve by reading both versions, keep most complete content |
|
|
253
|
+
| Auth fails on push | See syncing-memory-filesystem skill |
|
|
717
254
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
| Subagent exits with code `null`, 0 tool uses | `letta.js` not built | Run `bun run build` |
|
|
721
|
-
| Subagent hangs on "Tool requires approval" | Wrong subagent type | Use `subagent_type: "history-analyzer"` (workers) or `"memory"` (synthesis) |
|
|
722
|
-
| Merge conflict during synthesis | Workers touched overlapping files | Resolve by checking `git log` for context |
|
|
723
|
-
| Auth fails on push ("repository not found") | Credential helper broken or global helper conflict | Reconfigure **repo-local** helper and check/clear conflicting global `credential.<host>.helper` entries (see syncing-memory-filesystem skill) |
|
|
255
|
+
### 10. Ask user if done
|
|
256
|
+
Check if they're satisfied or want further refinement. Then commit and push memory.
|