# S031 — Command line, headless and REST > Category 07 Library and tools · Model: Sonnet · Effort: medium · Depends on: S021, S024 · Phase: build · Human: no > Files touched: crates/cli/**, crates/core/src/rest*, crates/app/src/main* ## Goal FEATURES 8.2 (API), 8.3. ## Read - crates/core command API - crates/core/src/connector - crates/app/src/instance* ## Steps - [ ] `medlar add|list|show|pause|resume|remove|limit|mode|queue|continue|export|quit`, with `--json`, exit codes and quiet mode - [ ] Talks to a running instance by its socket, or starts headless; clear message otherwise - [ ] `--headless` without a display, systemd user unit file - [ ] REST plus event stream with the same commands, token per client, scopes (read, control), off by default, loopback unless remote control is on - [ ] Shell completions (bash, zsh, fish) and man page generated - [ ] Terminal progress with parts, plain when not a terminal - [ ] Test file `docs/tests/S031-cli-rest.md`, with the checks below - [ ] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S031: …`, push ## End criteria `nice cargo check -q -j 2 -p medlar` clean ## Checks for the test file (do not run now) - automatic tests in medlar-cli green - scripted end-to-end run against the test server without a display ## Pitfalls The socket lives in XDG_RUNTIME_DIR with mode 600. Tokens hashed at rest. ## Handoff (→ PROGRESS.md) REST description for S032.