shmem import
Import conversation history or local files into shmem from these sources:
--from |
What it imports |
|---|---|
claude-code |
JSONL transcripts from ~/.claude/projects/ |
cursor |
Cursor IDE chat history from ~/Library/Application Support/Cursor/User/ |
codex-cli |
OpenAI Codex CLI rollouts from ~/.codex/sessions/ (or $CODEX_HOME) |
cline |
Cline VS Code extension + Cline CLI conversation history |
chatgpt |
One-shot import from a ChatGPT export .zip (auto-detected under ~/Downloads/) |
github |
The auth'd user's PRs, issues, and review comments via the gh CLI |
files |
One fact per paragraph from .md / .txt (or anything via --include) files and directories. Pipe-friendly — accepts paths via positional args or stdin. |
snapshot |
A project's memory exported as NDJSON, one fact per line, keeping each fact's original date and metadata. Reads a file, or - for stdin. |
agentgateway |
LLM conversations from an agentgateway request-log database (--db) |
Common flags:
| Flag | Description | Default | Applies to |
|---|---|---|---|
-p, --project |
Target shmem project (creates if missing) | Current project (via .shmem/project walk-up), then default |
all |
--dry-run |
Show what would be imported without writing | — | all |
--since YYYY-MM-DD |
Only import items after this date | — | claude-code, cursor, codex-cli, cline, chatgpt, github, agentgateway |
--from agentgateway
Backfills conversations an agentgateway proxy has already recorded, so a team that runs one has memory on day zero instead of after a month of capture.
shmem import --from agentgateway --db ./agw-logs.db --dry-run # preview
shmem import --from agentgateway --db ./agw-logs.db --since 2026-08-10
shmem import --from agentgateway --db ./agw-logs.db --include-system
| Flag | Description |
|---|---|
--db |
Path to the agentgateway request-log SQLite file (required) |
--limit |
Stop after this many rows (0 = all) |
--include-system |
Also import system-role prompts, which repeat on every call |
Requires the gateway to be persisting requests, with content capture on:
config:
database: { url: /var/lib/agentgateway/logs.db }
logging:
database: { url: /var/lib/agentgateway/logs.db }
frontendPolicies:
accessLog:
database:
llm: full # without this, rows carry metadata but no conversation
Two limits worth knowing before you plan around this:
- Conversations only. agentgateway writes this table for LLM (
aibackend) traffic. MCP tool calls never reach it, so historical tool activity is not recoverable — onlyshmem gateway servesees those, live. - Postgres is not supported yet. agentgateway treats a
postgres://URL as Postgres and anything else as SQLite; shmem reads the SQLite form.
Identity comes from the gateway's agentgateway_user and agentgateway_group
columns, which are populated only when an auth policy (apiKey, jwtAuth,
basicAuth) is attached to the route carrying the traffic. A route with no
auth policy yields anonymous facts.
--from claude-code
shmem import --from claude-code # one shmem project per Claude project dir (default)
shmem import --from claude-code --project mywork # all Claude history into one shmem project
shmem import --from claude-code --dry-run # preview
shmem import --from claude-code --since 2026-01-01 # only sessions after this date
shmem import --from claude-code --claude-project "-Users-me-repos-myrepo" # filter
| Flag | Description | Default |
|---|---|---|
--claude-project |
Filter to a specific Claude project directory name | — |
Without --project, each Claude project directory becomes its own shmem project. With --project, all sessions land in one project. Parse-and-insert — no LLM calls, so it's fast.
--from cursor
shmem import --from cursor # one shmem project per Cursor workspace (default)
shmem import --from cursor --project mywork # all Cursor history into one shmem project
shmem import --from cursor --since 2026-01-01 # only sessions after this date
shmem import --from cursor --dry-run # preview
Reads Cursor's local chat database under ~/Library/Application Support/Cursor/User/. Without --project, each workspace folder becomes its own shmem project (named from the workspace path). With --project, all sessions land in one project.
--from codex-cli
shmem import --from codex-cli # all rollouts, routed per-cwd into shmem projects (default)
shmem import --from codex-cli --project mywork # all rollouts into one shmem project
shmem import --from codex-cli --since 2026-04-21 # only sessions after this date
shmem import --from codex-cli --dry-run # preview
Walks ~/.codex/sessions/ (or $CODEX_HOME/sessions/) for rollout JSONL files. Without --project, each session is routed into a shmem project derived from the session's recorded cwd. With --project, all sessions land in one project.
--from chatgpt
shmem import --from chatgpt # auto-detect chat-data*.zip in ~/Downloads/
shmem import --from chatgpt ~/Downloads/chat-data.zip # explicit path
shmem import --from chatgpt ~/Downloads/chat-data.zip --project mywork
shmem import --from chatgpt --since 2026-01-01
shmem import --from chatgpt --dry-run
One-shot import (not realtime) of a ChatGPT export archive. Get the archive at chat.openai.com/settings → Data Controls → Export — OpenAI emails you a download link to a .zip containing conversations.json. The importer reads that file and emits one fact per user / assistant text turn on the main thread of each conversation (forks abandoned via the in-app edit button are skipped via current_node walk).
| What's imported | What's skipped (counted, not failed) |
|---|---|
Text turns from user and assistant authors |
system / tool author turns |
content_type=text content |
multimodal_text (images), code interpreter output, tether_quote, etc. |
Without --project, facts land in the current project (via the .shmem/project walk-up, then default); there's no per-conversation routing because ChatGPT exports carry no cwd / workspace hint. With --project, every fact gets that tag.
Auto-detection scans ~/Downloads/ for chat-data*.zip (older OpenAI naming) and data-*-batch-*.zip (current naming, mid-2026); ambiguous matches fail with a list so you can pick one explicitly.
--from github
shmem import --from github # everything you authored, into the current project
shmem import --from github --per-repo # one shmem project per GitHub repo
shmem import --from github --org acme # restrict to a single org
shmem import --from github --repo acme/api --repo acme/web # restrict to specific repos (repeatable)
shmem import --from github --since 2026-01-01 # only items after this date
shmem import --from github --dry-run # preview
| Flag | Description | Default |
|---|---|---|
--per-repo |
Route each GitHub repo into its own shmem project, named owner-repo |
false (everything into the current project) |
--org |
Restrict to all repos in a single organization | — |
--repo OWNER/REPO |
Restrict to specific repos (repeatable) | — |
Pulls your own GitHub writing via the gh CLI — you must have gh installed and authenticated (gh auth login). If gh is missing or logged out, the import prints a note and exits without importing anything.
What it imports. The search is scoped to --author=@me, so the corpus is the PRs and issues you opened, plus the bodies of your own comments and reviews on them. Two consequences worth knowing before you rely on it:
- Review work on other people's PRs is not imported. A PR someone else opened, where you left a detailed review, never enters the corpus — the search never surfaces it.
- Only your side of a thread is kept. Replies from other people are filtered out, so an issue you filed imports your question but not the maintainer's answer.
Facts carry no diffs, patch content, or commit messages — titles and prose only. Each is tagged imported_from=github with the repo, item number, and URL in metadata, and timestamped with the item's GitHub creation time. Re-running is safe: imports dedupe on content, so unchanged items are skipped.
Note that --since filters on when an item was created, not when you last touched it — a long-running issue opened before the cutoff is excluded even if you commented on it yesterday.
--from files
shmem import --from files ~/notes ~/docs # walk dirs into the current project
shmem import --from files --project notes ~/notes # into a named project
find ~/notes -name '*.md' | xargs shmem import --from files -p notes
find ~/notes -name '*.md' | shmem import --from files -p notes # or via stdin (no positionals)
shmem import --from files --include .md,.org ~/notes # custom extensions
| Flag | Description | Default |
|---|---|---|
--include |
Comma-separated extensions for directory walks. Explicitly-named files are always ingested regardless. | .md,.txt |
One fact per paragraph (paragraphs separated by blank lines). Paragraphs shorter than 10 characters are skipped. Each fact carries source_file=<path> metadata. Timestamps come from each file's mtime so re-importing the same file dedupes correctly.
If no positional args are given, shmem import --from files reads newline-separated paths from stdin until EOF — designed for find ... | xargs ... and find ... | shmem import ... workflows.
Symlinks: a link inside a folder you import is followed only when its target is inside that folder too, so a linked notes vault imports whole while a link out to, say, ~/.aws/credentials does not. A symlinked file passed directly (including from find) is skipped and listed; pass its target to import it. A symlinked folder passed directly is imported from its target.
--from snapshot
shmem import --from snapshot shmem-history.ndjson --project shmem-history # into a project of its own
shmem import --from snapshot --dry-run shmem-history.ndjson # count, write nothing
cat history.ndjson | shmem import --from snapshot -p history - # from stdin
A snapshot is a project's memory as a file, such as one downloaded from a public history page: NDJSON, one fact per line. Each line is a JSON object:
| Field | Required | Meaning |
|---|---|---|
content |
yes | The fact's text |
timestamp |
no | RFC 3339 time or YYYY-MM-DD. Facts keep their own dates, so the history keeps its shape; a missing or unreadable time becomes now |
source |
no | user, llm, or tool (default tool) |
id |
no | The fact's id in the snapshot, kept as snapshot_id metadata |
metadata |
no | Key/value pairs; string values are kept, others dropped. Keys that record the exporting store's own state (via, replica, author_stamp, and copies of the identity fields below) are dropped too |
Rows saved from the list_facts_since MCP tool load as they are. Their ownership and placement fields (owner_user, caller_user, caller_agent, project, dedup_key) are ignored: you own what you import (facts are stamped with your SHMEM_CALLER_USER, like other imports), and it lands in --project, or your current project if you don't pass one. Pass --project to keep a memory you load apart from your own. Records whose metadata.kind is share-event are sharing bookkeeping and are skipped, as are lines that aren't a JSON object with content. Each fact gets imported_from=snapshot and an import_key derived from the record, and loading the same snapshot twice imports nothing new.