SHEPHERDdocs Search the docs/ v0.5.3-beta
On this pageAgent lifecycleRolesWhat you do with a roleVendorsMCP tools an agent sees

Agents and roles

The agent lifecycle, roles, vendors and the tools an agent sees.

Works inDesktop appTerminal UICLI

Agent lifecycle

shepherd spawn <role> <task> (or s in the Agents view, or a pattern run) does this:

  1. Resolves the role into a vendor, a model and a fallback, using the configuration.
  2. Checks the limits (max_concurrent, max_depth).
  3. If the role has worktree: true, creates a git worktree and a branch shep/<n>-<task> under ~/.shepherd/worktrees/<repo>/.
  4. Installs the role's skills and starts the vendor in a terminal pane, with Shepherd's MCP server injected and a token of its own.
  5. Sends the first prompt: the task, or the persona defined in a pattern.

States: starting, then working and idle alternating. blocked means a person is needed (a trust dialog, a login, a question). done means it delivered a result. killed and exited are final.

$ shepherd agents
ID            STATE     ROLE        VENDOR  MODEL  TASK
specialist-1  starting  specialist  codex   -      Task-1-demo
  • Open its terminal: shepherd attach <agent> (or Enter in the Agents view). That is where you answer permission prompts and questions.
  • Clean up: a finished agent is removed with x in the Agents view. Its snapshots are kept according to max_per_agent.
  • Agents without MCP: bus messages are typed into their terminal as [shep] from <role>#<n>: ... when the pane is idle.
  • Inherited configuration: agents inherit your global vendor configuration (for example ~/.claude/CLAUDE.md). If it demands plan approval before editing, the agent will wait. Include the approval in the task.

shepherd spawn accepts --vendor and --model to override a role for one agent, and --task-id to link the agent to a task. To link or detach an agent later, use shepherd assign <agent> <task-id|none> (or l in the terminal Agents view). After a server restart, shepherd resume (u in the terminal Agents view) marks the agents it left behind and shepherd reconcile checks them against their terminals; neither starts anything.

Roles

A role is a named job description. It is not a vendor: it says which vendor and model are the default for that job, plus permissions and skills.

RoleDefault vendorPurposeOwn worktreeMay start agents
brainclaude / opusPlan, split work, aggregate resultsnoyes
codercodex (fallback gemini, claude)Implementyesno
reviewergemini (must differ from the coder's vendor)Review code and securitynono
docsgeminiDocumentation and docs questionsnono
testerclaude / sonnetTests and debuggingnono

See what your configuration resolves to:

$ shepherd roles list
brain      claude/opus
coder      codex/default
docs       gemini/default
reviewer   gemini/default
tester     claude/sonnet

Changing a role or adding one

Roles live in config.yaml, globally (~/.config/shepherd/config.yaml) or per project (<repo>/.shepherd/config.yaml). Write only what changes; everything else comes from the defaults, and maps merge deeply (a null value resets a key).

roles:
  coder:
    vendor: claude          # instead of codex
    model: sonnet
    worktree: true
  specialist:               # a new role with any name
    vendor: codex
    worktree: false
    prompt: You focus on database migrations.
    skills: [lang-go, debug]
FieldMeaning
vendorWhich vendor runs the role
modelModel; empty means the vendor's default
fallbackAlternative vendors if the main one is not available
must_differ_fromThe vendor must differ from another role's (cross-review)
worktreeThe agent works in its own worktree and branch
can_spawnThe agent may start sub-agents (the spawn_agent tool)
skillsSkills specific to this role
promptYour own instructions for the role

Check the result with shepherd config validate. Common problems it reports: a role pointing at an unknown vendor or fallback, a must_differ_from that names an unknown role, or limits below 1.

In the native app, the Models view lists the agents and models installed on your machine, grouped by vendor, and lets you pick them for each role without editing YAML.

What you do with a role

  • Use one as it is. The five built-in roles are enough to start: brain plans, coder implements, reviewer reviews, docs writes documentation, tester writes and runs tests. shepherd spawn coder "..." or a pattern that names role: coder uses it.
  • Change one. Write only what changes in config.yaml, for example roles: {coder: {vendor: claude, model: sonnet}}. Everything else keeps its default.
  • Add your own. Add a new name under roles: when a job needs its own vendor, model, skills or prompt: a gopher, a migrator, a security-auditor. Patterns can use it right away.
  • Check it. shepherd config validate finds a role that points at an unknown vendor, a must_differ_from that names an unknown role, and skills that do not exist. shepherd roles list shows what each role resolves to.

Vendors

Shepherd drives agent CLIs. Three are built in:

VendorCommand
claudeclaude
codexcodex
geminiagy
$ shepherd vendors list
claude   claude   available
codex    codex    available
gemini   agy      available

A vendor entry in config.yaml describes how to start it and how to reach it:

FieldMeaning
command, argsExecutable and startup arguments
models, default_model, model_flagAvailable models, the default, and the flag that selects one
print_argsArguments of the non-interactive mode
mcp.supported, mcp.styleWhether MCP is supported and how it is injected
skills.mode, skills.style, skills.fileHow skills are delivered (native, instructions, prompt)
shepherd_agentThe name the agent detector knows it by
disabledExcludes the vendor; roles fall back to their fallback

To switch a vendor off: vendors: { gemini: { disabled: true } }.

MCP tools an agent sees

Agents with MCP support see these as tools of the shepherd server (a local HTTP server, with one token per agent).

ToolWhat it does
spawn_agentStart a sub-agent (only roles with can_spawn: true)
send_message, read_messagesDirect message to another agent by id or role; read and drain pending ones
wait_forWait for given agents to deliver a result or exit
submit_result, get_resultDeliver the final result; read another agent's without blocking
list_agentsAgents in the session with role, vendor, state and worktree
get_diffFull diff of a coder's worktree against the base branch
run_checksRuns the project's checks (workflow.checks, or cargo test, pytest, npm test, go test ./... when it has none) in an agent's worktree, yours by default, and returns PASSED or FAILED with each command's exit code and the end of its real output. Pass or fail is the exit code, not an agent's reading. Each command has a time limit (timeout_secs, default 600, at most 3600) and is killed with everything it started when it runs out
read_outputLast N lines of an agent's pane
ask_docsAsk the docs agent (started if needed) and wait
get_task_context, update_task_contextRead the task (issue, spec, criteria, plan) or, for brain and docs only, update it. In pattern runs it returns the objective and the topology
get_workspace_instructionsRepository instructions, effective skills, detected checks
publish, subscribe, poll, ack, replay, list_topicsThe event bus, see Topics and events

Limits protect you from runaway trees: max_depth bounds how deep agents may start agents, and max_concurrent bounds how many work at once.

Was this page useful?Suggest an edit on GitHub