Tutorial· About 15 minutes
Automate Edith from shell scripts
When you finish, you will have a shell script that reads Edith's data with ed, reacts to every exit code correctly, and runs on a schedule inside Edith. Everything you do here by script, you can also do by hand in the Edith window; this tutorial is for the jobs you want to run unattended. You need Edith installed with ed on your PATH (see Set up a new Mac) and jq for reading JSON. The script in this tutorial uses the Usage extension, but the rules apply to every command.
Find the command you need
Most things you can click in Edith also have an ed command. Find it by describing the task:
ed docs ask "keep the mac awake with the lid closed"ed help configed config --helpThe Docs extension does the same inside the app: describe a task, or browse every command with its arguments and options.

For a script or an agent, ed guide --json prints every command, alias, flag, default and help text as one JSON catalog.
Ask for JSON
Add --json to a command and it prints exactly one JSON document on stdout:
ed version --json{ "appRunning": true, "version": "1.0.0"}The shape is the same on every run:
- Object keys are sorted.
- A missing value is
null, never a dropped key. - Dates are ISO 8601, such as
2026-08-06T22:57:22Z. - Lists are top-level arrays.
ed usage limits,ed clipboard ls,ed machines lsanded extensions lsall print an array.
So you can pipe straight into jq:
ed extensions ls --json | jq '.[] | select(.enabled) | .id'Keep stdout and stderr apart
stdout carries the answer and nothing else. Errors, hints, progress and notes go to stderr. A failure prints an error: line and often a hint: line with the next step:
ed clipboard get 9999error: there is no clipboard entry 9999hint: the history holds 1217 entries, numbered from 1On a non-zero exit, stdout is empty. A command never leaves half a document behind, so ed usage summary --json > usage.json writes a whole document or nothing. Progress spinners turn off with --json, and when stderr is not a terminal, so logs stay clean.
Read the exit code
Every command exits with one of five codes:
| Code | Meaning | Example |
|---|---|---|
| 0 | Success, including a preview that changed nothing | ed cleaner clean without --yes |
| 1 | Understood, but refused or failed | A setting value outside its allowed list |
| 2 | The command line was wrong | An unknown flag |
| 3 | The thing you named does not exist or is ambiguous | An unknown machine or setting key |
| 4 | It exists but is unavailable right now | An extension is off, a machine is down, a store is empty |
Code 4 also means an empty store: no clipboard history yet, or no limit readings yet. Treat it as "nothing to act on", not as a crash. When ed cannot reach Edith at all, it also exits 4.
Extension marketplace commands and ed invoke, which talk to the running app, use their own table, listed in the command line guide. ed machines exec and the ed <machine> ... shorthand pass the remote program's own exit code through instead. For a machine named devbox:
ed devbox sh -c 'exit 42'echo $?42Preview before you change anything
Commands that remove or restart something preview by default and act only with --yes. A missing --yes is not an error: the command reports what it would do and exits 0. Run the preview in your terminal first, then put the --yes form in the script:
ed cleaner clean --category npm --jsoned cleaner clean --category npm --yesWrite the script
This script stops a long job from starting when the Claude 5-hour window is nearly used up. Save it as ~/bin/claude-gate.sh:
#!/bin/shthreshold=80limits=$(ed usage limits --json)status=$?case $status in 0) ;; 4) echo "no limit history yet, skipping the check" >&2; exit 0 ;; *) exit "$status" ;;esacpercent=$(printf '%s\n' "$limits" | jq -r '.[] | select(.provider == "claude") | .session.percent')percent=${percent%.*}percent=${percent:-0}if [ "$percent" -ge "$threshold" ]; then echo "Claude 5-hour window at ${percent}%, holding off" >&2 exit 1fiecho "Claude 5-hour window at ${percent}%, go ahead"What it relies on:
ed usage limits --jsonreads the last saved reading, so it answers fast and does not poll your provider.- Exit 4 means Edith has not saved a reading yet, so the script lets the job run.
- Any other failure keeps its own exit code, so a caller can tell a wrong command line (2) from a real failure (1).
.sessionis the 5-hour window.jqprintsnullwhen the window is missing, which the script turns into 0.
Make it executable and put it in front of a job:
chmod +x ~/bin/claude-gate.sh~/bin/claude-gate.sh && make buildLet ed start Edith for you
You do not need to open Edith first. When a command needs the app and it is not running, ed opens it in the background, without a window, and waits up to about 20 seconds. If Edith still cannot be reached, the command exits 4. A few commands, such as ed version, ed status and ed guide, never need the app.
To check whether Edith is running without starting it:
ed version --json | jq -e '.appRunning'jq -e exits non-zero when the value is false, so this works in an if. What needs Edith running has the full list.
Run it on a schedule
ed agent schedule runs a command inside Edith on an interval or a cron rule, with no terminal open. Schedules survive restarts and reboots:
ed agent schedule add claude-gate --every 15m -- /bin/sh /Users/you/bin/claude-gate.shed agent schedule lsed agent schedule run claude-gatePut -- before an absolute path to the program. Each run is a task, so read its output with ed agent tasks ls and ed agent tasks inspect <id>. In the app, Settings > About lists background jobs and tasks; see Background jobs.
Next steps
- The
edcommand line for completion and the machine shorthand. - Conventions: the full
--jsonand exit code contract. - Background jobs for tasks, schedules and
ed run. - Connect Claude Code over MCP: the same commands as tools for an agent.
