docs/subagent-authoring.md

Subagent Authoring Guide

Subagents are named roles with isolated context, narrowed tools, and explicit budgets.

File location

User-defined subagents live under:

.picasso/agents/<name>.md

The shipped roles live under apps/cli/agents/ as YAML files (<name>.yaml).

YAML definition

A subagent is a YAML document. The role instructions live in a system_prompt field rather than a markdown body.

name: security_auditor
invocation: "@security_auditor"
model: claude-opus-4-8
tools:
  - read_file
  - grep
  - glob
  - find_symbol
  - query_memory
deny:
  - create_file
  - edit_file
  - delete_file
memory: read-only
hooks:
  skip:
    - post-act
max_steps: 30
max_depth: 0
output_schema: security-audit
system_prompt: |
  You are a security auditor. Work from evidence. Return findings as structured JSON.

Required fields

Spawn policy fields (T4.7)

Role files are self-contained spawn policy. These keys map onto the spawn request's ToolRestriction (the engine's toolFilter shape):

(tools: stays the allowlist). tools: and deny: may coexist only when disjoint — declaring the same tool in both refuses the role file at load.

scalar, or an object hooks: { skip: [<hook-name>...] } listing hook names the subagent run does not fire.

request has no memory-scope field, so the spawn layer enforces it through the deny list: none refuses query_memory + write_memory, read-only refuses write_memory, and session stamps a session-scoped namespace into the spawn metadata. A memory: scope that denies a tool also in tools: is refused the same way an explicit deny: collision is.

Tool narrowing

Give each role only what it needs:

Invocation

Inside the TUI:

@security_auditor review the auth changes for token leakage

Programmatically:

spawn_subagent --role=security_auditor --prompt="review auth changes"

Isolation rules

Output schema

Return:

{
  "status": "ok",
  "findings": [
    {
      "severity": "high",
      "file": "src/auth/token.ts",
      "line": 42,
      "message": "Token is logged before redaction.",
      "recommendation": "Redact before logging."
    }
  ]
}