Repository navigation
API reference
The desktop app, the terminal UI and the CLI are all clients of one server. This page is what they send it, so you can script it or write your own client.
A Unix socket. Send one JSON object on one line and read one line back; the server then closes the connection, so open a new one for each request.
-
Find the socket:
shepherd status serverprints it (socket: ...).SHEPHERD_SOCKET_PATHoverrides it. - Send a line, then read one line back:
{"id":"1","method":"shepherd.agent.list","params":{}}- Success:
{"id":"1","result":{"type":"shepherd_agent_list","agents":[]}}-
Failure: the same
id, with anerror:
{"id":"1","error":{"code":"shepherd_error","message":"unknown shepherd operation \"nope\""}}A complete client in Python:
import socket, json
def call(sock_path, method, params=None):
s = socket.socket(socket.AF_UNIX)
s.connect(sock_path)
s.sendall((json.dumps({"id": "1", "method": method, "params": params or {}}) + "\n").encode())
reply = b""
while not reply.endswith(b"\n"):
chunk = s.recv(65536)
if not chunk:
break
reply += chunk
reply = json.loads(reply)
if "error" in reply:
raise RuntimeError(reply["error"]["message"])
return reply["result"]
print(call("/path/to/shepherd.sock", "shepherd.topic.list"))Many methods take root: the project folder (where .shepherd/ lives). Without it the server uses its own working directory.
| Group | Methods |
|---|---|
| Agents |
shepherd.agent.list, spawn, kill, clean, focus, resume, reconcile
|
| Tasks |
shepherd.task.list, task.create, task.archive
|
| Runs and gates |
shepherd.run.start, run.list, run.approve, run.reject
|
| Patterns |
shepherd.pattern.list, get, save, delete, validate
|
| Pattern runs |
shepherd.pattern.run.start, run.list, run.show, run.pause, run.resume, run.stop
|
| Event bus |
shepherd.topic.list, create, publish, tail, replay, groups
|
| Snapshots |
shepherd.snapshot.capture, list, show, diff, restore, delete, prune
|
| Git | shepherd.git.status |
| Skills | shepherd.skill.list |
The exact parameters and answers of the typed methods are in the generated schema, docs/next/api/shepherd-api.schema.json.
Everything else goes through one method, with the operation name and its arguments:
{"id":"1","method":"shepherd.call","params":{"op":"publish","args":{"topic":"notices","content":"hello","from":"me"}}}{"id":"1","result":{"type":"shepherd_call","data":{"content":"hello","from":"me","id":1,"kind":"msg","offset":0,"partition":0,"topic":"notices","ts":"2026-11-12T21:50:23Z"}}}The answer is under data. An operation the server does not know answers unknown shepherd operation "...".
| Operation | Arguments | What it does |
|---|---|---|
topic_create |
name, partitions
|
Create a topic |
publish |
topic, content, key?, partition?, from?
|
Publish a message |
topic_tail, topic_replay
|
topic, partition?, limit?, from?
|
Read messages |
bus_clean |
force? |
Delete every message. With live agents using the bus it needs force: true
|
assign_agent_task |
agentId, task (a number, or null to detach) |
Link an agent to a task |
cancel_run |
task |
Stop a task's run and close its agents |
task_update |
id, and any of title, description, spec, criteria
|
Edit a task |
task_delete |
id, confirm: true, archived?
|
Delete a task for good; refuses a task with a live agent |
import_task |
issue_ref |
Create a task from a GitHub issue (needs gh) |
publish_branch |
branch |
Approve the subtask waiting on that branch, which pushes it |
run_delete |
id, confirm
|
Delete a pattern run (stops an active one first) |
runs_clean |
Forget finished pattern runs | |
create_branch |
branch, base?
|
Create a branch |
create_worktree |
path, branch
|
Add a worktree |
remove_worktree |
path |
Remove one (refuses the main checkout, a dirty one, one with a live agent) |
skills_create |
name, description?, scope (user or repo), global?
|
Create a skill |
skills_delete |
name |
Delete a skill |
skills_global |
name, global
|
Make a skill global or not |
skills_toggle |
agent_id, skill, enable
|
Turn a skill on or off for one agent (next start) |
skills_restore |
agent_id, skill
|
Put it back to what the role gives |
Operations that delete or stop need their confirmation in the arguments (confirm: true, or force: true for the bus). Without it they do nothing and answer with an error that starts with confirmation_required: and says what would be lost, for example confirmation_required: deleting task 1 removes its folder and cannot be undone (archive keeps it).
-
Two sockets. The API socket is
shepherd.sock; the clients that draw terminals useshepherd-client.sock. This page is about the first. -
The server is the owner of the state. Tasks live in
.shepherd/tasks/, patterns in.shepherd/patterns/, the agent registry in the config directory. Clients ask; they do not edit those files. - One test keeps clients honest. A test in the repository reads every operation the app and the terminal UI send and calls each on the server, so a button cannot send something the server does not know.
See Practical examples for the same operations from the CLI.