SHEPHERDdocs Search the docs/ v0.5.3-beta
On this pageTransportTyped methodsThe generic call: `shepherd.call`Good to know

JSON API

The local socket, the typed methods and the generic call.

Works inCLI

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.

Transport

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 server prints it (socket: ...). SHEPHERD_SOCKET_PATH overrides 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 an error:
{"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.

Typed methods

GroupMethods
Agentsshepherd.agent.list, spawn, kill, clean, focus, resume, reconcile
Tasksshepherd.task.list, task.create, task.archive
Runs and gatesshepherd.run.start, run.list, run.approve, run.reject
Patternsshepherd.pattern.list, get, save, delete, validate
Pattern runsshepherd.pattern.run.start, run.list, run.show, run.pause, run.resume, run.stop
Event busshepherd.topic.list, create, publish, tail, replay, groups
Snapshotsshepherd.snapshot.capture, list, show, diff, restore, delete, prune
Gitshepherd.git.status
Skillsshepherd.skill.list

The exact parameters and answers of the typed methods are in the generated schema, docs/next/api/shepherd-api.schema.json.

The generic call: shepherd.call

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 "...".

OperationArgumentsWhat it does
topic_createname, partitionsCreate a topic
publishtopic, content, key?, partition?, from?Publish a message
topic_tail, topic_replaytopic, partition?, limit?, from?Read messages
bus_cleanforce?Delete every message. With live agents using the bus it needs force: true
assign_agent_taskagentId, task (a number, or null to detach)Link an agent to a task
cancel_runtaskStop a task's run and close its agents
task_updateid, and any of title, description, spec, criteriaEdit a task
task_deleteid, confirm: true, archived?Delete a task for good; refuses a task with a live agent
import_taskissue_refCreate a task from a GitHub issue (needs gh)
publish_branchbranchApprove the subtask waiting on that branch, which pushes it
run_deleteid, confirmDelete a pattern run (stops an active one first)
runs_cleanForget finished pattern runs
create_branchbranch, base?Create a branch
create_worktreepath, branchAdd a worktree
remove_worktreepathRemove one (refuses the main checkout, a dirty one, one with a live agent)
skills_createname, description?, scope (user or repo), global?Create a skill
skills_deletenameDelete a skill
skills_globalname, globalMake a skill global or not
skills_toggleagent_id, skill, enableTurn a skill on or off for one agent (next start)
skills_restoreagent_id, skillPut 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).

Good to know

  • Two sockets. The API socket is shepherd.sock; the clients that draw terminals use shepherd-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.

Was this page useful?Suggest an edit on GitHub