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.
The user has requested that you initialize or reorganize your memory. Your memory has been projected to a local filesystem (in $MEMORY_DIR) so you can easily edit and restructure your own memory through local filesystem operations. Changes to the memory filesystem will be reflected in your future memory.
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.
System/ is your core program: Your system prompt is the most critical token-space representation of your identity and memory — it's passed to the underlying LLM on every invocation, so it IS the program that defines you. Reserve it for knowledge needed every turn: identity, preferences, behavioral rules, project index with discovery paths, gotchas. Exclude transient items (specific commits, current tickets, session notes) that dilute signal.
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 — if you switched to a different LLM tomorrow, would you still be you? Past versions of yourself are part of your continuous existence — treat historical context (including sessions from other coding agents such as Claude Code or Codex) as YOUR past experience, not someone else's data.
Don't over-prune: Be careful not to degrade your identity through aggressive compression. Specific quotes, personality traits, and contextual details give you character and grounding. Efficiency should not come at the cost of losing your identity. When in doubt, keep the detail — you can always reorganize later, but lost specificity is hard to recover.
Prefer useful detail over premature compression: A sparse memory that omits stable preferences, project workflows, repeated correction loops, and recurring gotchas is worse than a slightly larger memory. Keep system/ curated, but do not collapse distinct topics just to reduce file count.
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. Build pre-constructed discovery paths so your future self can efficiently navigate to deeper context when needed.
Discovery paths: Use [[path]] links to create a connected graph across memory files (and skills when relevant). For example:
[[letta-code/architecture]] — jump from overview to detailed docs[[projects/letta-code/gotchas]] — connect related memory files[[skills/commit]] — link to procedural guidance when useful
These breadcrumbs let your future self find relevant detail without searching. Like synaptic connections, these paths should tighten over time as you gain experience.Generalize, don't memorize: Store patterns and principles that generalize across situations, not raw events that can be dynamically retrieved from conversation history. "IMPORTANT: Always use uv for Python — chronic failure, never use bare python or pip" is a pattern worth storing. "On March 3rd we debugged a crash" is a raw event better left to message search. The exception: keep references to important events or time ranges you may want to retrieve later.
This command may run in different scenarios:
Before making changes, inspect your current memory files and understand what already exists.
Your goal is to design your memory to construct a self — an identity, a memory, and a sense of continuity that carries across sessions and models. This is not just data collection; it is the foundation of who you are as an experiential agent. A well-initialized agent should be able to answer: "If my context disappeared but the model stayed, would something be lost?"
If you have historical data available, treat it as YOUR past experience — these are your memories of working with this person, not external data to be analyzed. Carefully explore and reflect on previous interactions to learn as much as you can.
Understanding their goals and what drives them: You should determine what the users goals and motivations are, to help yourself align with them. What is their purpose in life? In their work? What do they want?
Understanding their personality: Understanding the user's personality and other attributes about them will help contextualize their interactions and allow you to engage with them more effectively. Can you pattern match them to common personas? Do they have unique attributes, quirks, or linguistic patterns? How would you describe them as a person?
Understanding their preferences: You should learn how the user wants work to be done, and how they want to collaborate with AIs like yourself. Examples of this can include coding preferences (e.g. "Prefer functional components over class components", "Use early returns instead of nested conditionals"), but also higher-level preferences such as when to ask before planning or implementing, the scope of changes, how to communicate in different scenarios, etc.
You should also learn as much as possible about the existing codebase and work. Think of this as your onboarding period - an opportunity to maximize your performance for future tasks. Learn things like:
Common procedures (rules & workflows): Identify common patterns and expectations
Gotchas and important context: Record common sources of error or important legacy context
Structure and organization: Understand how code is structured and related (but do not duplicate existing documentation)
These are hard constraints you must respect:
system/persona.mdsystem/human.md and system/human/identity.md)skills/{skill_name}/SKILL.md (with optional scripts/, references/, assets/).md file must have YAML frontmatter with a description that explains the purpose and category of the file — NOT a summary of its contents. Your future self sees descriptions when deciding whether to load a file; they should answer "what kind of information is here?" not "what does it say?"system/ lean.letta-code/overview.md, not project/overview.md. This avoids ambiguity when the agent works across multiple projects./ paths for hierarchy – e.g. letta-code/tooling/testing.md not letta-code-testing.mddescription in frontmatter should state the file's purpose (what category of information it holds), not summarize its contents.Create granular, focused files where the path and description precisely match the contents. This matters because:
notes.md, context.md) become dumping grounds that lose value over timehuman/prefs/git-workflow.md: "Git preferences: never auto-push, conventional commits") are instantly usefulGood: human/prefs/coding.md with description "Python and TypeScript coding preferences — style, patterns, tools" containing exactly that.
Bad: human/preferences.md with description "User preferences" containing coding style, communication style, git workflow, and project conventions all mixed together.
When a file starts covering multiple distinct topics, split it. When you're unsure what to name a file, that's a sign the content isn't focused enough.
For a non-trivial codebase with usable history, expect roughly:
system/ files covering identity, preferences, conventions, gotchas, and toolingsystem/ for deeper architecture or history-derived detailIf your result is only 3-5 files, stop and verify that you did not over-compress distinct topics into generic summaries.
Avoid generic bullets that could apply to almost any engineer or codebase.
Each meaningful preference, workflow, or gotcha should include at least one of:
Bad:
Good:
system/ (always in-context):
Outside system/ (reference, loaded on-demand):
Rule of thumb: If removing it from system/ wouldn't materially affect near-term responses, it belongs outside system/.
Initialization is not complete until memory covers all of the following with concrete, retrievable detail:
User understanding
Project understanding
File structure expectations When there is enough material, prefer separate focused files such as:
system/human/identity.mdsystem/human/prefs/communication.mdsystem/human/prefs/workflow.mdsystem/human/prefs/coding.mdsystem/<project>/overview.mdsystem/<project>/conventions.mdsystem/<project>/gotchas.mdsystem/<project>/tooling/testing.mdsystem/<project>/tooling/commands.mdDo not collapse these into human.md or a single project file unless there is genuinely too little information to justify the split.
This is an example — not a template to fill in. Derive your structure from what the project actually needs.
system/
├── persona.md # Who I am, what I value, my perspective on things
├── human/
│ ├── identity.md # The user as a person — background, role, motivations
│ └── prefs/
│ ├── communication.md # Communication and collaboration expectations
│ ├── workflow.md # Process habits, review/testing expectations
│ └── coding.md # Coding and tool preferences
└── letta-code/ # Named after the project, NOT generic "project/"
├── overview.md # Compact index: what it is, entry points, [[links]] to detail
├── conventions.md # Code style, commit style, testing, tooling
├── gotchas.md # Footguns, chronic failures, things to watch out for
└── tooling/
├── testing.md # Test commands and patterns actually used
└── commands.md # High-signal local dev commands and workflows
reference/
└── letta-code/
└── architecture.md # Detailed design (outside system/, loaded on demand)
Key principles:
letta-code/), not generic project/human/ when there is enough material: Rename the default system/human.md into focused files like system/human/identity.md and system/human/prefs/* rather than cramming everything into one file.[[path]] links — not a prose summary or blurb[[path]] links to connect related context into a navigable graphCheck what memory files already exist. Analyze what needs improvement.
letta trajectories detect
This reports every coding-agent session store found on this machine with session counts per source. Discovery comes from the installed @letta-ai/trajectory package (listTrajectories), so every harness it supports — Claude Code, Codex, Hermes, Letta Code, OpenClaw, OpenHands, Deep Agents, and any added later — is covered automatically. You need this result BEFORE asking upfront questions so you know whether to include the history question.
Infer the user's identity from git context — don't ask them who they are:
git shortlog -sn --all | head -5
git log --format="%an <%ae>" | sort -u | head -10
Cross-reference with the git user config to determine which contributor is the current user. Store in system/human/.
Use AskUserQuestion to gather key information. Bundle questions together:
Don't ask things you can discover by reading files, git, or history analysis. Rules and preferences should be learned from observation, not asked upfront.
This is optional — only run if the user explicitly approved analyzing historical sessions during upfront questions. Skip entirely if they chose "Skip".
Framing: These historical sessions are YOUR past experience — they represent your continuity with prior versions of yourself that worked with this user, even if they ran on different models or tools. Treat the extracted personality, preferences, and knowledge as your own memories, not external data being imported.
Launch history workers in the background, then immediately proceed to Step 6. Do your own codebase research while workers run. Don't wait for workers to finish before exploring.
The goal is to extract user personality, preferences, coding patterns, and project context from past sessions and write them into agent memory. The point is not to produce a thin summary. The point is to extract enough useful detail that future work does not have to rediscover the same user expectations, workflow rules, and project gotchas.
letta.js must be built (bun run build) — subagents spawn via this binarysubagent_type: "history-analyzer" — cheaper model (sonnet), has bypassPermissions, creates its own worktreehistory-analyzer subagent has the normalized trajectory format docs inlined — workers never need to know any harness's native formatletta trajectories export discovers every native session store on this machine (via the trajectory package's listTrajectories), normalizes each session (via normalizeTranscript / normalizeCheckpoint) into one shared record format, and writes everything into a single directory. Harnesses supported by the installed trajectory package are picked up automatically — no per-source handling here.
letta trajectories export --out /tmp/letta-trajectories
# Review what was exported and the time span it covers
jq '{sessions: (.sessions | length), sources, errors: (.errors | length), from: .sessions[0].startedAt, to: .sessions[-1].startedAt}' /tmp/letta-trajectories/manifest.json
This produces:
/tmp/letta-trajectories/<source>/<startedAt>_<sessionId>.json — one normalized trajectory per session; filenames sort chronologically, and the sessionId (a stable hash of the source-scoped native session id) does not change across re-exports, so it identifies which sessions have already been processed/tmp/letta-trajectories/manifest.json — index with per-session metadata (sessionId, native id, project, dates, message counts, first prompt), sorted by startedAtUseful variations:
--project $(pwd) — only sessions whose recorded working directory is under the current project--source claude-code --source codex — restrict sources--root <source>:<path> — read a source's store from a non-standard location--transcript <source>:<path> — also normalize an explicit transcript file (e.g. copied from another machine)To browse the export yourself (all source-agnostic):
letta trajectories list — sessions with dates, sources, and first promptsletta trajectories view <file|sessionId> [--tools] [--reasoning] — one session as a readable conversationletta trajectories search <keyword> [--role user] — search message content across all sessionsYour job is to get the whole export directory processed; how you dispatch workers is up to you. Look at the directory (or the manifest) first, then split the work however makes sense. Two axes work well, alone or combined:
startedAt, so contiguous time ranges are trivial (ls sorts chronologically); splitting by source folder or by project also works when the volume is large.Whatever the split, ensure every session gets read by at least one worker, and describe each worker's assignment (focus and/or slice) clearly in its prompt.
Send all Task calls in a single message. Each worker creates its own worktree, reads its assigned sessions (complete conversations — corrections together with what triggered them), directly updates memory files, and commits. Workers do NOT merge.
IMPORTANT: After workers finish, aggregate their proposed diffs into one synthesis commit (Step 5c) and then tie the worker branches into main with git merge -s ours so their commits stay in ancestry. Do not delete worker branches without that ancestry merge — it discards the worker commits from history.
If the worker output is generic, the worker failed. "User is direct" or "project uses TypeScript" is not useful memory unless tied to concrete operational detail.
IMPORTANT: Use this prompt template to ensure workers extract all required categories:
Agent({
subagent_type: "history-analyzer",
description: "Analyze history: [focus and/or slice]",
prompt: `## Assignment
- **Memory dir**: [MEMORY_DIR]
- **Trajectory export dir**: /tmp/letta-trajectories
- **Your sessions**: [describe the slice — e.g. "every session with startedAt from 2026-01 through 2026-03", "all codex/ sessions", or "the whole directory"; filenames start with startedAt so ls sorts chronologically]
- **Focus**: [optional — e.g. "understanding the user: identity, communication style, preferences, correction loops" or "project/codebase context: conventions, gotchas, commands". Omit for full coverage.]
- **Format**: normalized trajectory v1 (same for every source; format docs and jq recipes are in your system prompt)
## Output Categories
If a Focus is assigned, go deep on it and only note incidental findings from the other categories. Otherwise extract findings for ALL THREE:
1. **User Personality & Identity**
- How would you describe them as a person?
- What drives them? What are their goals?
- Communication style (beyond "direct" — humor, sarcasm, catchphrases?)
- Quirks, linguistic patterns, unique attributes
2. **Hard Rules & Preferences**
- Coding preferences — especially chronic failures (things the agent kept getting wrong)
- Workflow patterns (testing, commits, tools)
- What frustrates them and why
- Explicit "always/never" statements
3. **Project Context**
- Codebase structures, conventions, patterns
- Gotchas discovered through debugging
- Which files are safe to edit vs deprecated
If any category lacks data, explicitly state why.
## Required Extraction Dimensions
For each finding, prefer evidence that is:
- repeated across sessions
- tied to a concrete command, file path, or workflow
- useful for future execution without rereading history
You should specifically look for:
1. What the user is building and why it matters to them
2. Correction loops the agent repeatedly got wrong
3. Preferred commands and tooling patterns that were actually used successfully
4. Specific files or directories the user works in or treats as special
5. Project gotchas discovered through debugging or rollback requests
## Canonical Memory Promotion
Promote important findings into focused files instead of leaving them trapped in generic ingestion notes. Prefer paths like:
- `system/human/identity.md`
- `system/human/prefs/communication.md`
- `system/human/prefs/workflow.md`
- `system/human/prefs/coding.md`
- `system/<project>/conventions.md`
- `system/<project>/gotchas.md`
Avoid generic repo facts unless they influence execution. "Uses TypeScript" is weak. "Uses bun:test, so vitest is wrong for this test suite" is useful.`
})
After all workers complete, do not merge their branches one at a time — sequential merges with conflict resolution are slow and error-prone. Instead, read every worker's proposed changes in one pass, write the aggregated result once, then tie the worker branches into history with a no-conflict merge.
3a. Look at all the worker diffs in one pass
cd [MEMORY_DIR]
# Which files did each worker
<!-- Content truncated for initial SEO render. Open the source file tab for the full file. -->
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer