lerim sync command is the hot path for memory extraction. It discovers new agent sessions from connected platforms, indexes them, enqueues them for processing, and runs DSPy extraction to create decision and learning primitives.
This is a service command - it requires a running Lerim server started via
lerim up or lerim serve.Syntax
What it does
- Scans connected platforms - Checks session stores for new transcripts (e.g.
~/.claude/projects/*.jsonl) - Indexes sessions - Adds new sessions to the internal SQLite catalog (
~/.lerim/index/sessions.db) - Enqueues for extraction - Marks unprocessed sessions for DSPy extraction
- Runs extraction - Processes up to
max_sessions(default: 50) using DSPy chain-of-thought:- Extracts decision candidates (choices made)
- Extracts learning candidates (insights gained)
- Deduplicates - Compares candidates against existing memories
- Writes memories - Creates new markdown files in
<repo>/.lerim/memory/decisions/andlearnings/
Time window control
The time window determines which sessions are scanned. You can specify:- Relative duration (e.g.
7d,24h,30m) - scan recent sessions - Literal
all- scan every session ever recorded - Absolute bounds (
--since/--until) - precise ISO-8601 timestamps
Duration format
s- secondsm- minutesh- hoursd- days
30s, 2m, 1h, 7d, 30d
Parameters
Time window for session discovery. Accepts:Default:
- Duration:
30s,2m,1h,7d,30d - Literal:
all(scan every session)
--since is set.sync_window_days from config (usually 7d)Absolute start bound (ISO-8601 timestamp). Overrides Format:
--window.YYYY-MM-DDTHH:MM:SSZ (UTC)Absolute end bound (ISO-8601 timestamp). Only used with Default: Current time (now)
--since.Target a single session by its run ID. Bypasses the normal index scan and fetches this session directly.Use with
--force to re-extract a specific session.Comma-separated list of platforms to sync. Omit to sync all connected platforms.Platform names:
claude, codex, cursor, opencodeMaximum number of sessions to extract in one run.Default:
sync_max_sessions from config (usually 50)Index and enqueue sessions but skip DSPy extraction entirely. Useful to populate the queue without creating memories yet.
Force re-extraction of sessions that were already processed. Without this, already-extracted sessions are skipped.
Preview mode: skip all writes (no indexing, no enqueuing, no extraction). Shows what would happen without changing anything.
Skip the filesystem writer lock. Useful for debugging, but risks corruption if another sync is running concurrently.
Examples
Standard usage
Platform filtering
Absolute time bounds
Re-extract a session
Preview mode
Queue population
Batch processing
Output
Human-readable:Memory extraction flow
For each session:- Read transcript - Load session JSONL from agent platform
- Window transcript - Chunk large transcripts to fit model context window (300K tokens)
- Extract candidates - Run DSPy chain-of-thought:
- Decision extraction: “What choices were made?”
- Learning extraction: “What insights were gained?”
- Deduplicate - Compare candidates against existing memories by title/body similarity
- Lead decision - Runtime agent determines:
add,update, orno-op - Write memory - Create markdown file in
<repo>/.lerim/memory/decisions/orlearnings/
Where memories are written
Memories are project-scoped by default:Sync vs maintain
| Command | Path | What it does |
|---|---|---|
lerim sync | Hot path | Index sessions, extract new memories |
lerim maintain | Cold path | Refine existing memories (merge, archive, decay) |
- Sync runs frequently (default: every 10 min in daemon mode)
- Maintain runs less often (default: every 60 min in daemon mode)
Exit codes
| Code | Meaning |
|---|---|
0 | Sync completed successfully |
1 | Server not running or runtime error |
2 | Usage error (invalid arguments) |
4 | Lock busy (another sync is running) |
Related commands
lerim connect- Connect agent platforms before syncinglerim maintain- Refine memories after syncinglerim daemon- Run continuous sync + maintain looplerim status- Check sync queue statuslerim up- Start server before syncing
Troubleshooting
”Lerim is not running”
Start the server first:No sessions found
Check:-
Are platforms connected?
-
Do session stores exist?
-
Is the time window too narrow?