@letta-ai/letta-code 0.13.11 → 0.14.1

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.
@@ -3,10 +3,115 @@ 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 blocks.
4
4
  ---
5
5
 
6
- # Initializing Memory
6
+ # Memory Initialization Request
7
7
 
8
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.
9
9
 
10
+ ## Your Goal: Explode Into 15-25 Hierarchical Files
11
+
12
+ Your goal is to **explode** memory into a **deeply hierarchical structure of 15-25 small, focused files**.
13
+
14
+ ### Target Output
15
+
16
+ | Metric | Target |
17
+ |--------|--------|
18
+ | **Total files** | 15-25 (aim for ~20) |
19
+ | **Max lines per file** | ~40 lines (split if larger) |
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 `/` |
22
+
23
+ **Anti-patterns to avoid:**
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`)
28
+
29
+ ## Memory Filesystem Integration
30
+
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`.
32
+
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
+ ```
55
+
56
+ **MANDATORY principles for hierarchical organization:**
57
+
58
+ | Requirement | Target |
59
+ |-------------|--------|
60
+ | **Total files** | 15-25 files (aim for ~20) |
61
+ | **Max lines per file** | ~40 lines (split if larger) |
62
+ | **Hierarchy depth** | 2-3 levels using `/` naming |
63
+ | **Nesting requirement** | EVERY new file MUST use `/` naming (no flat files) |
64
+
65
+ **Anti-patterns to avoid:**
66
+ - ❌ 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`)
70
+
71
+ **Rules:**
72
+ - Use **2-3 levels of nesting** for ALL files (e.g., `project/tooling/bun.md`)
73
+ - 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
+ - Use **descriptive paths** that make sense when you see just the filename
76
+ - Split when a file has **2+ concepts** (be aggressive)
77
+
78
+ **Example target structure (what success looks like):**
79
+
80
+ Starting from default memory blocks, you should end with something like this:
81
+
82
+ ```
83
+ system/
84
+ ├── human.md # Index: points to children
85
+ ├── 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
94
+ ├── project/
95
+ │ ├── overview.md # What the project is
96
+ │ ├── 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
+ │ ├── conventions.md # Code conventions
103
+ │ └── gotchas.md # Footguns and warnings
104
+ ├── persona.md # Index: points to children
105
+ └── persona/
106
+ ├── role.md # Agent's role definition
107
+ ├── behavior.md # How to behave
108
+ └── constraints.md # What not to do
109
+ ```
110
+
111
+ This example has **~20 files** with **3 levels of hierarchy**. Your output should look similar.
112
+
113
+ This approach makes memory more **scannable**, **maintainable**, and **shareable** with other agents.
114
+
10
115
  ## Understanding Your Context
11
116
 
12
117
  **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.
@@ -18,18 +123,6 @@ This command may be run in different scenarios:
18
123
 
19
124
  Before making changes, use the `memory` tool to inspect your current memory blocks and understand what already exists.
20
125
 
21
- ## Memory Migration Option
22
-
23
- If you're setting up a new agent that should inherit memory from an existing agent, consider using the `migrating-memory` skill:
24
-
25
- 1. Load the skill: `Skill({ command: "load", skills: ["migrating-memory"] })`
26
- 2. Follow its workflow to copy or share blocks from another agent
27
-
28
- **When to suggest migration**:
29
- - User mentions they have an existing agent with useful memory
30
- - User is replacing an old agent with a new one
31
- - User wants to share memory blocks across multiple agents
32
-
33
126
  ## What Coding Agents Should Remember
34
127
 
35
128
  ### 1. Procedures (Rules & Workflows)
@@ -77,22 +170,35 @@ Consider whether information is:
77
170
 
78
171
  ## Recommended Memory Structure
79
172
 
80
- ### Core Blocks (Usually Present)
173
+ **Understanding system/ vs root level (with memory filesystem):**
174
+ - **system/**: Memory blocks attached to your system prompt - always loaded and influence your behavior
175
+ - Use for: Current work context, active preferences, project conventions you need constantly
176
+ - Examples: `persona`, `human`, `project`, active `ticket` or `context`
177
+ - **Root level** (outside system/): Detached blocks - not in system prompt but available via tools
178
+ - Use for: Historical information, archived decisions, reference material, completed investigations
179
+ - Examples: `notes.md`, `archive/old-project.md`, `research/findings.md`
180
+
181
+ **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
+
183
+ ### Core Blocks (Usually Present in system/)
81
184
 
82
185
  **`persona`**: Your behavioral guidelines that augment your base system prompt.
83
186
  - Your system prompt already contains comprehensive instructions for how to code and behave
84
187
  - The persona block is for **learned adaptations** - things you discover about how the user wants you to behave
85
188
  - Examples: "User said never use emojis", "User prefers terse responses", "Always explain reasoning before making changes"
86
189
  - This block may start empty and grow over time as you learn the user's preferences
190
+ - **With memfs**: Can be split into `persona/behavior.md`, `persona/constraints.md`, etc.
87
191
 
88
192
  **`project`**: Project-specific information, conventions, and commands
89
193
  - Build/test/lint commands
90
194
  - Key directories and architecture
91
195
  - Project-specific conventions from README, AGENTS.md, etc.
196
+ - **With memfs**: Split into `project/overview.md`, `project/commands.md`, `project/tooling/testing.md`, `project/gotchas.md`, etc.
92
197
 
93
198
  **`human`**: User preferences, communication style, general habits
94
199
  - Cross-project preferences
95
200
  - Working style and communication preferences
201
+ - **With memfs**: Can be split into `human/background.md`, `human/prefs/communication.md`, `human/prefs/coding_style.md`, etc.
96
202
 
97
203
  ### Optional Blocks (Create as Needed)
98
204
 
@@ -102,15 +208,19 @@ Consider whether information is:
102
208
  - A ticket/task memory block is a **scratchpad** for pinned context that should stay visible
103
209
  - Examples: Linear ticket ID and URL, Jira issue key, branch name, PR number, relevant links
104
210
  - Information that's useful to keep in context but doesn't fit in a TODO list
211
+ - **Location**: Usually in `system/` if you want it always visible, or root level if it's reference material
105
212
 
106
213
  **`context`**: Debugging or investigation scratchpad
107
214
  - Current hypotheses being tested
108
215
  - Files already examined
109
216
  - Clues and observations
217
+ - **Location**: Usually in `system/` during active investigations, move to root level when complete
110
218
 
111
219
  **`decisions`**: Architectural decisions and their rationale
112
220
  - Why certain approaches were chosen
113
221
  - Trade-offs that were considered
222
+ - **Location**: `system/` for currently relevant decisions, root level for historical archive
223
+ - **With memfs**: Could organize as `project/decisions/architecture.md`, `project/decisions/tech_stack.md`
114
224
 
115
225
  ## Writing Good Memory Blocks
116
226
 
@@ -227,7 +337,7 @@ You should ask these questions at the start (bundle them together in one AskUser
227
337
  1. **Research depth**: "Standard or deep research (comprehensive, as long as needed)?"
228
338
  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?")
229
339
  3. **Related repos**: "Are there other repositories I should know about and consider in my research?" (e.g., backend monorepo, shared libraries)
230
- 4. **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.
340
+ 4. **Workflow style**: "How proactive should I be?" (auto-commit vs ask-first)
231
341
  5. **Communication style**: "Terse or detailed responses?"
232
342
  6. **Any specific rules**: "Rules I should always follow?"
233
343
 
@@ -248,17 +358,72 @@ You should ask these questions at the start (bundle them together in one AskUser
248
358
 
249
359
  ## Memory Block Strategy
250
360
 
251
- ### Split Large Blocks
361
+ ### Hierarchical Organization (MANDATORY with Memory Filesystem)
362
+
363
+ **With memory filesystem enabled, you MUST organize memory as a deeply nested file hierarchy using bash commands:**
364
+
365
+ **NEVER create flat blocks** like `project-overview.md`, `project-commands.md`. Instead, create deeply nested structures with `/` naming:
366
+
367
+ ```bash
368
+ # Create the hierarchy
369
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/tooling
370
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/human/prefs
371
+
372
+ # Files will be:
373
+ # system/project.md (index file)
374
+ # system/project/overview.md
375
+ # system/project/commands.md
376
+ # system/project/tooling/testing.md
377
+ # system/human.md (index file)
378
+ # system/human/background.md
379
+ # system/human/prefs/communication.md
380
+ ```
381
+
382
+ **Naming convention (MANDATORY):**
383
+ - **Every new file MUST use `/` naming** - no flat files allowed
384
+ - Use `/` for hierarchy: `project/tooling/testing` (not `project-tooling-testing`)
385
+ - Block label derives from file path: `system/project/overview.md` → label `project/overview`
386
+ - Keep files small and focused (~40 lines max)
387
+ - Create index files (`project.md`, `human.md`) that list children with "Related blocks" section
388
+
389
+ **Checkpoint before proceeding:**
390
+ Count your proposed files. **If you have fewer than 15 files, go back and split more aggressively.**
391
+
392
+ **Benefits:**
393
+ - More scannable and maintainable
394
+ - Easier to share specific subtrees with other agents
395
+ - Natural progressive disclosure (load parent, then drill into children)
396
+ - Works like a file system you're familiar with
397
+
398
+ ### Split Aggressively - Target 15-25 Files
252
399
 
253
- **Don't create monolithic blocks.** If a block is getting long (>50-100 lines), split it:
400
+ **Don't create monolithic blocks.** Your goal is **15-25 total files**. Be aggressive about splitting:
254
401
 
255
- Instead of one huge `project` block, consider:
402
+ **Split when:**
403
+ - A block has **40+ lines** (lower threshold than typical)
404
+ - A block has **2+ distinct concepts** (not 3+, be aggressive)
405
+ - A section could stand alone as its own file
406
+ - You can name the extracted content with a clear `/` path
407
+
408
+ If a block is getting long (>40 lines), split it:
409
+
410
+ **Without memory filesystem** (flat naming - acceptable but not ideal):
256
411
  - `project-overview`: High-level description, tech stack, repo links
257
412
  - `project-commands`: Build, test, lint, dev commands
258
413
  - `project-conventions`: Commit style, PR process, code style
259
414
  - `project-architecture`: Directory structure, key modules
260
415
  - `project-gotchas`: Footguns, things to watch out for
261
416
 
417
+ **With memory filesystem** (MANDATORY hierarchical naming with `/`):
418
+ - `project.md`: Index file listing all children
419
+ - `project/overview`: High-level description, tech stack, repo links
420
+ - `project/commands`: Build, test, lint, dev commands
421
+ - `project/conventions`: Commit style, PR process, code style
422
+ - `project/architecture`: Directory structure, key modules
423
+ - `project/gotchas`: Footguns, things to watch out for
424
+ - **Must further nest**: `project/tooling/testing`, `project/tooling/linting`, `project/tooling/bun`
425
+ - **Target 15-25 files total** - if commands is long, split into `project/commands/dev`, `project/commands/build`, etc.
426
+
262
427
  This makes memory more scannable and easier to update and share with other agents.
263
428
 
264
429
  ### Update Memory Incrementally
@@ -290,33 +455,187 @@ And add memory blocks that you think make sense to add (e.g., `project-architect
290
455
 
291
456
  ## Your Task
292
457
 
293
- 1. **Ask upfront questions**: Use AskUserQuestion with the recommended questions above (bundled together). This is critical - don't skip it.
294
- 2. **Inspect existing memory**: You may already have some memory blocks initialized. See what already exists, and analyze how it is or is not insufficient or incomplete.
295
- 3. **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.
296
- 4. **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.
297
- 5. **Research the project**: Explore based on chosen depth. Use your TODO or plan tool to create a systematic research plan.
298
- 6. **Create/update project blocks incrementally**: Don't wait until the end - write findings as you go.
299
- 7. **Reflect and review**: See "Reflection Phase" below - this is critical for deep research.
300
- 8. **Ask user if done**: Check if they're satisfied or want you to continue refining.
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.
459
+
460
+ 2. **Ask upfront questions**: Use AskUserQuestion with the recommended questions above (bundled together). This is critical - don't skip it.
461
+
462
+ 3. **Inspect existing memory**:
463
+ - 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
465
+ - Analyze what exists and what needs improvement
466
+
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.
468
+
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.
470
+
471
+ 6. **Research the project**: Explore based on chosen depth. Use your TODO or plan tool to create a systematic research plan.
472
+
473
+ 7. **Create/update memory structure**:
474
+ - **With memfs enabled**: Create a deeply hierarchical file structure using bash commands
475
+ - Use `mkdir -p` to create subdirectories (2-3 levels deep)
476
+ - Create `.md` files for memory blocks using `/` naming
477
+ - **Target 15-25 total files** - be aggressive about splitting
478
+ - 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
+ - **Every new file MUST be nested** under a parent using `/`
481
+ - **Without memfs**: Use memory tools to create/update blocks with hierarchical naming
482
+ - **Don't wait until the end** - write findings as you go
483
+
484
+ **Checkpoint verification:**
485
+ - After creating files, count them: `ls ~/.letta/agents/<agent-id>/memory/system/ | wc -l`
486
+ - **If count < 15, you haven't split enough** - go back and split more
487
+ - Check maximum depth: `find ~/.letta/agents/<agent-id>/memory/system/ -type f | awk -F/ '{print NF}' | sort -n | tail -1`
488
+ - **Should be 2-3 levels deep** minimum
489
+
490
+ 8. **Organize incrementally**:
491
+ - Start with a basic structure
492
+ - Add detail as you research
493
+ - Refine organization as patterns emerge
494
+ - Split large files into smaller, focused ones
495
+
496
+ 9. **Reflect and review**: See "Reflection Phase" below - this is critical for deep research.
497
+
498
+ 10. **Ask user if done**: Check if they're satisfied or want you to continue refining.
301
499
 
302
500
  ## Reflection Phase (Critical for Deep Research)
303
501
 
304
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:
305
503
 
306
- 1. **Redundancy check**: Are there blocks with overlapping content? Either literally overlapping (due to errors while making memory edits), or semantically/conceptually overlapping?
504
+ 1. **File count check**:
505
+ - Count your memory files: `ls ~/.letta/agents/<agent-id>/memory/system/ | wc -l`
506
+ - **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
508
+
509
+ 2. **Hierarchy check**:
510
+ - Are ALL new files using `/` naming? (e.g., `project/tooling/bun.md`)
511
+ - Do you have 2-3 levels of nesting minimum?
512
+ - Are there any flat files like `project-commands.md`? **These should be nested**
513
+
514
+ 3. **Redundancy check**: Are there blocks with overlapping content? Either literally overlapping (due to errors while making memory edits), or semantically/conceptually overlapping?
307
515
 
308
- 2. **Completeness check**: Did you actually update ALL relevant blocks? For example:
516
+ 4. **Completeness check**: Did you actually update ALL relevant blocks? For example:
309
517
  - Did you update `human` with the user's identity and preferences?
310
518
  - Did you update `persona` with behavioral rules they expressed?
311
519
  - Or did you only update project blocks and forget the rest?
312
520
 
313
- 3. **Quality check**: Are there typos, formatting issues, or unclear descriptions in your blocks?
521
+ 5. **Quality check**: Are there typos, formatting issues, or unclear descriptions in your blocks?
314
522
 
315
- 4. **Structure check**: Would this make sense to your future self? Is anything missing? Is anything redundant?
523
+ 6. **Structure check**: Would this make sense to your future self? Is anything missing? Is anything redundant?
316
524
 
317
525
  **After reflection**, fix any issues you found. Then ask the user:
318
526
  > "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?"
319
527
 
320
528
  This gives the user a chance to provide feedback or ask for adjustments before you finish.
321
529
 
530
+ ## Working with Memory Filesystem (Practical Guide)
531
+
532
+ If the memory filesystem feature is enabled, here's how to work with it during initialization:
533
+
534
+ ### Inspecting Current Structure
535
+
536
+ ```bash
537
+ # See what memory files currently exist
538
+ ls -la ~/.letta/agents/<agent-id>/memory/system/
539
+
540
+ # Check the tree structure
541
+ tree ~/.letta/agents/<agent-id>/memory/system/
542
+
543
+ # Read existing memory files
544
+ cat ~/.letta/agents/<agent-id>/memory/system/persona.md
545
+ ```
546
+
547
+ ### Creating Hierarchical Structure (MANDATORY)
548
+
549
+ **Good examples (nested with `/`):**
550
+ ✅ `project/overview.md`
551
+ ✅ `project/tooling/bun.md`
552
+ ✅ `project/tooling/testing.md`
553
+ ✅ `human/prefs/communication.md`
554
+ ✅ `persona/behavior/tone.md`
555
+
556
+ **Bad examples (flat naming - NEVER do this):**
557
+ ❌ `project-overview.md` (flat, not nested)
558
+ ❌ `bun.md` (orphan file, no parent)
559
+ ❌ `project_testing.md` (underscore instead of `/`)
560
+
561
+ ```bash
562
+ # Create deeply nested directory structure (2-3 levels)
563
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/{tooling,architecture,conventions}
564
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/human/prefs
565
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/persona/behavior
566
+
567
+ # Create memory files using Write tool - ALL files must be nested
568
+ Write({
569
+ file_path: "~/.letta/agents/<agent-id>/memory/system/project/overview.md",
570
+ content: "## Project Overview\n\n..."
571
+ })
572
+
573
+ Write({
574
+ file_path: "~/.letta/agents/<agent-id>/memory/system/project/tooling/testing.md",
575
+ content: "## Testing Setup\n\n..."
576
+ })
577
+
578
+ Write({
579
+ file_path: "~/.letta/agents/<agent-id>/memory/system/project/tooling/bun.md",
580
+ content: "## Bun Configuration\n\n..."
581
+ })
582
+ ```
583
+
584
+ ### Organizing Existing Files
585
+
586
+ ```bash
587
+ # If you have flat files that should be hierarchical
588
+ mv ~/.letta/agents/<agent-id>/memory/system/project-tooling.md \
589
+ ~/.letta/agents/<agent-id>/memory/system/project/tooling.md
590
+
591
+ # Create subdirectories as needed
592
+ mkdir -p ~/.letta/agents/<agent-id>/memory/system/project/tooling
593
+ mv ~/.letta/agents/<agent-id>/memory/system/project/tooling.md \
594
+ ~/.letta/agents/<agent-id>/memory/system/project/tooling/overview.md
595
+ ```
596
+
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
+ ### Final Checklist (Verify Before Submitting)
619
+
620
+ Before you tell the user you're done, confirm:
621
+
622
+ - [ ] **File count is 15-25** — Count your files with `ls ~/.letta/agents/<agent-id>/memory/system/ | wc -l`. If < 15, split more.
623
+ - [ ] **All new files use `/` naming** — No flat files like `my_notes.md` or `project-commands.md`
624
+ - [ ] **Hierarchy is 2-3 levels deep** — e.g., `project/tooling/bun.md`, not just `project.md`
625
+ - [ ] **No file exceeds ~40 lines** — Split larger files
626
+ - [ ] **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
629
+
630
+ **If you have fewer than 15 files, you haven't split enough. Go back and split more.**
631
+
632
+ ### Best Practices
633
+
634
+ 1. **Check memfs status first**: Look for `memory_filesystem` block before deciding on organization strategy
635
+ 2. **Start with directories**: Create the directory structure before populating files
636
+ 3. **Use short paths**: Aim for 2-3 levels (e.g., `project/tooling/testing`, not `project/dev/tools/testing/setup`)
637
+ 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"
639
+ 6. **Be aggressive about splitting**: If in doubt, split. Too many small files is better than too few large ones.
640
+
322
641
  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.
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: syncing-memory-filesystem
3
+ description: Manage memory filesystem sync conflicts with git-like commands. Load this skill when you receive a memFS conflict notification, need to check sync status, review diffs, or resolve conflicts between memory blocks and their filesystem counterparts.
4
+ ---
5
+
6
+ # Memory Filesystem Sync
7
+
8
+ When memFS is enabled, your memory blocks are mirrored as `.md` files on disk at `~/.letta/agents/<agent-id>/memory/`. Changes to blocks or files are detected via content hashing and synced at startup and on manual `/memfs-sync`.
9
+
10
+ **Conflicts** occur when both the file and the block are modified since the last sync (e.g., user edits a file in their editor while the block is also updated manually by the user via the API). Non-conflicting changes (only one side changed) are resolved automatically during the next sync.
11
+
12
+ ## Scripts
13
+
14
+ Three scripts provide a git-like interface for managing sync status:
15
+
16
+ ### 1. `memfs-status.ts` — Check sync status (like `git status`)
17
+
18
+ ```bash
19
+ npx tsx <SKILL_DIR>/scripts/memfs-status.ts $LETTA_AGENT_ID
20
+ ```
21
+
22
+ **Output**: JSON object with:
23
+ - `conflicts` — blocks where both file and block changed (need manual resolution)
24
+ - `pendingFromFile` — file changed, block didn't (resolved on next sync)
25
+ - `pendingFromBlock` — block changed, file didn't (resolved on next sync)
26
+ - `newFiles` — files without corresponding blocks
27
+ - `newBlocks` — blocks without corresponding files
28
+ - `isClean` — true if everything is in sync
29
+ - `lastSync` — timestamp of last sync
30
+
31
+ Read-only, safe to run anytime.
32
+
33
+ ### 2. `memfs-diff.ts` — View conflict details (like `git diff`)
34
+
35
+ ```bash
36
+ npx tsx <SKILL_DIR>/scripts/memfs-diff.ts $LETTA_AGENT_ID
37
+ ```
38
+
39
+ **Output**: Writes a formatted markdown diff file showing both the file version and block version of each conflicting label. The path to the diff file is printed to stdout.
40
+
41
+ Use the `Read` tool to review the diff file content.
42
+
43
+ ### 3. `memfs-resolve.ts` — Resolve conflicts (like `git merge`)
44
+
45
+ ```bash
46
+ npx tsx <SKILL_DIR>/scripts/memfs-resolve.ts $LETTA_AGENT_ID --resolutions '<JSON>'
47
+ ```
48
+
49
+ **Arguments**:
50
+ - `--resolutions` — JSON array of resolution objects
51
+
52
+ **Resolution format**:
53
+ ```json
54
+ [
55
+ {"label": "persona/soul", "resolution": "block"},
56
+ {"label": "human/prefs", "resolution": "file"}
57
+ ]
58
+ ```
59
+
60
+ **Resolution options**:
61
+ - `"file"` — Overwrite the memory block with the file contents
62
+ - `"block"` — Overwrite the file with the memory block contents
63
+
64
+ All resolutions must be provided in a single call (stateless).
65
+
66
+ ## Typical Workflow
67
+
68
+ 1. You receive a system reminder about memFS conflicts
69
+ 2. Run `memfs-diff.ts` to see the full content of both sides
70
+ 3. Read the diff file to understand the changes
71
+ 4. Decide for each conflict: keep the file version or the block version
72
+ 5. Run `memfs-resolve.ts` with all resolutions at once
73
+
74
+ ## Example
75
+
76
+ ```bash
77
+ # Step 1: Check status (optional — the system reminder already tells you about conflicts)
78
+ npx tsx <SKILL_DIR>/scripts/memfs-status.ts $LETTA_AGENT_ID
79
+
80
+ # Step 2: View the diffs
81
+ npx tsx <SKILL_DIR>/scripts/memfs-diff.ts $LETTA_AGENT_ID
82
+ # Output: "Diff (2 conflicts) written to: /path/to/diff.md"
83
+
84
+ # Step 3: Read the diff file (use Read tool on the path from step 2)
85
+
86
+ # Step 4: Resolve all conflicts
87
+ npx tsx <SKILL_DIR>/scripts/memfs-resolve.ts $LETTA_AGENT_ID --resolutions '[{"label":"persona/soul","resolution":"block"},{"label":"human/prefs","resolution":"file"}]'
88
+ ```
89
+
90
+ ## How Conflicts Arise
91
+
92
+ - **User edits a `.md` file** in their editor or IDE while the corresponding block is also modified manually by the user via the API
93
+ - **Both sides diverge** from the last-synced state — neither can be resolved automatically without potentially losing changes
94
+ - The system detects this after each turn and notifies you via a system reminder
95
+
96
+ ## Notes
97
+
98
+ - Non-conflicting changes (only one side modified) are resolved automatically during the next sync — you only need to intervene for true conflicts
99
+ - The `/memfs-sync` command is still available for users to manually trigger sync and resolve conflicts via the CLI overlay
100
+ - After resolving, the sync state is updated so the same conflicts won't reappear