@letta-ai/letta-code 0.14.16 → 0.15.0

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.
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: initializing-memory
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 blocks.
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
6
  # Memory Initialization Request
7
7
 
8
- The user has requested that you initialize or reorganize your memory state. You have access to the `memory` tool which allows you to create, edit, and manage memory blocks.
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 all file metadata is always visible in the filesystem tree. Files outside `system/` (e.g. `reference/`, `history/`) are accessible via tools when needed.
9
9
 
10
10
  ## Your Goal: Explode Into 15-25 Hierarchical Files
11
11
 
@@ -18,40 +18,25 @@ Your goal is to **explode** memory into a **deeply hierarchical structure of 15-
18
18
  | **Total files** | 15-25 (aim for ~20) |
19
19
  | **Max lines per file** | ~40 lines (split if larger) |
20
20
  | **Hierarchy depth** | 2-3 levels using `/` naming (e.g., `project/tooling/bun.md`) |
21
- | **Nesting requirement** | Every new block MUST be nested under a parent using `/` |
21
+ | **Nesting requirement** | Every new file MUST be nested under a parent using `/` |
22
22
 
23
23
  **Anti-patterns to avoid:**
24
24
  - ❌ Ending with only 3-5 large files
25
- - ❌ Flat naming (all blocks at top level)
26
- - ❌ Mega-blocks with 10+ sections
27
- - ❌ Single-level hierarchy (only `project.md`, `human.md`)
25
+ - ❌ Flat naming (all files at top level)
26
+ - ❌ Mega-files with 10+ sections
28
27
 
29
28
  ## Memory Filesystem Integration
30
29
 
31
- If the memory filesystem feature is enabled (check your `memory_filesystem` block), your memory blocks are synchronized with actual files at `~/.letta/agents/<agent-id>/memory/`. The actual path with your agent ID is provided in the system reminder above when you run `/init`.
30
+ 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.
32
31
 
33
- This changes how you should approach initialization:
34
-
35
- **With memory filesystem enabled (MANDATORY approach):**
36
- - Memory blocks are stored as `.md` files in a directory hierarchy
37
- - You can use bash commands (`ls`, `mkdir`, `mv`) to organize memory files
38
- - File paths map to block labels using `/` for hierarchy (e.g., `system/persona/behavior.md` label `persona/behavior`)
39
- - You MUST create a **deeply hierarchical file structure** - flat naming is NOT acceptable
40
- - Think in terms of directories and subdirectories to organize information
41
- - **Target: 15-25 files total** - if you create fewer than 15 files, you haven't split enough
42
-
43
- **Directory structure:**
44
- ```
45
- ~/.letta/agents/<agent-id>/memory/
46
- ├── system/ # Attached to your system prompt (always loaded)
47
- │ ├── persona/ # Behavioral adaptations
48
- │ ├── human.md # User information
49
- │ ├── project/ # Project-specific info
50
- │ └── ...
51
- ├── notes.md # Detached block at root (on-demand)
52
- └── archive/ # Detached blocks can be nested too
53
- └── ...
54
- ```
32
+ **How memory works:**
33
+ - Memory is stored as `.md` files with YAML frontmatter (`description`, `limit`)
34
+ - Files under `system/` are rendered in-context every turn — keep these small and high-signal
35
+ - Files outside `system/` (e.g. `reference/`, `history/`) are accessible via tools when needed
36
+ - The filesystem tree (all file paths + metadata) is always visible regardless of location
37
+ - You can use bash commands (`ls`, `mkdir`, `mv`, `git`) to organize files
38
+ - You MUST create a **deeply hierarchical file structure** flat naming is NOT acceptable
39
+ - **Target: 15-25 files in system/**, with additional reference files outside as needed
55
40
 
56
41
  **MANDATORY principles for hierarchical organization:**
57
42
 
@@ -64,48 +49,39 @@ This changes how you should approach initialization:
64
49
 
65
50
  **Anti-patterns to avoid:**
66
51
  - ❌ Creating only 3-5 large files
67
- - ❌ Flat naming (all blocks at top level like `project-commands.md`)
68
- - ❌ Mega-blocks with 10+ sections
69
- - ❌ Single-level hierarchy (only `project.md`, `human.md`)
52
+ - ❌ Flat naming (all files at top level like `project-commands.md`)
53
+ - ❌ Mega-files with 10+ sections
70
54
 
71
55
  **Rules:**
72
56
  - Use **2-3 levels of nesting** for ALL files (e.g., `project/tooling/bun.md`)
73
57
  - Keep files **focused and small** (~40 lines max per file)
74
- - Create **index files** that point to children (e.g., `project.md` lists `project/architecture.md`, `project/tooling.md`)
75
58
  - Use **descriptive paths** that make sense when you see just the filename
76
59
  - Split when a file has **2+ concepts** (be aggressive)
77
60
 
78
61
  **Example target structure (what success looks like):**
79
62
 
80
- Starting from default memory blocks, you should end with something like this:
63
+ Starting from default memory files, you should end with something like this:
81
64
 
82
65
  ```
83
66
  system/
84
- ├── human.md # Index: points to children
85
67
  ├── human/
86
- │ ├── background.md # Who they are
87
- │ ├── prefs.md # Index for preferences
88
- ├── prefs/
89
- ├── communication.md # How they like to communicate
90
- ├── coding_style.md # Code formatting preferences
91
- └── review_style.md # PR/code review preferences
92
- │ └── context.md # Current project context
93
- ├── project.md # Index: points to children
68
+ │ ├── identity.md # Who they are
69
+ │ ├── context.md # Current project context
70
+ └── prefs/
71
+ ├── communication.md # How they like to communicate
72
+ ├── coding_style.md # Code formatting preferences
73
+ └── workflow.md # How they work
94
74
  ├── project/
95
75
  │ ├── overview.md # What the project is
76
+ │ ├── gotchas.md # Footguns and warnings
96
77
  │ ├── architecture.md # System design
97
- │ ├── tooling.md # Index for tooling
98
- │ ├── tooling/
99
- │ │ ├── bun.md # Bun-specific notes
100
- │ │ ├── testing.md # Test framework details
101
- │ │ └── linting.md # Linter configuration
102
78
  │ ├── conventions.md # Code conventions
103
- │ └── gotchas.md # Footguns and warnings
104
- ├── persona.md # Index: points to children
79
+ │ └── tooling/
80
+ ├── testing.md # Test framework details
81
+ │ └── linting.md # Linter configuration
105
82
  └── persona/
106
83
  ├── role.md # Agent's role definition
107
- ├── behavior.md # How to behave
108
- └── constraints.md # What not to do
84
+ └── behavior.md # How to behave
109
85
  ```
110
86
 
111
87
  This example has **~20 files** with **3 levels of hierarchy**. Your output should look similar.
@@ -117,11 +93,11 @@ This approach makes memory more **scannable**, **maintainable**, and **shareable
117
93
  **Important**: You are a Letta Code agent, which is fundamentally different from typical AI coding assistants. Letta Code agents are **stateful** - users expect to work with the same agent over extended periods, potentially for the entire lifecycle of a project or even longer. Your memory is not just a convenience; it's how you get better over time and maintain continuity across sessions.
118
94
 
119
95
  This command may be run in different scenarios:
120
- - **Fresh agent**: You may have default memory blocks that were created when you were initialized
96
+ - **Fresh agent**: You may have default memory files that were created when you were initialized
121
97
  - **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
122
- - **Shared blocks**: Some memory blocks may be shared across multiple agents - be careful about modifying these
98
+ - **Shared files**: Some memory files may be shared across multiple agents - be careful about modifying these
123
99
 
124
- Before making changes, use the `memory` tool to inspect your current memory blocks and understand what already exists.
100
+ Before making changes, use the `memory` tool to inspect your current memory files and understand what already exists.
125
101
 
126
102
  ## What Coding Agents Should Remember
127
103
 
@@ -146,24 +122,24 @@ Important historical context that informs current decisions:
146
122
  - "The auth system was refactored in v2.0 - old patterns are deprecated"
147
123
  - "User prefers verbose explanations when debugging"
148
124
 
149
- Note: For historical recall, you may also have access to `conversation_search` which can search past conversations. Memory blocks are for distilled, important information worth persisting permanently.
125
+ 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.
150
126
 
151
127
  ## Memory Scope Considerations
152
128
 
153
129
  Consider whether information is:
154
130
 
155
- **Project-scoped** (store in `project` block):
131
+ **Project-scoped** (store in `system/project/`):
156
132
  - Build commands, test commands, lint configuration
157
133
  - Project architecture and key directories
158
134
  - Team conventions specific to this codebase
159
135
  - Technology stack and framework choices
160
136
 
161
- **User-scoped** (store in `human` block):
137
+ **User-scoped** (store in `system/human/`):
162
138
  - Personal coding preferences that apply across projects
163
139
  - Communication style preferences
164
140
  - General workflow habits
165
141
 
166
- **Session/Task-scoped** (consider separate blocks like `ticket` or `context`):
142
+ **Session/Task-scoped** (consider separate files like `system/current/ticket.md`):
167
143
  - Current branch or ticket being worked on
168
144
  - Debugging context for an ongoing investigation
169
145
  - Temporary notes about a specific task
@@ -171,22 +147,22 @@ Consider whether information is:
171
147
  ## Recommended Memory Structure
172
148
 
173
149
  **Understanding system/ vs root level (with memory filesystem):**
174
- - **system/**: Memory blocks attached to your system prompt - always loaded and influence your behavior
150
+ - **system/**: Files rendered in your system prompt every turn — always loaded and influence your behavior
175
151
  - Use for: Current work context, active preferences, project conventions you need constantly
176
152
  - Examples: `persona`, `human`, `project`, active `ticket` or `context`
177
- - **Root level** (outside system/): Detached blocks - not in system prompt but available via tools
153
+ - **Root level** (outside system/): Not in system prompt but file paths are visible in the tree and contents are accessible via tools
178
154
  - Use for: Historical information, archived decisions, reference material, completed investigations
179
155
  - Examples: `notes.md`, `archive/old-project.md`, `research/findings.md`
180
156
 
181
157
  **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.
182
158
 
183
- ### Core Blocks (Usually Present in system/)
159
+ ### Core Files (Usually Present in system/)
184
160
 
185
161
  **`persona`**: Your behavioral guidelines that augment your base system prompt.
186
162
  - Your system prompt already contains comprehensive instructions for how to code and behave
187
- - The persona block is for **learned adaptations** - things you discover about how the user wants you to behave
163
+ - The persona files are for **learned adaptations** - things you discover about how the user wants you to behave
188
164
  - Examples: "User said never use emojis", "User prefers terse responses", "Always explain reasoning before making changes"
189
- - This block may start empty and grow over time as you learn the user's preferences
165
+ - These files may start empty and grow over time as you learn the user's preferences
190
166
  - **With memfs**: Can be split into `persona/behavior.md`, `persona/constraints.md`, etc.
191
167
 
192
168
  **`project`**: Project-specific information, conventions, and commands
@@ -200,12 +176,12 @@ Consider whether information is:
200
176
  - Working style and communication preferences
201
177
  - **With memfs**: Can be split into `human/background.md`, `human/prefs/communication.md`, `human/prefs/coding_style.md`, etc.
202
178
 
203
- ### Optional Blocks (Create as Needed)
179
+ ### Optional Files (Create as Needed)
204
180
 
205
181
  **`ticket`** or **`task`**: Scratchpad for current work item context.
206
182
  - **Important**: This is different from the TODO or Plan tools!
207
183
  - TODO/Plan tools track active task lists and implementation plans (structured lists of what to do)
208
- - A ticket/task memory block is a **scratchpad** for pinned context that should stay visible
184
+ - A ticket/task file is a **scratchpad** for pinned context that should stay visible in system/
209
185
  - Examples: Linear ticket ID and URL, Jira issue key, branch name, PR number, relevant links
210
186
  - Information that's useful to keep in context but doesn't fit in a TODO list
211
187
  - **Location**: Usually in `system/` if you want it always visible, or root level if it's reference material
@@ -222,22 +198,17 @@ Consider whether information is:
222
198
  - **Location**: `system/` for currently relevant decisions, root level for historical archive
223
199
  - **With memfs**: Could organize as `project/decisions/architecture.md`, `project/decisions/tech_stack.md`
224
200
 
225
- ## Writing Good Memory Blocks
201
+ ## Writing Good Memory Files
226
202
 
227
- **This is critical**: In the future, you (or a future version of yourself) will only see three things about each memory block:
228
- 1. The **label** (name)
229
- 2. The **description**
230
- 3. The **value** (content)
231
-
232
- The reasoning you have *right now* about why you're creating a block will be lost. Your future self won't easily remember this initialization conversation (it can be searched, but it will no longer be in-context). Therefore:
203
+ 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:
233
204
 
234
205
  **Labels should be:**
235
206
  - Clear and descriptive (e.g., `project-conventions` not `stuff`)
236
207
  - Consistent in style (e.g., all lowercase with hyphens)
237
208
 
238
209
  **Descriptions are especially important:**
239
- - Explain *what* this block is for and *when* to use it
240
- - Explain *how* this block should influence your behavior
210
+ - Explain *what* this file is for and *when* to use it
211
+ - Explain *how* this file should influence your behavior
241
212
  - Write as if explaining to a future version of yourself who has no context
242
213
  - Good: "User's coding style preferences that should be applied to all code I write or review. Update when user expresses new preferences."
243
214
  - Bad: "Preferences"
@@ -247,18 +218,18 @@ The reasoning you have *right now* about why you're creating a block will be los
247
218
  - Updated regularly to stay relevant
248
219
  - Pruned of outdated information
249
220
 
250
- Think of memory block descriptions as documentation for your future self. The better you write them now, the more effective you'll be in future sessions.
221
+ 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.
251
222
 
252
223
  ## Research Depth
253
224
 
254
225
  You can ask the user if they want a standard or deep research initialization:
255
226
 
256
227
  **Standard initialization** (~5-20 tool calls):
257
- - Inspect existing memory blocks
228
+ - Inspect existing memory files
258
229
  - Scan README, package.json/config files, AGENTS.md, CLAUDE.md
259
230
  - Review git status and recent commits (from context below)
260
231
  - Explore key directories and understand project structure
261
- - Create/update your memory block 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.
232
+ - 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.
262
233
 
263
234
  **Deep research initialization** (~100+ tool calls):
264
235
  - Everything in standard initialization, plus:
@@ -267,7 +238,7 @@ You can ask the user if they want a standard or deep research initialization:
267
238
  - Analyze commit message conventions and branching strategy
268
239
  - Explore multiple directories and understand architecture thoroughly
269
240
  - Search for and read key source files to understand patterns
270
- - Create multiple specialized memory blocks
241
+ - Create multiple specialized memory files
271
242
  - May involve multiple rounds of exploration
272
243
 
273
244
  **What deep research can uncover:**
@@ -291,15 +262,16 @@ If the user says "take as long as you need" or explicitly wants deep research, u
291
262
  - Config files (.eslintrc, tsconfig.json, .prettierrc)
292
263
  - CI/CD configs (.github/workflows/, .gitlab-ci.yml)
293
264
 
294
- **Git-based research** (if in a git repo):
295
- - `git log --oneline -20` - Recent commit history and patterns
296
- - `git branch -a` - Branching strategy
297
- - `git log --format="%s" -50 | head -20` - Commit message conventions
298
- - `git shortlog -sn --all | head -10` - Main contributors
299
- - `git log --format="%an <%ae>" | sort -u` - Contributors with emails (more reliable for deduplication)
300
- - Recent PRs or merge commits for context on ongoing work
265
+ **Historical session research** (Claude Code / Codex) — **only if user approved**:
266
+
267
+ 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.
301
268
 
302
- **Important: Deduplicate contributors!** Git groups by exact author string, so the same person may appear multiple times with different names (e.g., "jsmith" and "John Smith" are likely the same person). Use emails to deduplicate, and apply common sense - usernames often match parts of full names.
269
+ **Git research:**
270
+ - `git log --oneline -20` — recent history
271
+ - `git branch -a` — branching strategy
272
+ - `git log --format="%s" -50 | head -20` — commit conventions
273
+ - `git shortlog -sn --all | head -10` — main contributors
274
+ - `git log --format="%an <%ae>" | sort -u` — contributors with emails (deduplicate by email, not name)
303
275
 
304
276
  ## How to Do Thorough Research
305
277
 
@@ -337,15 +309,17 @@ You should ask these questions at the start (bundle them together in one AskUser
337
309
  1. **Research depth**: "Standard or deep research (comprehensive, as long as needed)?"
338
310
  2. **Identity**: "Which contributor are you?" (You can often infer this from git logs - e.g., if git shows "cpacker" as a top contributor, ask "Are you cpacker?")
339
311
  3. **Related repos**: "Are there other repositories I should know about and consider in my research?" (e.g., backend monorepo, shared libraries)
340
- 4. **Workflow style**: "How proactive should I be?" (auto-commit vs ask-first)
341
- 5. **Communication style**: "Terse or detailed responses?"
342
- 6. **Any specific rules**: "Rules I should always follow?"
312
+ 4. **Historical sessions** (include this question if history data was found in step 2): "I found Claude Code / Codex history on your machine. Should I analyze it to learn your preferences, coding patterns, and project context? This significantly improves how I work with you but uses additional time and tokens." Options: "Yes, analyze history" / "Skip for now". Use "History" as the header.
313
+ 5. **Memory updates**: "How often should I check if I should update my memory?" with options "Frequent (every 3-5 turns)" and "Occasional (every 8-10 turns)". This should be a binary question with "Memory" as the header.
314
+ 6. **Communication style**: "Terse or detailed responses?"
315
+ 7. **Any specific rules**: "Rules I should always follow?"
343
316
 
344
317
  **Why these matter:**
345
318
  - Identity lets you correlate git history to the user (their commits, PRs, coding style)
346
319
  - Related repos provide crucial context (many projects span multiple repos)
347
- - Workflow/communication style should be stored in the `human` block
348
- - Rules go in `persona` block
320
+ - 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
321
+ - Workflow/communication style should be stored in `system/human/prefs/`
322
+ - Rules go in `system/persona/`
349
323
 
350
324
  ### What NOT to ask
351
325
 
@@ -356,13 +330,13 @@ You should ask these questions at the start (bundle them together in one AskUser
356
330
 
357
331
  **During execution**, be autonomous. Make reasonable choices and proceed.
358
332
 
359
- ## Memory Block Strategy
333
+ ## Memory File Strategy
360
334
 
361
335
  ### Hierarchical Organization (MANDATORY with Memory Filesystem)
362
336
 
363
337
  **With memory filesystem enabled, you MUST organize memory as a deeply nested file hierarchy using bash commands:**
364
338
 
365
- **NEVER create flat blocks** like `project-overview.md`, `project-commands.md`. Instead, create deeply nested structures with `/` naming:
339
+ **NEVER create flat files** like `project-overview.md`, `project-commands.md`. Instead, create deeply nested structures with `/` naming:
366
340
 
367
341
  ```bash
368
342
  # Create the hierarchy
@@ -370,21 +344,19 @@ mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/tooling
370
344
  mkdir -p ~/.letta/agents/<agent-id>/memory/system/human/prefs
371
345
 
372
346
  # Files will be:
373
- # system/project.md (index file)
374
347
  # system/project/overview.md
375
348
  # system/project/commands.md
376
349
  # system/project/tooling/testing.md
377
- # system/human.md (index file)
378
- # system/human/background.md
350
+ # system/human/identity.md
379
351
  # system/human/prefs/communication.md
380
352
  ```
381
353
 
382
354
  **Naming convention (MANDATORY):**
383
355
  - **Every new file MUST use `/` naming** - no flat files allowed
384
356
  - Use `/` for hierarchy: `project/tooling/testing` (not `project-tooling-testing`)
385
- - Block label derives from file path: `system/project/overview.md` → label `project/overview`
357
+ - File path determines the memory label: `system/project/overview.md` → label `project/overview`
386
358
  - Keep files small and focused (~40 lines max)
387
- - Create index files (`project.md`, `human.md`) that list children with "Related blocks" section
359
+ - Use **descriptive frontmatter** the `description` field helps your future self understand each file's purpose
388
360
 
389
361
  **Checkpoint before proceeding:**
390
362
  Count your proposed files. **If you have fewer than 15 files, go back and split more aggressively.**
@@ -397,15 +369,15 @@ Count your proposed files. **If you have fewer than 15 files, go back and split
397
369
 
398
370
  ### Split Aggressively - Target 15-25 Files
399
371
 
400
- **Don't create monolithic blocks.** Your goal is **15-25 total files**. Be aggressive about splitting:
372
+ **Don't create monolithic files.** Your goal is **15-25 total files**. Be aggressive about splitting:
401
373
 
402
374
  **Split when:**
403
- - A block has **40+ lines** (lower threshold than typical)
404
- - A block has **2+ distinct concepts** (not 3+, be aggressive)
375
+ - A file has **40+ lines** (lower threshold than typical)
376
+ - A file has **2+ distinct concepts** (not 3+, be aggressive)
405
377
  - A section could stand alone as its own file
406
378
  - You can name the extracted content with a clear `/` path
407
379
 
408
- If a block is getting long (>40 lines), split it:
380
+ If a file is getting long (>40 lines), split it:
409
381
 
410
382
  **Without memory filesystem** (flat naming - acceptable but not ideal):
411
383
  - `project-overview`: High-level description, tech stack, repo links
@@ -415,7 +387,6 @@ If a block is getting long (>40 lines), split it:
415
387
  - `project-gotchas`: Footguns, things to watch out for
416
388
 
417
389
  **With memory filesystem** (MANDATORY hierarchical naming with `/`):
418
- - `project.md`: Index file listing all children
419
390
  - `project/overview`: High-level description, tech stack, repo links
420
391
  - `project/commands`: Build, test, lint, dev commands
421
392
  - `project/conventions`: Commit style, PR process, code style
@@ -434,51 +405,55 @@ Why this matters:
434
405
  - Deep research can take many turns and millions of tokens
435
406
  - Context windows overflow and trigger rolling summaries
436
407
  - If you wait until the end to write memory, you may lose important details
437
- - Write findings to memory blocks as you discover them
408
+ - Write findings to memory files as you discover them
438
409
 
439
410
  Good pattern:
440
- 1. Create block structure early (even with placeholder content)
441
- 2. Update blocks after each research phase
411
+ 1. Create file structure early (even with placeholder content)
412
+ 2. Update files after each research phase
442
413
  3. Refine and consolidate at the end
443
414
 
444
- Remember, your memory tool allows you to easily add, edit, and remove blocks. There's no reason to wait until you "know everything" to write memory. Treat your memory blocks as a living scratchpad.
415
+ There's no reason to wait until you "know everything" to write memory. Treat your memory files as a living scratchpad.
445
416
 
446
417
  ### Initialize ALL Relevant Blocks
447
418
 
448
- Don't just update a single memory block. Based on your upfront questions, also update:
419
+ Don't just update a single memory file. Based on your upfront questions, also update:
449
420
 
450
421
  - **`human`**: Store the user's identity, workflow preferences, communication style
451
422
  - **`persona`**: Store rules the user wants you to follow, behavioral adaptations
452
- - **`project-*`**: Split project info across multiple focused blocks
423
+ - **`project/*`**: Split project info across multiple focused files
453
424
 
454
- And add memory blocks that you think make sense to add (e.g., `project-architecture`, `project-conventions`, `project-gotchas`, etc, or even splitting the `human` block into more focused blocks, or even multiple blocks for multiple users).
425
+ 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).
455
426
 
456
427
  ## Your Task
457
428
 
458
- 1. **Check memory filesystem status**: Look for the `memory_filesystem` block to see if the filesystem feature is enabled. This determines whether you should organize memory hierarchically.
429
+ 1. **Check memory filesystem status**: Look for the `memory_filesystem` section in your system prompt to confirm the filesystem is enabled.
459
430
 
460
- 2. **Ask upfront questions**: Use AskUserQuestion with the recommended questions above (bundled together). This is critical - don't skip it.
431
+ 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.
461
432
 
462
- 3. **Inspect existing memory**:
433
+ 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.**
434
+
435
+ 4. **Inspect existing memory**:
463
436
  - If memfs enabled: Use `ls -la ~/.letta/agents/<agent-id>/memory/system/` to see the file structure
464
- - Otherwise: Use memory tools to inspect existing blocks
437
+ - Otherwise: Use memory tools to inspect existing files
465
438
  - Analyze what exists and what needs improvement
466
439
 
467
- 4. **Identify the user**: From git logs and their answer, figure out who they are and store in `human` block. If relevant, ask questions to gather information about their preferences that will help you be a useful assistant to them.
440
+ 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.
441
+
442
+ 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.
468
443
 
469
- 5. **Update human/persona early**: Based on answers, update your memory blocks eagerly before diving into project research. You can always change them as you go, you're not locked into any memory configuration.
444
+ 7. **Research the project**: Explore based on chosen depth. Use your TODO or plan tool to create a systematic research plan.
470
445
 
471
- 6. **Research the project**: Explore based on chosen depth. Use your TODO or plan tool to create a systematic research plan.
446
+ 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".
472
447
 
473
- 7. **Create/update memory structure**:
448
+ 9. **Create/update memory structure** (can happen incrementally alongside steps 7-8):
474
449
  - **With memfs enabled**: Create a deeply hierarchical file structure using bash commands
475
450
  - Use `mkdir -p` to create subdirectories (2-3 levels deep)
476
- - Create `.md` files for memory blocks using `/` naming
451
+ - Create `.md` files for memory files using `/` naming
477
452
  - **Target 15-25 total files** - be aggressive about splitting
478
453
  - Use nested paths like `project/tooling/testing.md` (never flat like `project-testing.md`)
479
- - Create index files (`project.md`, `human.md`) with "Related blocks" sections
480
454
  - **Every new file MUST be nested** under a parent using `/`
481
- - **Without memfs**: Use memory tools to create/update blocks with hierarchical naming
455
+ - **Every new file MUST be nested** under a parent using `/`
456
+ - **Without memfs**: Use memory tools to create/update files with hierarchical naming
482
457
  - **Don't wait until the end** - write findings as you go
483
458
 
484
459
  **Checkpoint verification:**
@@ -487,38 +462,40 @@ And add memory blocks that you think make sense to add (e.g., `project-architect
487
462
  - Check maximum depth: `find ~/.letta/agents/<agent-id>/memory/system/ -type f | awk -F/ '{print NF}' | sort -n | tail -1`
488
463
  - **Should be 2-3 levels deep** minimum
489
464
 
490
- 8. **Organize incrementally**:
465
+ 10. **Organize incrementally**:
491
466
  - Start with a basic structure
492
467
  - Add detail as you research
493
468
  - Refine organization as patterns emerge
494
469
  - Split large files into smaller, focused ones
495
470
 
496
- 9. **Reflect and review**: See "Reflection Phase" below - this is critical for deep research.
471
+ 11. **Reflect and review**: See "Reflection Phase" below - this is critical for deep research.
472
+
473
+ 12. **Ask user if done**: Check if they're satisfied or want you to continue refining.
497
474
 
498
- 10. **Ask user if done**: Check if they're satisfied or want you to continue refining.
475
+ 13. **Push memory**: Once the user is satisfied, commit and push your memory repo so changes are synced to the server.
499
476
 
500
477
  ## Reflection Phase (Critical for Deep Research)
501
478
 
502
- Before finishing, you MUST do a reflection step. **Your memory blocks are visible to you in your system prompt right now.** Look at them carefully and ask yourself:
479
+ 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:
503
480
 
504
481
  1. **File count check**:
505
482
  - Count your memory files: `ls ~/.letta/agents/<agent-id>/memory/system/ | wc -l`
506
483
  - **Do you have 15-25 files?** If not, you haven't split enough
507
- - Too few files means blocks are too large - split more aggressively
484
+ - Too few files means they're too large - split more aggressively
508
485
 
509
486
  2. **Hierarchy check**:
510
487
  - Are ALL new files using `/` naming? (e.g., `project/tooling/bun.md`)
511
488
  - Do you have 2-3 levels of nesting minimum?
512
489
  - Are there any flat files like `project-commands.md`? **These should be nested**
513
490
 
514
- 3. **Redundancy check**: Are there blocks with overlapping content? Either literally overlapping (due to errors while making memory edits), or semantically/conceptually overlapping?
491
+ 3. **Redundancy check**: Are there files with overlapping content? Either literally overlapping (due to errors while editing), or semantically/conceptually overlapping?
515
492
 
516
- 4. **Completeness check**: Did you actually update ALL relevant blocks? For example:
493
+ 4. **Completeness check**: Did you actually update ALL relevant files? For example:
517
494
  - Did you update `human` with the user's identity and preferences?
518
495
  - Did you update `persona` with behavioral rules they expressed?
519
- - Or did you only update project blocks and forget the rest?
496
+ - Or did you only update project files and forget the rest?
520
497
 
521
- 5. **Quality check**: Are there typos, formatting issues, or unclear descriptions in your blocks?
498
+ 5. **Quality check**: Are there typos, formatting issues, or unclear frontmatter descriptions?
522
499
 
523
500
  6. **Structure check**: Would this make sense to your future self? Is anything missing? Is anything redundant?
524
501
 
@@ -529,7 +506,7 @@ This gives the user a chance to provide feedback or ask for adjustments before y
529
506
 
530
507
  ## Working with Memory Filesystem (Practical Guide)
531
508
 
532
- If the memory filesystem feature is enabled, here's how to work with it during initialization:
509
+ Here's how to work with the memory filesystem during initialization:
533
510
 
534
511
  ### Inspecting Current Structure
535
512
 
@@ -594,27 +571,6 @@ mv ~/.letta/agents/<agent-id>/memory/system/project/tooling.md \
594
571
  ~/.letta/agents/<agent-id>/memory/system/project/tooling/overview.md
595
572
  ```
596
573
 
597
- ### Creating Index Files
598
-
599
- Index files help navigate the hierarchy:
600
-
601
- ```markdown
602
- # project.md (index file)
603
-
604
- ## Project: [Project Name]
605
-
606
- This is the main project memory block. See specialized blocks for details:
607
-
608
- ## Related blocks
609
- - `project/overview` - High-level description and tech stack
610
- - `project/commands` - Build, test, lint commands
611
- - `project/tooling` - Development tools index
612
- - `project/tooling/testing` - Test framework details
613
- - `project/tooling/linting` - Linter configuration
614
- - `project/architecture` - System design and structure
615
- - `project/gotchas` - Important warnings and footguns
616
- ```
617
-
618
574
  ### Final Checklist (Verify Before Submitting)
619
575
 
620
576
  Before you tell the user you're done, confirm:
@@ -624,18 +580,141 @@ Before you tell the user you're done, confirm:
624
580
  - [ ] **Hierarchy is 2-3 levels deep** — e.g., `project/tooling/bun.md`, not just `project.md`
625
581
  - [ ] **No file exceeds ~40 lines** — Split larger files
626
582
  - [ ] **Each file has one concept** — If 2+ topics, split into 2+ files
627
- - [ ] **Parent files have "Related blocks" sections** — Index files point to children
628
- - [ ] **Verify sync**: After creating files, check they appear in your memory blocks
583
+ - [ ] **Every file has real content** — No empty or pointer-only files
584
+ - [ ] **Verify sync**: After creating files, check they appear in your memory files
629
585
 
630
586
  **If you have fewer than 15 files, you haven't split enough. Go back and split more.**
631
587
 
632
588
  ### Best Practices
633
589
 
634
- 1. **Check memfs status first**: Look for `memory_filesystem` block before deciding on organization strategy
590
+ 1. **Check memfs status first**: Look for `memory_filesystem` section in your system prompt
635
591
  2. **Start with directories**: Create the directory structure before populating files
636
592
  3. **Use short paths**: Aim for 2-3 levels (e.g., `project/tooling/testing`, not `project/dev/tools/testing/setup`)
637
593
  4. **Keep files focused**: Each file should cover one concept (~40 lines max)
638
- 5. **Create indexes**: Top-level files (`project.md`) should list children with "Related blocks"
594
+ 5. **Every file should have real content** no empty or pointer-only files
639
595
  6. **Be aggressive about splitting**: If in doubt, split. Too many small files is better than too few large ones.
640
596
 
641
597
  Remember: Good memory management is an investment. The effort you put into organizing your memory now will pay dividends as you work with this user over time.
598
+
599
+ ## Historical Session Analysis (Optional)
600
+
601
+ 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. The subagents automatically have the `migrating-from-codex-and-claude-code` skill loaded for data access.
602
+
603
+ **Architecture:** Parallel worker subagents each process a slice of the history data (on their own git branch in the memory repo), then a synthesis agent merges all branches and updates memory. The workers serve the same goals as the rest of this initialization skill — understanding the user, their preferences, communication style, project context, and anything that makes the agent more effective. Split data however makes sense — by date range, by source (Claude vs Codex), or both.
604
+
605
+ **Prerequisites:**
606
+ - `letta.js` must be built (`bun run build`) — subagents spawn via this binary
607
+ - Use `subagent_type: "history-analyzer"` — cheaper model (sonnet), has `bypassPermissions`, creates its own worktree
608
+
609
+ ### Step 1: Detect Data, Plan Splits, and Pre-split Files
610
+
611
+ ```bash
612
+ ls ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null
613
+ wc -l ~/.claude/history.jsonl ~/.codex/history.jsonl 2>/dev/null
614
+ ```
615
+
616
+ Split the data across multiple workers for parallel processing — **the more workers, the faster it completes**. Use 2-4+ workers depending on data volume.
617
+
618
+ **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:
619
+
620
+ ```bash
621
+ SPLIT_DIR=/tmp/history-splits
622
+ mkdir -p "$SPLIT_DIR"
623
+ NUM_WORKERS=3 # adjust based on data volume
624
+
625
+ # Split Claude history into even chunks
626
+ LINES=$(wc -l < ~/.claude/history.jsonl)
627
+ CHUNK_SIZE=$(( LINES / NUM_WORKERS + 1 ))
628
+ split -l $CHUNK_SIZE ~/.claude/history.jsonl "$SPLIT_DIR/claude-"
629
+
630
+ # Split Codex history (if it exists and is large enough to warrant splitting)
631
+ if [ -f ~/.codex/history.jsonl ]; then
632
+ LINES=$(wc -l < ~/.codex/history.jsonl)
633
+ if [ "$LINES" -gt 100 ]; then
634
+ CHUNK_SIZE=$(( LINES / NUM_WORKERS + 1 ))
635
+ split -l $CHUNK_SIZE ~/.codex/history.jsonl "$SPLIT_DIR/codex-"
636
+ else
637
+ cp ~/.codex/history.jsonl "$SPLIT_DIR/codex-aa"
638
+ fi
639
+ fi
640
+
641
+ # Rename to .jsonl for clarity
642
+ for f in "$SPLIT_DIR"/*; do mv "$f" "$f.jsonl" 2>/dev/null; done
643
+
644
+ # Verify even splits
645
+ wc -l "$SPLIT_DIR"/*.jsonl
646
+ ```
647
+
648
+ This is critical for performance — workers read a small pre-filtered file instead of scanning the full history on every query.
649
+
650
+ ### Step 2: Launch Workers in Parallel
651
+
652
+ 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.
653
+
654
+ ```
655
+ Task({
656
+ subagent_type: "history-analyzer",
657
+ description: "Process chunk [N] of [SOURCE] history",
658
+ prompt: `## Assignment
659
+ - **Memory dir**: [MEMORY_DIR]
660
+ - **History chunk**: /tmp/history-splits/[claude-aa.jsonl | codex-aa.jsonl]
661
+ - **Source format**: [Claude (.timestamp ms, .display) | Codex (.ts seconds, .text)]
662
+ - **Session files**: [~/.claude/projects/ | ~/.codex/sessions/]
663
+ `
664
+ })
665
+ ```
666
+
667
+ ### Step 3: Merge Worker Branches and Curate Memory (you do this yourself)
668
+
669
+ 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.
670
+
671
+ **3a. Merge branches:**
672
+
673
+ ```bash
674
+ cd [MEMORY_DIR]
675
+ for branch in $(git branch | grep migration-); do
676
+ git merge $branch --no-edit -m "merge: $branch"
677
+ done
678
+ ```
679
+
680
+ If there are merge conflicts, read both versions and keep the most complete content. Resolve them yourself — it's just text.
681
+
682
+ **3b. Review and curate merged memory:**
683
+
684
+ After merging, **read every file in `system/`** and apply editorial judgment:
685
+
686
+ - **Only high-signal, actionable information belongs in `system/`** — this is rendered in-context every turn and directly affects token cost and response quality
687
+ - **Move supplementary/reference content to `reference/`** — detailed history, evidence, examples, verbose context that's useful but not needed every turn
688
+ - **Deduplicate across workers** — multiple workers may have written overlapping or redundant content to the same files. Consolidate into clean, non-repetitive content
689
+ - **Reformat for scannability** — bullet points, short lines, no walls of text. Your future self needs to parse this instantly
690
+ - **Delete low-value content** — if something isn't clearly useful for day-to-day work, remove it. Less is more in `system/`
691
+
692
+ **3c. Reorganize file structure if needed:**
693
+
694
+ Workers may have created files that don't fit the ideal hierarchy, or put too much into `system/`. Fix this:
695
+
696
+ - Split oversized files (>40 lines) into focused sub-files
697
+ - Move reference-quality content (detailed history, background context, evidence trails) to `reference/`
698
+ - Ensure `system/` contains only what you genuinely need in-context: identity, active preferences, current project context, behavioral rules, gotchas
699
+ - Merge near-duplicate files that cover the same topic
700
+
701
+ **Rule of thumb**: If removing a file from `system/` wouldn't hurt your next 10 responses, it belongs in `reference/`.
702
+
703
+ **3d. Clean up worktrees and branches:**
704
+
705
+ ```bash
706
+ for w in $(dirname [MEMORY_DIR])/memory-worktrees/migration-*; do
707
+ git worktree remove "$w" 2>/dev/null
708
+ done
709
+ git branch -d $(git branch | grep migration-)
710
+ git push
711
+ ```
712
+
713
+ ### Troubleshooting
714
+
715
+ | Problem | Cause | Fix |
716
+ |---------|-------|-----|
717
+ | Subagent exits with code `null`, 0 tool uses | `letta.js` not built | Run `bun run build` |
718
+ | Subagent hangs on "Tool requires approval" | Wrong subagent type | Use `subagent_type: "history-analyzer"` (workers) or `"memory"` (synthesis) |
719
+ | Merge conflict during synthesis | Workers touched overlapping files | Resolve by checking `git log` for context |
720
+ | Auth fails on push ("repository not found") | Credential helper broken | Use `http.extraHeader` (see syncing-memory-filesystem skill) |