Use the weft command
The weft binary serves Studio and talks to it from a terminal. weft studio serves the UI, OTLP ingest and the playground over one database; weft runs, weft open, weft export and weft doctor each call one route of that Studio’s JSON API, so a script or CI job reads the same runs the UI shows. The clients find the running Studio and its token through the discovery file it writes, so in the directory you ran it in they need no flags.
go install github.com/weftgo/weft/cmd/weft@latestweft studioweft runsweft: Studio http://127.0.0.1:7331 (discovery file ~/xdg/weft/studio.json)ID AGENT STATUS STARTED STEPS DUR COST PROMPT STOPPED BY ERRORotel-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7 support succeeded 2026-10-01 12:00:00 +0200 2 3.2s $0.0029 - - -weft: weft open <id> shows one in Studio; weft export <id> --format jsonl writes it outThat run is a stock OpenTelemetry agent’s, posted from Inspect agents written in other languages, so it records no prompt and no stop. A Go app run from the same directory joins this Studio through the same file: its otel.Install() logs INFO weft/otel: joined the running Studio url=http://127.0.0.1:7331 …. In the outputs below, ~/work and ~/xdg stand for the scratch directories the commands ran in.
What each command does
Section titled “What each command does”Every subcommand is a convenience over something an app or a script can do itself: weft studio is studio.New with setup B’s options, and the clients are thin wrappers of documented routes. A team that skips the CLI loses nothing.
| Command | What it does |
|---|---|
weft studio | Setup B: the UI, OTLP ingest, the playground and a dev token stable per database, on 127.0.0.1:7331, else the next free port in 7331–7340. One Studio per SQLite file: a second start on a file another Studio serves is refused |
weft dev | weft studio in-process plus your app, restarted on a .go save; it reuses a Studio already serving the same database. One line per start: studio http://127.0.0.1:7331/ · app pid … · runtime rt_… registered |
weft runs | One row per top-level run, newest first, from GET /api/runs. --limit defaults to 50 and says so on stderr when it hid runs; --json for scripts |
weft open [id] | Prints the page of a run, public id, session or trace, bare; with no id the Studio root. --with-token adds the #token= fragment, --open hands the browser the link |
weft export <run id> | GET /api/runs/{id}/export to stdout (--format json, jsonl or otlp), or with --wefttest <dir> the run’s replay test written into a package directory |
weft doctor | One line per check of a running Studio, each read from GET /api/meta |
weft mcp | A read-only MCP server over stdio, so a coding agent reads runs while you debug |
weft vacuum | One retention sweep, then VACUUM (SQLite) or OPTIMIZE TABLE … FINAL (ClickHouse) |
weft version | The weft version the binary was built from |
Every connection flag mirrors an environment variable, and the flag wins: --addr is WEFT_STUDIO_ADDR, --db WEFT_DB (a bare SQLite path, where --db takes a sqlite:// or clickhouse:// URL), --token WEFT_STUDIO_TOKEN, --manifest WEFT_MANIFEST, --url WEFT_STUDIO_URL, --retain WEFT_RETAIN, --pricing WEFT_PRICING, --log-level WEFT_LOG_LEVEL and --log-format WEFT_LOG_FORMAT (Common flags). weft dev’s --watch and --no-watch, --open, --no-playground and the action --rotate-token have no mirror. -h spells every flag with two dashes. The exit codes are 0 on success, 1 on a failure (one weft: … line on stderr) and 2 on a usage error, which names its arguments in words (weft: export needs exactly one run id (got none)). weft CLI reference lists every flag.
Run Studio
Section titled “Run Studio”weft studio with no flags serves $WEFT_DB, else ./.weft/weft.db (the file an app’s otel.Install writes by default), and prints where everything is:
weft studio --db sqlite://other.db --open=falsestudio: http://127.0.0.1:7331/studio: token created in ~/work/other.db.token (stable for this database; --rotate-token renews it)studio: db other.dbstudio: no weft.json from ~/work upward; no manifest (--manifest names one)studio: apps find this Studio through ~/xdg/weft/studio.json (WEFT_STUDIO_URL overrides it, WEFT_DISCOVERY=off ignores it)studio: sign in with `weft open --with-token` (prints this Studio's link, the token in its fragment)The flags you reach for, with Run Studio covering the rest:
--db sqlite://pathserves another file;--db clickhouse://user:pass@host:9000/dbserves the hosted backend.--addrpins the listen address. Without it, anything else on 7331 moves Studio to the next free port in 7331–7340 (the port policy).--manifest weft.json(orWEFT_MANIFEST) serves yourweft.json; without it Studio looks for the nearest one upward, and one line says which file it loaded, by its absolute path:studio: manifest /home/you/support/weft.json (found upward), or(--manifest)/(WEFT_MANIFEST). A file that does not parse stops the start:weft: manifest <path>: does not parse: …, exit 1.--openopens the browser with the token in the URL fragment. It is on when stdout is a terminal;--open=falseturns it off, and the banner’s last line then says how to sign in. On a box with no browser opener the start goes on with one line,weft: could not open a browser (…); open the link yourself.--no-playgroundturns the playground off.
One Studio per database. weft studio takes a lock on <db>.lock beside a SQLite file while it serves, released when the process ends, a crash included. The file itself stays on disk after exit; leave it. A symlink, a directory or another non-regular file at that path, or on unix a hard link, is refused at start with dblock: the lock file is not a regular file (One Studio per database). A second weft studio on the same file, from any directory and on any port, is refused with exit 1:
weft: studio already running at http://127.0.0.1:7331 (pid 1683241) on ~/work/other.db: one Studio per database file — sign in to it with `weft open --with-token`, or stop it firstweft dev reuses that Studio instead. Before 0.20.0 a second weft studio said …, reusing and exited 0. ClickHouse takes no lock.
When the discovery file cannot be written, the banner says studio: no discovery file (<error>); apps need WEFT_STUDIO_URL=http://127.0.0.1:7331 and Studio serves anyway.
The token. The first start on a SQLite file writes a dev token beside it, <db>.token (mode 0600), and every later start serves the same one, so a restart keeps the browser tab and the app’s WEFT_STUDIO_TOKEN valid. It is never printed; the banner names the file. --rotate-token writes a new one, and panel tokens signed with the old one stop verifying. --token or WEFT_STUDIO_TOKEN fixes the token instead and leaves the file alone. Only a database with no file (sqlite://:memory:, ClickHouse) gets a token printed at start. The dev token has the details.
The API over a terminal
Section titled “The API over a terminal”The clients are a terminal over Studio’s JSON API, one route each: weft runs reads GET /api/runs, weft open checks the id it is given, weft export reads GET /api/runs/{id}/export, and weft doctor reads GET /api/meta. They compute nothing Studio does not serve.
All five clients, weft mcp included, find Studio the same way: --url, else WEFT_STUDIO_URL, else the discovery file a running weft studio or weft dev wrote (the trust rules otel.Install uses; WEFT_DISCOVERY=off skips it), else http://127.0.0.1:7331. The token is --token, else WEFT_STUDIO_TOKEN, else the discovery file’s when that file names the resolved Studio. When you named no Studio, the first stderr line says which was taken and why: weft: Studio http://127.0.0.1:7331 (discovery file …). Without a token, a Studio on a file answers 401:
WEFT_DISCOVERY=off weft runsweft: Studio http://127.0.0.1:7331 (the default address; WEFT_DISCOVERY=off)weft: GET /api/runs: 401 the API requires a token: Authorization: Bearer <token> (--token or WEFT_STUDIO_TOKEN)A Studio that does not answer reads studio not reachable at <url>: … with the fix. A redirect is an error, never followed: point --url at the Studio itself. Each request has a two-minute timeout.
List and open runs
Section titled “List and open runs”weft runs prints the newest top-level runs, 50 by default. Filters go to the server: --agent, --failed, and --status with one of running, succeeded, failed, interrupted, parked or cancelled. --since takes a duration back from now or an RFC 3339 time. The columns are the run’s id, agent, status, start (local time with its zone), steps, duration, cost (own plus delegated), its public id when a row has one, the prompt’s first line, what stopped it and, for a failed run, its error kind and why, cut to 60 characters. After the table, a line on stderr names the next step.
weft runs --status bogusweft: --status: status must be running, succeeded, failed, interrupted, parked or cancelled ("bogus" given)That is exit 2. --limit 0 lists every match; a limit that hid runs says so on stderr, which keeps stdout clean for a pipe:
weft runs --limit 1weft: showing the newest 1; --limit 0 lists all--json prints the rows as Studio serves them, a JSON array with every field of the runs list (status, err, stopped_by, usage, cost_usd, prompt_preview and the rest); its shape did not change when the table’s columns did in 0.20.0. PROMPT reads - for a run with no prompt preview, and every cell prints control characters as spaces, since prompts and agent names are untrusted text.
weft open takes a run id, a public id, a session id or a trace id, tried in that order, and prints its page. With no id it prints the Studio root:
weft open otel-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7http://127.0.0.1:7331/runs/otel-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7The link is bare: the token may be the panel tokens’ signing key, so it stays out of logs. --with-token prints #token=<token> after it, the resolved token; weft open --with-token with no id is how a terminal signs a browser in. --open hands the browser the link with the token in the fragment, which never reaches a server.
Export a run
Section titled “Export a run”weft export writes the run’s export to stdout, json by default, or jsonl and otlp with --format. From a 0.18.3 run, cut to 80 characters:
weft export c343127c37a733a7d1d88d897b7817dc --format jsonl | cut -c1-80{"record":"run","format":"weft.run.export/1","run":{"id":"c343127c37a733a7d1d88d{"record":"event","pos":0,"time":"2026-10-18T10:42:16.532125457Z","event":{"type{"record":"event","pos":1,"time":"2026-10-18T10:42:16.532154322Z","event":{"type{"record":"event","pos":2,"time":"2026-10-18T10:42:16.532201922Z","event":{"type{"record":"event","pos":3,"time":"2026-10-18T10:42:16.532220517Z","event":{"type{"record":"event","pos":4,"time":"2026-10-18T10:42:16.532238692Z","event":{"type{"record":"messages","index":0,"step":0,"input":true,"messages":[{"role":"user",{"record":"messages","index":1,"step":0,"input":false,"messages":[{"role":"assis{"record":"messages","index":2,"step":0,"input":false,"messages":[{"role":"tool"{"record":"request","index":0,"step":0,"attempt":1,"time":"2026-10-18T10:42:16.5{"record":"tools","hash":"d90d08d79c38775c5a61ba7037f26bb5e9f84ef466c82dae2a056c{"record":"span","trace_id":"0793339c79b2442e7f091bcc3304c2be","span_id":"85cac7{"record":"span","trace_id":"0793339c79b2442e7f091bcc3304c2be","span_id":"1cb8b9{"record":"span","trace_id":"0793339c79b2442e7f091bcc3304c2be","span_id":"ab5844Export a run describes each format. With --wefttest <dir> it writes Studio’s save-as-test tree into the package directory <dir>: a replay test and its testdata/ that pass under go test there. --fixtures-only writes the fixtures alone under <dir>/<test>, for a test of your own. --test <name> names that test and so its directory (the run id by default); it goes only with --fixtures-only. A second export into the same place is refused, exit 1, until you pass --force. --format wefttest is exit 2 (--format wefttest is a zip of fixtures: use --wefttest <dir>). Turn a Studio run into a test has both forms.
Check a Studio
Section titled “Check a Studio”weft doctor reads GET /api/meta within 5 s and prints one line per check:
weft doctorok studio reachable at http://127.0.0.1:7331 (weft v0.20.2, studio v0.20.2)ok token acceptedok discovery ~/xdg/weft/studio.json -> http://127.0.0.1:7331 (this Studio)ok db sqlite ~/work/other.db (643.8 KiB)warn content studio stores content as received; latest run otel-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7: unmarked — the latest run carries no content mark: no events stored, a weft older than the mark, or a non-weft exporterok data newest run 629h45m0s ago (service py-support) carries no weft version: a non-weft exporterok otlp open: OTLP at http://127.0.0.1:7331/v1/traces and /v1/logs takes a loopback app's spans with no ingest tokenok ingest 1 OTLP batches accepted, 0 refused; no app reported lost records (weft.records.dropped on its heartbeats and run brackets)warn runtimes none connected - WEFT_ENV is unset in this shell: the app opens the runtime link only with WEFT_ENV=dev (or runtime.Enabled(true)) - WEFT_STUDIO_URL is unset in this shell: the app dials the Studio a running `weft studio` names in its discovery file, else its otel Studio destination; set WEFT_STUDIO_URL=http://127.0.0.1:7331 to pin this one (or runtime.Studio(url, token))ok panel /panel.js matches studio v0.20.2ok manifest none: no weft.json configured (studio.Manifest, or --manifest / WEFT_MANIFEST) and no runtime registered one, nothing to compareThat is weft v0.20.2 against the stock-span run above. It checks that Studio is reachable and takes your token, and which discovery file this shell reads and whether it names this Studio. It reports the database’s path and size, the content the latest run stored, and the newest run’s age, weft version and service. It says whether OTLP ingest is open, walled or off, and counts the batches accepted and refused. It lists the connected runtimes and the panel bundle’s version, and checks whether the manifest matches the latest runs. The manifest line names its source first: weft.json, or the runtimes’ registrations when none is configured; before 0.20.0 it was labelled weft.json. A 401 names --token "$(cat <db>.token)" and weft open --with-token, and a capability that is off names its cause (--no-playground: “drop the flag”). A failed check exits 1, and an unreachable Studio is the first of them: one line and a hint, and no other check runs.
The reference lists which field each line reads and when it warns or fails.
Read runs from a coding agent
Section titled “Read runs from a coding agent”weft mcp serves Studio’s read routes as 22 MCP tools over stdio, so Claude Code or Cursor answers “why did run X fail” from your Studio. Let Claude Code or Cursor read your runs sets it up.
Best practices & gotchas
Section titled “Best practices & gotchas”- Run the clients where Studio runs, or name it. With no
--urlthey read the discovery file; a Studio elsewhere, or a shell withWEFT_DISCOVERY=off, needs--urland--token. (Source:cmd/weft/resolve.go) - Pass a database URL as
--db, never asWEFT_DB.WEFT_DBis a SQLite file path:WEFT_DB='clickhouse://u:p@host:9000/db' weft studiostarts with no error and serves a new, empty SQLite file under a directory named after the URL, password included, which the banner’s token line prints. (Source:cmd/weft/main.go(the WEFT_DB fallback); observed with the v0.20.2 binary) - Stop the running Studio before you start another on its file. A second
weft studioon one SQLite file is refused; useweft dev, which reuses it, or sign in to it withweft open --with-token. (Source: CHANGELOG.md:83) - Keep
--with-tokenoutput out of logs. The dev token is the panel tokens’ signing key; the bare link is enough when the browser already holds the token. (Source:weft open -h;cmd/weft/token.go) - Read the limit note on stderr.
weft runscaps at 50 rows unless you pass--limit 0, and only stderr says it cut. (Source:cmd/weft/api.go) - Script against
--json, not the table. The table’s columns changed in 0.20.0; the JSON did not. (Source: CHANGELOG.md:84)
See also
Section titled “See also”Symbols used: studio.New · wefttest.Replay