This page describes dx 0.15.1.
dx from scripts: the read and action contract
This page is for anyone who drives dx from a program: a script, an editor extension, a dashboard. It covers two things:
- Reading.
dx sessions --jsonprints every session, group, device and contact as one JSON document. - Acting. Every verb can run without a terminal and never asks a question there. Many verbs print one JSON result with
--json, and every verb exits with a code that says what happened.
For the commands themselves, see the docs or dx help <command>.
What you can rely on
From dx 0.13.0, three things are stable:
- The read document:
dx sessions --json, with--here,--scanand--transcripts, at contract 1.0. That is every field, value and rule under Reading below. - The exit codes: the table under Exit codes, and the cases this page gives each code.
- The no-question rule: without a terminal, or with
--no-input,DX_NO_INPUT=1or--json, dx never asks. Where it would have asked, it exits 5 and names the flag that answers.
These stay dx's own, and may change in any release:
- the
--jsonresults of the verbs (Results); - the order in which a target is matched, beyond what exits 3 and 4 mean;
- the
dx sessionslist for people; - every message and help line.
What counts as a change. Adding a field or a value raises the contract's minor version (1.0 to 1.1), and can come in any dx release. Renaming, removing or retyping a field, or changing what one means, raises the major (2.0). An exit code keeps its cases: giving a case another code, or a code another meaning, is a breaking change, and a new code is only for a case that didn't exist before, such as a new verb or flag. The no-question rule never weakens: no release adds a question without a terminal. A fix that makes dx do what this page says is not a change, even when a script relied on the bug. Nor is a change to anything this page calls dx's own.
Notice. A breaking change is announced in the Notes of an earlier release's changelog entry, at least one minor release and at least 30 days before the release that makes it. This page then marks the part that will change with one quoted line right under it, always of the form > **Changes in 0.N.0:** …, naming that release. A security fix may come without notice. Its changelog entry says why.
Conventions
nullmeans "unknown" or "doesn't apply". It is never written as""or-.- Timestamps are integer epoch seconds. Numbers are integers, never quoted.
- Booleans are JSON booleans.
- Paths are absolute. On Windows they use the
C:/…form. - No string contains a control character, so values are safe to print to a terminal. Invalid UTF-8 in old stored text shows up as U+FFFD.
- A session's short id is the first 8 characters of its id. It's what dx prints in its messages; it isn't a separate field.
- dx keeps its files in
~/.dx, or in$DX_HOMEwhen that is set. This page writes~/.dxfor either.
Reading: dx sessions --json
dx sessions --json [--here <folder>] [--scan] [--transcripts]
dx sessions # a list for people; its format may change
| Flag | Effect |
|---|---|
--json | Print the document on stdout, and nothing else there. Needs Node.js. |
--here <folder> | Add current to every session: whether it belongs to that folder (see the session table). A missing folder argument is exit 2; a folder that doesn't exist is exit 3. |
--scan | Check which sessions are open on this device before printing, instead of using the last check. Slower: on Windows it runs tasklist.exe. When dx can't read the list of processes, or any Claude home, the answer is the last check's, with a note on stderr. |
--transcripts | Read each transcript to fill in transcript.messages and transcript.started_at. Results are cached, so later runs are cheaper. Without the flag both are null. |
What's on stdout. With --json, stdout carries exactly one JSON object: the document, or an error result (see Results). The exit code follows the table under Exit codes. A store with no sessions is still a valid document ("sessions": []) and exit 0. Without Node.js, dx sessions --json exits 1 with a hint on how to install it.
Is this dx new enough? The promise above starts with dx 0.13.0. A 0.12 dx prints the same contract 1.0 document, without the promise. A dx older than 0.12.0 answers dx sessions --json with its help text and exit 0. So don't trust exit 0 alone: check that stdout starts with {, or that contract is present. dx version tells you which dx you're talking to.
It reads, nothing else. dx sessions --json never changes your sessions. Its caches live under ~/.dx/run/, never in the synced ~/.dx/data/.
The document
{
"contract": "1.0",
"dx": { "version": "0.13.0", "build_ref": "abc1234" },
"generated_at": 1760000000,
"self": { "device_id": null, "name": "mini", "os": "macos", "boot_epoch": 1759990000 },
"constants": { "wake_since_default": 259200, "connect_online_window": 420,
"ledger_scanned_at": 1759999000, "ledger_retain": 2592000 },
"palette": { "red": "#e06c75", "green": "#98c379", "yellow": "#e5c07b", "blue": "#61afef",
"purple": "#c678dd", "cyan": "#56b6c2", "orange": "#d19a66", "pink": "#e88fb2",
"tan": "#c2a678", "gray": "#7f848e" },
"ui": { "page_path": "C:/Users/me/.dx/data/ui.html", "built_at": 1759998000, "listed": ["..."] },
"devices": [ ... ],
"contacts": [ ... ],
"groups": [ ... ],
"sessions": [ ... ]
}
| Field | Type | Meaning |
|---|---|---|
contract | string | The document's version, "<major>.<minor>", separate from dx's own version. "1.0" since dx 0.12.0. |
dx.version | string | The dx that printed it. |
dx.build_ref | string or null | The commit the release was built from; null in a source checkout. |
generated_at | int | When the document was printed. |
self.device_id | string or null | This device's id when dx connect is set up, else null. Find this device by devices[].self, not by id. |
self.name | string | This device's name: the one set with dx connect name, else one made from the host name. |
self.os | string | windows, macos, linux, wsl or other. |
self.boot_epoch | int or null | When this device last booted; null when dx can't tell. |
constants.wake_since_default | int | How far back dx wake looks: 259200 (72 hours). |
constants.connect_online_window | int | How recently a device must have been heard from to count as online: 420 seconds. |
constants.ledger_scanned_at | int or null | When dx last checked which sessions are open here. null when it never has: then treat open.here and wakeable.ok as unknown, not as false. To get a fresh answer, pass --scan. |
constants.ledger_retain | int | How long dx remembers that a session was open: 2592000 (30 days). |
palette | object | The ten color names dx color accepts, each as a lowercase #rrggbb. |
ui.page_path | string or null | The page dx ui builds, when it exists. |
ui.built_at | int or null | When that page was last built. |
ui.listed[] | array or null | The ids of the sessions that page lists; null when there is no page. |
devices[] | array | This device first, then paired devices by name. See Devices. |
contacts[] | array | People you shared sessions with. See Contacts. |
groups[] | array | Sorted by id. See Groups. |
sessions[] | array | Newest first (by ts). See Sessions. |
Never in the document: pairing and share codes, connection tickets, keys, host addresses and transcript content. Device ids are addresses that dx connect already prints, not secrets.
Sessions
{
"id": "3f2a9c1e-7b4d-4e8f-9a2b-1c3d5e7f9a0b",
"ts": 1759900000, "type": "snap", "claimed": true, "agent": "claude",
"repo": { "path": "C:/Users/me/proj", "name": "proj", "remote": "github.com/me/proj", "git": true },
"commit": "a1b2c3d", "branch": "feature/x",
"name": "viewer fixes", "named": true, "explicit": true, "title": "viewer fixes",
"group": { "id": "proj", "label": null },
"origin": { "kind": "self", "device_id": null, "name": "mini", "shared_from": null },
"color": { "hex": "#c2a678", "name": "tan" },
"open": { "here": false, "devices": [ { "device_id": "<hex64>", "seen": 1759999900 } ] },
"wakeable": { "ok": true, "last_seen": 1759990000, "before_reboot": false, "cwd": "C:/Users/me/proj",
"folder_missing": false, "spawned_recently": false },
"transcript": { "path": "C:/Users/me/.claude/projects/C--Users-me-proj/3f2a9c1e-….jsonl", "size": 48213,
"mtime": 1759995000, "started_at": null, "blob_mtime": null, "messages": null },
"last_active": 1759995000,
"holders": [],
"current": true
}
| Field | Type | Meaning |
|---|---|---|
id | string | The session's id, a lowercase uuid. It's the id Claude Code uses: claude --resume <id> opens it. |
ts | int | When dx last recorded the session (a snap, a commit, an arrival from another device). |
type | string | snap: you snapped it, or claimed an auto session by naming, coloring or grouping it. auto: the commit hook started it, or it's a clone that hasn't run yet (below). live: it is open on another device that never snapped it; opened here, it opens as a clone unless you take it over (see One place at a time). A clone that dx fork starts is auto until it has run. The next time dx records anything (a commit, dx snap, dx wake, dx tidy, an auto-sync tick) it becomes a snap. Until then dx sessions --json can show it as auto with a transcript. |
claimed | bool | True for a session you snapped or named (coloring or grouping an auto session makes it a snap); false for an auto nobody touched: one the commit hook started, or a clone that hasn't become a snap yet. dx log, dx tidy and the picker use the same rule. |
agent | string or null | The coding tool that ran the session (claude today). |
repo.path | string | The folder the session belongs to: the repo's top level, or a plain folder. |
repo.name | string | The repo's name, from its remote, else the folder's name. Also the default group. |
repo.remote | string or null | The remote without its scheme, user and .git, e.g. github.com/me/proj. |
repo.git | bool | True when the session has a commit, a branch or a remote. A live session is always false here, which says nothing about its folder. |
commit | string or null | The commit the session was recorded at, as stored: the 40 hex digits dx snap and a fork's clone keep (a SHA-256 repository's 64 are cut to 40), or the shorter form the commit hook and older versions wrote. dx shows 7 characters of a whole hash, and a shorter one as it is. |
branch | string or null | The branch; null on a detached HEAD. |
name | string or null | The session's name (at most 120 characters). |
named | bool | name is not null. |
explicit | bool | A person gave the name: dx name, the picker, or a /rename in Claude Code. An explicit name sticks: a re-snap or an older /rename never replaces it; a newer /rename does (the latest choice wins). False for names dx took from the first message or the commit. |
title | string | What to show: name, else branch, else repo.name. |
group.id | string | The group: its label, else repo.name. dx log --group and dx color -g match it ignoring the case of A to Z. |
group.label | string or null | The label someone set with dx group; null for the default group. |
origin.kind | string | self: made here. device: came from one of your devices (even one you later unpaired). contact: someone shared it with you. |
origin.device_id | string or null | The device it came from, for device. That device may no longer be in devices[]; use origin.name then. |
origin.name | string | This device's name, the source device's name, or the name of the person who shared it. |
origin.shared_from | string or null | Who shared it with you, whenever it arrived as a share. |
color.hex | string or null | The color set with dx color, lowercase #rrggbb. |
color.name | string or null | Its palette name, or null for a custom color. |
open.here | bool | Open on this device at the last check (constants.ledger_scanned_at), or now with --scan. Any run of it counts: in a terminal, in the background (claude --bg or claude -p), in an IDE or in the desktop app, under any Claude home dx knows (see Claude's home). A session recorded in a home dx can't read says false here, as this field has no word for "can't tell". |
open.devices[] | array | {device_id, seen} for each online device where it is open, by the same rule. |
wakeable.ok | bool | dx wake would reopen it: it was open in a terminal within the last 72 hours, isn't open now, and dx didn't just open it in a tab (spawned_recently). A session that only ran in the background, an IDE or the desktop app isn't wakeable. Being open on another device doesn't change this. |
wakeable.last_seen | int or null | When it was last seen open here. |
wakeable.before_reboot | bool | It was last seen open before this device last booted. |
wakeable.cwd | string or null | The folder it was open in. |
wakeable.folder_missing | bool | That folder no longer exists. |
wakeable.spawned_recently | bool | dx opened it in a new tab within the last minute: dx wake, dx open, or for a clone dx fork --open. So a clone that is still starting already shows here. |
transcript.path | string or null | The transcript dx would use: the newest copy under ~/.claude/projects/ ($CLAUDE_CONFIG_DIR/projects/ when that's set, see Claude's home), else the copy dx keeps for a session from another device, else null (there is none in this run's home or in dx's copies on this device). |
transcript.size, transcript.mtime | int or null | Its size in bytes and when it last changed. |
transcript.started_at | int or null | With --transcripts: when the conversation started. |
transcript.blob_mtime | int or null | When dx's own copy (from another device) last changed. |
transcript.messages | int or null | With --transcripts: how many user and assistant messages it holds. null means "not counted"; it never means zero. |
last_active | int | The latest of ts, transcript.mtime and transcript.blob_mtime. |
holders[] | array | Ids of your other devices that hold a copy of this session or have one on its way: the device it came from, and every device dx has queued it for (the whole session or only its details). Queued isn't delivered. Never this device, never a contact. To count copies including this device, add one. |
current | bool | Only with --here: the session belongs to that folder. That's when the folder's remote matches the session's; or, for a folder with no remote, the same path or (in a git repo) the same folder name; or when the folder's Claude project directory has a copy of the transcript. |
Groups
{ "id": "proj", "label": null, "folder": false, "members": [ "<id>", "..." ] }
| Field | Meaning |
|---|---|
id | The same string as sessions[].group.id. A group with no sessions isn't listed. |
label | The label someone set, or null for a default group. |
folder | True when none of its sessions (other than live ones) is in a git repo. |
members[] | Its session ids, in sessions[] order. |
Devices
{ "id": "<hex64>", "name": "mini", "self": false, "os": { "raw": "Darwin", "kind": "macos" },
"state": "online", "last_seen": 1759999900, "version": "0.13.0", "sessions": 12,
"open": [ { "id": "<uuid>", "name": "viewer fixes", "cwd": "/Users/me/proj", "seen": 1759999900 } ] }
| Field | Meaning |
|---|---|
id | The device's id from dx connect. null for this device when dx connect was never set up. Join sessions and devices by id, never by name. |
name | Its name, or the first 8 characters of its id followed by …. |
self | True for this device, which always comes first and is always online. |
os.raw, os.kind | What the device reports (Darwin, Linux, MINGW64_NT…), and the same five kinds as self.os. |
state | online (heard from within connect_online_window), seen (heard from before that), or pending (paired, never heard from). |
last_seen | When it was last heard from; null for pending. |
version | The dx version it last reported, or null. |
sessions | How many sessions came from it (for this device: the ones made here or shared with you). dx connect prints the same numbers. |
open[] | What it reports as open: {id, name, cwd, seen}, whatever its state, so you can apply the online rule yourself. sessions[].open.devices already does. |
Contacts
{ "id", "name", "last_seen" } for each person you shared with or received from. name and last_seen may be null.
Values you don't know
A newer dx may print values an older script hasn't seen. Read them as the nearest known one: an unknown origin.kind as device (with no devices[] record), state as seen, type as auto, os.kind as other, and an error code as error. Ignore fields you don't know.
Versions
contract is "<major>.<minor>". Adding a field or a value raises the minor; renaming, removing or retyping a field, or changing what one means, raises the major (see What you can rely on). So a script checks the major: one it doesn't know is a document it can't read. A newer minor only adds, so a script reads it and ignores what it doesn't know.
Acting: verbs from a script
The exit codes and the no-question rule below are stable. The --json results are dx's own: read them, but expect them to change in any release.
Which session a target names
resume, fork, open, drop, name, color, group, send and share take a session the same way. dx tries, in order:
- In
resume,forkandwakeonly: a number of up to 9 digits is a position in the list. A number past the end of the list falls through to the next rules. - A full id, in any case.
- An exact name.
- The first 4 or more characters of an id, when only one session starts with them.
- A name in any case, when only one session has it.
When more than one session matches, dx exits 4 and lists them. A name never loses to an ambiguous prefix. A script passes the full id: it always matches exactly one session, and it can never be read as a list number.
The order above is dx's own and may change. What stays is what the codes mean: no match is exit 3, more than one is exit 4.
snap is the exception: it finds a Claude Code session that dx hasn't saved yet, so it also takes any part of an id or of its /rename title. send and share also take a session that is open here but was never snapped. Groups match ignoring the case of A to Z alone, as dx log does: CAFÉ and café are two groups. color and wake take a group too: a target that names no session is read as a group's name, and --group reads it as one straight away. In wake, a number is always a position in the list, and wake <group> <n> is position n in that group's list. A wake target like an id (four or more hex digits and dashes, nothing else) is never read as a group: when no session has it, it is exit 3, and --group reaches a group of that name.
A device (send, connect forget) or a friend (share, share forget) is named by its full id, 64 hex characters in any case; else by its name in any case; else by the first 4 or more characters of its id, when only one has them. Two with that name, or a prefix two share, is exit 4 with each listed, and nothing is done. A trailing …, as dx shows a device with no name, is ignored, so what dx connect prints can be pasted back.
No questions without a terminal
When stdin isn't a terminal, dx never asks. Where it would have asked, it exits 5 and names the flag that answers the question (run: dx resume -y <id>), and nothing is changed.
-y/--yesanswers every question a verb has.--no-input, right afterdxor after the verb, orDX_NO_INPUT=1in the environment, turns questions off even at a terminal.--jsondoes too.DX_INTERACTIVE=1asks anyway, for a terminal that reports itself as a pipe.- Reading stdin as data isn't a question:
dx feedback < note.mdanddx receiveof a piped bundle work as before.
The session picker needs a console. Without one, dx exits 5 with a hint: pass a target instead.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Done, including when there was nothing to change (setting a color a session already has). wake: at least one tab opened, or nothing needed reopening (for wake --from, also when everything open on that device is already open here). |
| 1 | Any other error. wake, open and fork --open: no terminal tab could be opened. fork --open: Claude Code is older than 2.0.73, or dx can't read its version. send: nothing could be queued for any device. resume and open: the session is already open on this device; it is open on another device and open-elsewhere is refuse; the copy here is behind and couldn't be brought up to date, or its newer lines haven't arrived; the copies have gone separate ways (see One place at a time). open: a clone in a new tab needs Claude Code 2.0.73. resume, open, fork and fork --open: the session is in another Claude home, or --copy-in can't copy it. resume and open: the session is recorded in a Claude home dx can't read. wake, with --list or --scan too: dx can't read any Claude home (see Claude's home). With --worktree, the refusals marked 1 in its table. |
| 2 | Usage: an unknown flag or command, a missing argument, a value that isn't allowed. |
| 3 | Not found: no session, device, friend or group matched; for open and fork --open, the session's folder is gone; with --worktree, no folder on this device holds the session's repo, or the commit isn't in it (rebased away, or never pushed); for wake --from, a session named that isn't open on that device, or whose repo isn't on this device. |
| 4 | Ambiguous: more than one session, device or friend matched. The candidates are listed. With --worktree, a short hash that now matches more than one commit. |
| 5 | Needs a person: dx would have asked (stdin isn't a terminal, or --no-input) and -y wasn't given; or the picker had no console. Nothing was changed. Among the questions: a clone under open-elsewhere ask, and a take-over of a copy known to be behind. |
| 6 | Cancelled: someone answered no, or pressed Esc in the picker. |
| 128+N | Stopped by signal N (130 after Ctrl-C). |
Errors also print error: … on stderr. An unknown command prints the help on stderr and exits 2. dx help, -h and --help print to stdout and exit 0, and so does dx <command> --help.
Results: --json
snap, drop, name, color, group, wake, tidy, send, receive, config, ui, open, fork and doctor take --json. Each then prints one JSON object on stdout and nothing else there. Progress lines still go to stderr. --json also means --no-input. These results are dx's own and may change in any release (see What you can rely on).
{ "ok": true, "verb": "color", "id": "3f2a9c1e-7b4d-4e8f-9a2b-1c3d5e7f9a0b", "name": "viewer fixes",
"color": "#61afef", "changed": true, "message": "Color for 3f2a9c1e set to #61afef — dx wake will reopen it colored" }
{ "ok": false, "verb": "open", "exit": 4, "error": "ambiguous", "changed": false, "spawned": false,
"candidates": [ { "id": "3f2a9c1e-…", "title": "viewer fixes" }, { "id": "3f2a7777-…", "title": "feature/x" } ],
"message": "'3f2a' matches 2 sessions — pick one by its id:" }
| Field | Meaning |
|---|---|
ok | true exactly when the exit code is 0. |
verb | The verb as you typed it. |
id, name | The session acted on. null for verbs that act on several (tidy, color -g, wake), which carry ids[] and count instead. |
changed | Whether anything changed. Doing what was already done is ok: true, changed: false. |
message | The text dx would have printed for a person. |
exit, error | On failure: the exit code and a short word for it: usage, not_found, ambiguous, needs_confirmation, cancelled or error. |
candidates[] | {id, title} for each match when the target was ambiguous; for a device or a friend, title is the name as dx connect shows it. For tidy --dry-run, the sessions it would remove. |
spawned | open and fork: a terminal tab was opened. wake: at least one was. No process id is given: dx never learns one. |
command | open: the (cd '<folder>' && claude --resume <id>) line to run, whenever dx printed it instead of opening a tab (--terminal print, VS Code, --dry-run, a tab that failed to open, or a path a tab can't carry); else null, and null too when the path of its folder or of its Claude home holds bytes dx does not print (skipped says which). fork gives the line that starts the clone, which ends in --fork-session --session-id <clone_id>. wake gives the same per session in results[]. Each carries CLAUDE_CONFIG_DIR='<home>' before claude only when that variable is set to an absolute path (see Claude's home). |
ids[], count, spawned_count, skipped_count, results[] | wake: the sessions it chose, how many tabs it opened and how many sessions it skipped, and per session {id, spawned, terminal, command} with the fields below (clone_id to skipped). skipped at the top level is the same count as skipped_count, kept for scripts written for 0.13. |
group | wake: the group it took the sessions from (dx wake <group> or --group), as dx group --json gives it: the label cleaned as dx group stores one (no control character, no byte that isn't UTF-8, at most 40 characters), else the repo's name. It may differ in case from what was typed. A label synced from elsewhere can hold a byte that isn't UTF-8, which dx log --group and dx wake --group still match on, so to name that group again, use the name as typed. null when no group was named. |
clone_id | fork: the id the clone has, which dx makes before Claude Code starts. id and name are the session it was forked from. open and wake give one too when they open a clone because the session is open on another device. null when no clone was made. |
reason, device | open, fork and each wake result: reason is open_elsewhere when it opens, or would open, as a clone because the session is open on another device, and device is that device: {id, name, online, last_seen, version}, with last_seen on this device's clock and version its dx. device is null when dx can't tell which device (it then opens a clone all the same). With --worktree, reason says why dx couldn't make the worktree (see At its commit, in its own worktree). |
took_over | open and each wake result, with --take-over: {id, name, online, last_seen, behind_bytes, behind_from}. id to last_seen are the device the take-over is from, the one its line names first: the device dx heard from last for resume, open and the local wake, or the device named with wake --from. The others follow in the order they were paired. A session open on several devices is taken over from all of them, and behind_bytes is how many bytes the copy here was missing against the one furthest ahead (null when none reported a size). behind_from is that device, {id, name}, or null when behind_bytes is 0 or null, so a gap is never read as another device's. id and name are null when dx couldn't tell which device. A printed command's result has it too, saying what running the command does. Else null. |
copy, behind_bytes, copy_mtime | open, fork and each wake result: what dx knows of the session's copy on this device, against the newest size another device reported for it. current: nothing that report holds is missing here (the copy here may hold more), and behind_bytes is 0. behind: it is missing the last behind_bytes bytes of that report, or behind_bytes is null when the two don't line up or have gone separate ways. unknown: dx can't tell (no device reported a size, or the newest report came from a dx before 0.14), and behind_bytes is null. none: there is no copy here. copy_mtime is when the copy here last changed, or null. |
skipped | open, fork --open and each wake result: why nothing opened, or null: open_here (open on this device), open_elsewhere (open on another device, and open-elsewhere is refuse), behind (the copy here is behind), diverged (the copies have gone separate ways), folder_missing (the session's folder is gone), folder_unusable (the path of the session's folder holds a control character, so dx can't use it), claude_too_old (a clone in a new tab needs Claude Code 2.0.73), other_home (it's recorded in another Claude home and this one has no copy; open and fork take --copy-in, see Claude's home) open_unknown (it's recorded in a Claude home whose sessions folder dx can't read, so dx can't tell whether it's open there, see Claude's home), folder_unprintable (the path of the session's folder holds bytes dx does not print, so dx printed no command for it, and command is null) or home_unprintable (the same for the path of the Claude home it would carry). wake --from adds no_copy (no copy of it on this device yet) and no_repo (no folder here holds its repo). Read a word you don't know as "not opened". |
worktree, reason | open and fork: with --worktree, {path, branch, commit, created, repo}: the worktree the tab starts in; the branch it is on now (null when its HEAD is detached); the full hash its HEAD is at now (for a new worktree, the commit dx made it at); whether this run made it (a reuse says false); and the main checkout it belongs to (the repo the worktree was made from, which may be another clone of the session's remote than the folder dx ran in). Else null. After --dry-run, created is false and path, branch and commit are the ones dx would use (the full hash; when the commit would first need a fetch, which a dry run doesn't do, commit is the one the session has, as stored). The session's own commit is in dx sessions --json. When dx can't make one, reason says why (see At its commit, in its own worktree). |
queued, results[] | send: whether any device got it queued, and one item per device the send aimed at (see dx send). |
Verbs add their own fields beside these: name gives explicit, color gives color, group gives group and explicit, open and fork give terminal and cwd (the folder the tab starts in), and drop gives worktrees[] (see dx drop). dx ui --json adds page_path, built_at and sessions (how many sessions the page lists).
resume and plain fork hand the terminal over to Claude Code. So resume has no --json, and fork --json means fork --open --json: it starts the clone in a new tab and prints the result. Any other verb given --json exits 2 (dx log --json doesn't pretend to work).
dx name
dx name <session> <name> # set it (alias: dx rename)
dx name <session> --clear # take it off
dx name <session> # show it
- A name is at most 120 characters, with control characters removed. An empty name is exit 2, and so is a name of only hex digits and dashes, which would look like a session id. A name another session already has is allowed, with a warning; a target by that name then matches both: exit 4, with both listed.
- The name sticks. A re-snap never replaces a name a person gave. A newer
/renamein Claude Code does: the latest choice wins, whichever tool it came from. --clearworks on this device only: a later sync can bring the name back.- Naming an
autosession claims it, likedx coloranddx group. dx nametakes no list number (onlyresume,forkandwakedo).
dx open
dx open <session> [--terminal tmux|vscode|wt|iterm|terminal|print] [--cwd <folder>] [--dry-run] [-y] [--take-over] [--copy-in] [--json]
Opens the session in a new terminal tab and returns at once, unlike resume and fork, which take over the terminal you're in.
- The tab uses the terminal
dx wakewould use.--terminalpicks one, and so does theDX_TERMINALenvironment variable.printopens nothing and prints the command instead. - The folder is the one the session was last open in, if that still exists, else its repo folder.
--cwdsets it. A folder that's gone is exit 3, and nothing is changed. - When the folder is a git repo whose history doesn't contain the session's commit, dx asks before it resumes there:
-yanswers, and without a terminal it's exit 5. - Whether it opens the session itself or a clone depends on where else it is open (see One place at a time).
--dry-runonly looks: it opens nothing and records nothing.
dx fork --open
dx fork <session> --open [--terminal <t>] [--cwd <folder>] [--dry-run] [-y] [--copy-in] [--json]
Starts a clone of the session in a new terminal tab and returns, the way dx open opens one. The clone is a new session: it remembers everything so far, then goes its own way, and the original is untouched.
- The clone's id is one dx makes before Claude Code starts, so the result can name it (
clone_id). This needs Claude Code 2.0.73 or newer. With an older one, or a version dx can't read, it's exit 1 and nothing opens. - The terminal, the folder, the commit question and
-ywork as indx open. A session that was never snapped is offered for a snap first, as plaindx forkdoes. --jsonimplies--open.--terminal,--cwdand--dry-runneed--openor--json, else it's exit 2.dx fork --jsonwith no session would open the picker, so it's exit 5.changedis true when dx recorded the clone, which is every fork except--dry-run. The clone is then listed asautountil it has run (seetype).- When dx prints the line instead of opening a tab,
spawnedis false andcommandis that line. Run it once: it starts the clone underclone_id, and a second run fails, because the id is taken by then. After--dry-run, dx has recorded nothing, so a clone started from that line is listed only once it's snapped.
One place at a time
A session is open in one place at a time. Before resume, open or wake opens a session under its own id, dx checks where else it is open. A fork is a new session, so fork makes no such check.
- Open on this device, in any run of it (as
open.herecounts):resumeandopenrefuse, exit 1, with adx forkhint.wakeskips it (open_here). - Open on another device, as far as dx knows: that device's latest presence lists it, or its last word about the session said it was open. It opens as a clone, under an id dx makes, as
dx config open-elsewheresays. Underclone, the default, there is no question, and the result hasclone_id,reason: "open_elsewhere"anddevice. Underask, dx asks first:-yanswers, and with no person to ask it's exit 5. Underrefuse,resumeandopenexit 1, naming both ways on, andwakeskips it (open_elsewhere). - A clone in a new tab needs Claude Code 2.0.73 or newer, since dx names its id:
openexits 1 andwakeskips it (claude_too_old).resumefalls back to Claude Code's plain fork. - dx knows only what each device last said. A session opened on a device that has sent nothing since isn't seen. When dx can't read what the devices said, it counts the session as open elsewhere, and
deviceisnull. --take-overopens the session itself anyway, taken over from every device dx counts it open on, andtook_oversays from which. When the copy here is known to be missing lines of what one of them last reported, dx asks first, against the one furthest ahead:-yanswers, and with no person to ask it's exit 5. dx records a take-over only when it starts Claude Code itself, never for a printed command or a dry run.- The copy here. Before Claude Code starts, dx brings it up to date from the longest copy on this device that continues it. Under the session's own id, dx never opens a copy it knows is behind: when it couldn't bring it up to date, or the newer lines another device reported haven't arrived,
resumeandopenexit 1 andwakeskips it (behind). Copies that have gone separate ways are exit 1 too, or awakeskip (diverged). A clone (dx fork <id>) opens from the copy here as it is, and--take-overgoes on without the missing lines.
copy says what dx knows of the copy here on every open, fork and wake result, whatever opened. It only reports: whether the session opened is spawned and skipped.
dx wake --from
dx wake --from <device> [<n>|<session>] [-y] [--list] [--dry-run] [--terminal <t>] [--take-over] [--json]
Reopens here what is open on another device, each as a clone unless --take-over; open-elsewhere doesn't apply. The device is named the way dx send names one (see Which session a target names).
- No device of that name is exit 3, and two are exit 4. This device's own name,
--sinceor--scanis exit 2. - Unless
--list, dx first asks the device for what it has and receives what it sends, for up to 10 seconds.--dry-runasks too. - The rows are what that device last reported open. Skipped: one already open here (
open_here), one with no copy here yet (no_copy), one with no folder here that holds its repo (no_repo), and, as in the local wake,behind,divergedandclaude_too_old. A copy behind a device that hasn't been heard from lately opens, and says what it lacks. - The exit is 0 when one opened, or when everything open there is open here already. It's 1 when dx has heard nothing from the device about what is open there (
--listgives 0), or when every one was skipped. A session named that can't reopen gives its own: 0 when it's already open here, 1 with no copy here, 3 when it isn't open on that device or its repo isn't on this one. --jsonaddsfrom:{id, name, online, last_seen, version}, the device. Eachresults[]item addscwd, the folder here.--list --jsongives the same shape, withspawnedfalse.
At its commit, in its own worktree
dx open <session> --worktree [--terminal <t>] [--dry-run] [-y] [--copy-in] [--json]
dx fork <session> --worktree [--open] [--terminal <t>] [--dry-run] [-y] [--copy-in] [--json]
dx resume <session> --worktree [--copy-in]
Starts the session at the commit it was saved at, in a folder of its own under $DX_HOME/worktrees/<id8>/<repo>, on a branch dx/<name>. dx makes the worktree before the tab opens, in the foreground, from a folder on this device that holds the session's repo, and reuses it on the next run. A clone (every fork, and a session open on another device) gets a worktree of its own, on dx/<name>-<clone id8>.
--worktreeand--cwdboth choose the folder: exit 2.--dry-runmakes nothing: it prints thegit worktree addstep (and the fetch it would first need, which it doesn't do) and the tab command.resumehas no--dry-runand no--json.- A refusal keeps the contract's
errorand exit code and addsreason:
reason | Exit | Meaning |
|---|---|---|
no_repo | 3 | No folder on this device holds the session's repo (its remote, or for a session with none, its folder or name). |
commit_missing | 3 | The commit isn't in any folder here that has the session's remote, and fetching that remote in the first of them didn't bring it (rebased away, or never pushed). |
commit_ambiguous | 4 | The row kept a short hash that now matches more than one commit. |
no_commit | 1 | The session has no commit: it was saved outside git, snapped before its repository had a commit, or never snapped on the device it was open on. |
fetch_failed | 1 | The commit wasn't in any of them, and the fetch of the first one's own remote failed. |
path_taken | 1 | dx can't use the folder that is, or would be, the session's worktree: it isn't a worktree dx made, or it was made on another system that shares the DX_HOME, or it belongs to a repo without the session's remote, or its link to its repo is broken (the repo moved and git worktree repair wasn't run), or its entry in the repo (.git/worktrees/<name>) now belongs to another worktree (the repo was cloned again at its old place, or git pruned the entry while the folder was away and a newer worktree got its name). dx reuses a worktree it made for the session when the repo it is looking at lists it, or when it stands where that repo's worktree would go (another clone of the remote with the same folder name). A clone with a different folder name gets a second worktree. |
path_too_long | 1 | Windows: a file in the worktree would have a full path of 260 characters or more, or a folder of 248 or more (counted in UTF-16 units, as Windows counts), and core.longpaths is off. dx never sets it. |
branch_taken | 1 | Both dx/<name> and dx/<name>-<id8> exist already. |
add_failed | 1 | git worktree add failed. dx removes the branch it made for it. |
claude_too_old | 1 | Claude Code is older than 2.0.73, or dx can't read its version: the clone's id names the folder, so a clone in a worktree needs one that takes an id. fork: the plain fork without --worktree still works, unless --open (or --json, which opens a tab) is on. |
git_too_old | 1 | git is older than 2.17, which has no git worktree remove. |
- dx looks for the commit in each folder here that has the session's remote before it fetches. It fetches once, only the remote of the first of them, by name, and never a URL that came from a session row or another device.
- git never asks anyone anything from dx: a login, a passphrase or a host-key question fails at once (
GIT_TERMINAL_PROMPT=0, no askpass program, no ssh prompt, no credential manager window). The person's own ssh keys and agent still work. Two exceptions: an ssh older than OpenSSH 8.4 (Ubuntu 20.04, RHEL 8, macOS 11) doesn't knowSSH_ASKPASS_REQUIRE, which dx uses to stop its own question, so it can still ask on the terminal; and an askpass helper that answers by itself (a token script incore.askPass, ksshaskpass with KWallet) is not consulted, so a fetch that needed it fails with therun: git ... fetchhint. - If dx makes a worktree and can't record it, it removes it again (and its branch, while that is still at the commit dx put it on) and exits 1 with no
reason: an internal failure, not something to fix. - A question dx asks (a take-over of a copy known to be behind) and the refusal for a copy that is behind come before the worktree is made: exit 5 and
skipped: "behind"leavechangedfalse. changedis true when this run made a worktree that is still there.dx dropoffers to remove the worktree when nothing there would be lost (seedx drop).- A new worktree gets the files its main checkout's
.worktreeincludelists, only those that git ignores in the main checkout and in the worktree at its commit, never over a file that commit tracks and never through a link; a line says how many.
Claude's home
Claude Code keeps its transcripts (projects/) and its registry of running sessions (sessions/) in $CLAUDE_CONFIG_DIR, or in ~/.claude when that isn't set. dx uses the same home, read once per run: the run's home.
- Only an absolute path counts:
/…, or on Windows a drive path. A relative or empty value, or one with a control character, is ignored. dx uses~/.claude, and says so on stderr where a verb starts Claude Code or finds no transcript, never on--json's stdout. Theclaudeit starts still has the value. - Transcripts are read from the run's home only.
dx sessions --jsonstill lists a session whose only copy is in another home, withtranscript.pathnull. - What's open is read wider: the open check, the ledger and what a device tells its peers read the registries of the run's home, of
~/.claude, and of each home a session on this device was recorded in. A home dx has no record of isn't read. - Sync and connect send transcripts from the home of the run that sends them. The sync daemon and the connect node keep the home they started with until they restart.
commandcarries the home when the variable is set to an absolute path. That line is for POSIX shells; it doesn't run in PowerShell or cmd.- A tab gets the home. A path a tab can't carry sends the whole run to print, decided before anything is written:
terminalisprint,commandhas the line, and a line on stdout says why. That means",$, a backtick,;,\or a control character in dx's path or the home, for any terminal; also'and%forwt; also!or a character the locale can't print foritermandterminal.
A session stays in its home. dx records a session's home when it's snapped, when the commit hook starts it and when a fork's clone starts, in a file sync and connect don't send. When the run's home has no copy of a session recorded in another home that still exists, dx copies nothing and starts nothing:
resume,open,forkandfork --openexit 1, withskippedother_homewhere the verb reportsskipped, and themessagenames the two ways on.-ydoesn't answer it.wakeskips that session, withskippedother_homeandcommandnullin itsresults[]row, and goes on with the rest. It exits 1 when that leaves nothing opened.- This comes before a take-over is asked or a worktree is made. With
--worktreeonly the record decides, so--copy-inis needed even when a reused worktree already holds a copy. - A session with no record (it came from another device, or dx last saw it before it kept this record), one whose recorded home is gone, and one with a copy in the run's home already go on as usual.
--copy-in (resume, open, fork) lets the copy go ahead, once, and makes the run's home the session's home. wake doesn't take it: exit 2.
- The copy is the recorded home's longest, or its newest when its copies have gone separate ways, or dx's own copy when that extends it or the home has none. The old copy isn't touched.
- The
<uuid>/side folder comes from the home whichever file wins. One that can't be copied stays there, with a line on stderr, and the transcript still lands. - A copy already in the run's home is never replaced: a line says so, and the run's home becomes the session's home.
- Exit 1, with nothing copied and the record as it was: the session is open under any home dx knows, dx can't tell whether it is, dx can't read the home's
projectsfolder, a folder in it or the copy (dx's own copy isn't used in its place), there's no copy to take, or the copy can't be written.-ydoesn't stand in for any of these. - With no copy to take, dx stops before a worktree, a branch or a clone's id exists:
clone_idisnull. --dry-runcopies nothing.
A home dx can't read is one whose sessions folder dx can't open, whether by the folder's own permissions, a parent's or a Windows deny. It's never read as gone or closed, and it says nothing about any other home: a session open in a home dx can read is open.
- A session recorded in that home is unknown.
resume,openand any--copy-inexit 1, withskippedopen_unknownwhere the verb reportsskipped, and themessagenames the folder and the way on. A plainforkgoes on: a clone is a new session. wakeskips that session, withskippedopen_unknownandcommandnullin itsresults[]row, and goes on with the rest. It exits 1 when that leaves nothing opened.open.hereand what a device tells its peers have no word for unknown, so there that session reads as not open.dx dropkeeps a session's worktree while any home dx can't read might hold a Claude in it, whichever home the session was recorded in, withrunninginkept_reasons.- With no home readable,
wakereopens nothing and exits 1, and so dowake --list, since an empty list would read as nothing to reopen, andwake --scan, which leaves the ledger as it was.dx sessions --json --scanexits 0 with the last check's answers and a note on stderr. A device's peers keep what they last heard. A session with no record can't be told from a closed one, soresumeandopengo on for it.
dx send
dx send <session> [<device>] [--full] [--json]
Queues a session for your paired devices, or for the one named. Queued means handed to the transport: dx can't know when it arrives, and it never says "delivered".
results[] has one item for each device the send aimed at (the one named, else every paired device):
{device_id, device, queued: true, what, held_back}when it was queued.whatistranscript(all of it),update(what's new since the last send) ordetails(the name, color and group, without the transcript).held_backis true only when the transcript waits because that device hasn't been heard from in a day, or ever. That happens only when no device was named: a device you name is never held back.{device_id, device, queued: false, reason}when it wasn't.reasonisup_to_date(it already has the latest) orfailed, and thenerrorsays why.
device is the name as dx connect shows it. The exit is 0 when at least one device got it queued, or every device was up to date. When nothing was queued and a device failed, it's exit 1. A device that failed beside one that worked gets a warning on stderr, and the exit stays 0.
dx drop
dx drop [<session>] [-y] [--json]
Drops the session, and a tombstone tells your other devices. Claude's transcript stays. When dx made a worktree for the session on this device (see At its commit, in its own worktree), drop offers to remove it and its dx/ branch, if nothing there would be lost: it's clean (untracked files count), no Claude runs in it, it isn't locked and has no submodules, git is 2.17 or newer, and its commits are on a remote, after a fetch of each one. Its ignored files go only with a yes given now, or when each pattern that ignores them is on the disposable list. A git repository of its own inside it goes only with a yes to its own question.
- Every check and question comes before the session is dropped, so nothing changes before an exit 5. With no one to ask, under
drop-worktree ask, the worktree is kept. -yremoves a worktree that passes the checks, ignored files and all, whateverdrop-worktreesays, and saves nothing. It never removes one that holds a git repository of its own.- A drop that arrives from another device never removes a worktree.
- The exit is 0 whether a worktree was removed or kept: the session is dropped either way. A kept worktree gets a line on stderr that says why, with the command that removes it.
worktrees[] has one item for each worktree dx made for the session on this device:
| Field | Meaning |
|---|---|
path, branch | The worktree, and its branch (null when it has none). |
removed, branch_removed | Whether this drop removed the worktree, and its branch. |
ignored[] | {pattern, count}: each .gitignore pattern that ignores files there, and how many. |
deleted | Ignored files were deleted with it. |
kept_reasons[] | Why it was kept, empty when it was removed: removed is false exactly when this says why. |
command | The command that removes it, as the kept line prints it. null when it was removed, for lost and folder_missing, and for remove_failed once git has let it go. |
kept_reasons | Why |
|---|---|
dirty | Something in it isn't committed (untracked files count), git couldn't say, or a file is marked assume-unchanged or skip-worktree, so dx can't tell. |
unpushed | A commit there isn't on a remote, dx can't tell which are, or the commit it started at is only on its branch. |
running | A Claude runs in it or may be starting there, dx can't read the list of processes, or a Claude home dx can't read may hold one (see Claude's home). |
locked | git has it locked, or dx couldn't read git's record of it. |
submodules | It has submodules, which git removes only with --force. |
nested_repo | A folder in it holds a git repository of its own, and no one said yes to its question. |
fetch_failed | dx couldn't reach a remote to check that its commits are pushed. |
old_git | git is older than 2.17. |
not_disposable | Under always with no one to ask, ignored files there match a pattern that isn't on the disposable list; or ignored files appeared after dx asked; or dx couldn't read the whole list of them. |
no_person | drop-worktree is ask, and there was no one to ask. |
declined | Someone answered no. |
never | drop-worktree is never. |
lost | dx can't vouch for it: it isn't where dx makes worktrees, no repository knows it any more, or its repo's entry now belongs to another worktree. Nothing touches it. |
remove_failed | dx couldn't first remove the links in it, git's remove refused (something changed after dx checked), or the folder stayed behind (a file there is in use). |
folder_missing | Its folder is already gone. dx forgets it and keeps its branch. |
Read a word you don't know as "kept".
dx config
dx config [<setting> [<value> | --clear]] [--json]
dx config disposable [--add <pattern>… | --remove <pattern>… | --clear] [--every-repo] [--json]
Shows or changes dx's settings on this device: open-elsewhere (clone, ask or refuse; see One place at a time), drop-worktree (ask, always or never; see dx drop) and disposable: the .gitignore patterns whose files dx may delete with a worktree, kept as written, each for one repo or for every repo. --add, --remove and --clear change this repo's list, or with --every-repo every repo's. A pattern that starts with # is refused (\#build is the name #build), and so is one that holds a tab.
With no setting, --json gives settings[], each {name, value, default, choices}. With one, the result has that setting's name, value, default and choices, and changed. disposable's value is a list of {pattern, repo}, where repo is null for a pattern every repo shares, else {key, name}, and its choices is null. An unknown setting, an unknown or empty value, or two values is exit 2. Setting the value a setting already has is changed: false.
dx doctor
dx doctor [--json]
Checks dx on this device and says what to fix: the hooks of the repo it runs in, the install, Claude Code, Node.js, dx connect, auto-sync, the terminal dx wake opens tabs in, the worktrees dx made, and what dx left behind. It changes nothing except two things other verbs also keep up to date: Claude Code's version, and the newest release dx knows of. It keeps them in ~/.dx only when that folder exists, and never creates it. It takes no argument; an argument or an option it doesn't know is exit 2.
doctor exits 0 whenever it ran, whatever it found, so ok is true then too. healthy says whether anything needs fixing: true exactly when every check ran and none needs a fix. Exit 1 is only for a run that can't start at all.
findings[] has an item for each thing a check found:
| Field | Meaning |
|---|---|
check | A stable id: repo, hook_post_commit, hook_pre_push, hooks_path, dx_home, dx_exec, dx_on_path, dx_version, launcher, claude, claude_fork, claude_hook, claude_home, claude_homes, node, rsntr, connect_node, connect_transport, connect_devices, sync_target, sync_daemon, sync_watcher, wake_terminal, tmux, worktree_gone, worktree_orphan, worktree_link, worktrees_other_system, stale_locks and launcher_copies. A check can have several items (one for each worktree or lock folder), and a release can add ids. |
checked | false when the check couldn't run (git is missing, rsntr's answer couldn't be read, or dx couldn't tell whose a process is). Then needs_fix is false. |
needs_fix | Something is wrong, and a person can fix it. A thing that is only worth knowing is false: dx not enabled in this repo, connect or sync not set up, a lock folder left over, a newer release. So a fresh install is healthy when dx is on PATH and the device has git, Claude Code and Node.js. Each one missing makes it unhealthy: dx_on_path, claude or node needs a fix, and without git repo can't be checked. |
message | The sentence a person reads. |
command | The command the line ends with, else null. For a fix, it is the one that fixes it. For a note, it is a next step, such as dx enable or dx update, and nothing needs fixing. Either way it is for a person to read before running it, not for a script to run: one fix pipes curl into bash, and another adds a line to a shell startup file. |
Beside healthy and findings[], the result has an object for each part, with the facts its checks read. Like the findings, they are dx's own and may change in any release.
| Object | Fields |
|---|---|
repo | git, top, hooks_from, custom_hooks_path, linked, post_commit (new, old, legacy, other or none), pre_push, tracked |
install | home, present, script, ran_from (home, launcher or other), on_path, on_path_kind (link, copy or other), bin_dir, bin_dir_on_path, version, latest_known, latest_checked_at, launcher ({home, on_path, same}, on Windows) |
claude | found, path, version, forks_with_id, home, home_from (default, env or ignored), home_exists, home_readable, sessions_exists, sessions_readable, other_homes[] ({home, readable}) |
node | found, version |
connect | set_up, rsntr ({path, version, wanted}), node_running, node_pid, device_name, transport (relay or lan), relay, devices[] ({id, name}) |
sync | target, daemon_pid, daemon_running, watcher_pid, watcher_running, last_push, last_pull, last_error |
wake | terminal, reason, opens_tabs, tmux, dx_terminal |
worktrees | rows[] ({path, id, repo, branch, system, folder, session, link}), other_system (how many were made on another system) |
leftovers | locks[] ({path, pid, age}), launcher_copies (Windows), launcher_folder |
dx ui --no-open
dx ui --no-open [--out <path>] [--json]
Builds the session viewer page without opening a browser. --out writes it elsewhere (default: ~/.dx/data/ui.html).
Not covered
dx's verbs run through the dx command, and through a local server for dx's own pages that runs only while you keep it open: it listens on 127.0.0.1, acts only for the page dx opened for it, and runs each request as one of a few of the verbs above with --json. There is no URL scheme and no other way in. A transcript's content isn't part of this contract, and clears (--clear) are not sent to your other devices.