Compiling
The spawnfile compile command takes a Spawnfile project and produces runtime-specific output files plus a machine-readable compile report. This guide explains the pipeline, output layout, and report format.
The Compile Pipeline
Section titled “The Compile Pipeline”The reference compiler follows this pipeline:
- Parse the root
Spawnfile. - Validate local schema and file references.
- Walk the manifest graph through
members[*].refandsubagents[*].ref. - Detect cycles and incompatible duplicate references.
- Resolve effective
runtimeandexecutionfor every graph node. - Build a normalized intermediate representation (IR).
- Group resolved nodes by runtime.
- Invoke runtime adapters.
- Emit output directories and
spawnfile-report.json.
The compiler operates on resolved IR after the graph phase, not on raw YAML. Adapters receive fully resolved nodes with all inheritance applied.
Validation Phases
Section titled “Validation Phases”Validation happens in three layers:
Static Validation
Section titled “Static Validation”- YAML validity
- Required fields (
spawnfile_version,kind,name) - Path existence for docs, skills, and member/subagent refs
- Enum checks (transport, isolation, sandbox mode)
- Duplicate name/id detection
Graph Validation
Section titled “Graph Validation”- Cycle detection across teams and subagents
- Duplicate node resolution conflicts (same path, different effective config)
- Runtime resolution (every agent must have an effective runtime)
- Skill
requires.mcpresolution against visible MCP scope
Adapter Validation
Section titled “Adapter Validation”- Runtime option validation
- Runtime-native config constraints
- Capability preservation checks
You can run validation without compiling using spawnfile validate:
spawnfile validate ./my-agentThis performs static and graph validation without invoking adapters or emitting output.
Graph Resolution
Section titled “Graph Resolution”Node Identity
Section titled “Node Identity”Graph nodes are keyed by canonical manifest path. One manifest path equals one logical node. If the same path is referenced multiple times, all references must resolve to the same effective runtime and execution. Otherwise the compiler fails.
Edge Kinds
Section titled “Edge Kinds”The compiler tracks two edge kinds:
team_member— from a team to one of its memberssubagent— from a parent agent to one of its subagents
Adapters may treat these edge types very differently.
Effective Resolution
Section titled “Effective Resolution”- For agents:
runtimeis declared in the manifest. - For subagents:
runtimeis inherited from the parent. If the subagent declaresruntime, it must match the parent. - For execution: parent
executionis deep-merged with childexecution. Objects merge recursively, scalars replace, arrays replace wholesale. - For team members: each member declares its own runtime. Teams do not override member runtimes.
Adapter Contract
Section titled “Adapter Contract”Runtime adapters implement two operations:
compileAgent(required) — takes a resolved agent node, emits files and capability outcomes.compileTeam(optional) — takes a resolved team node, emits native team artifacts if the runtime supports them.
Each operation returns:
- files — emitted files relative to the node’s output directory
- capabilities — per-capability outcomes (
supported,degraded, orunsupported) - diagnostics — warnings and errors discovered by the adapter
Every agent node is always compilable independently by its runtime adapter. Team compilation is optional and adapter-dependent.
For multi-runtime teams, the compiler compiles each member agent independently and reports any loss of native team semantics.
Output Layout
Section titled “Output Layout”The default output root is ./dist. Within that root:
dist/ spawnfile-report.json runtimes/ openclaw/ agents/ analyst/ teams/ research-cell/ picoclaw/ agents/ researcher/Rules:
- One directory per runtime
- One stable directory per compiled node
- Agent and team outputs are separated
- The report file is always at the root
Use --out to change the output directory:
spawnfile compile ./my-agent --out ./buildCompile Report
Section titled “Compile Report”The compiler emits a JSON report at spawnfile-report.json in the output root.
Top-Level Shape
Section titled “Top-Level Shape”{ "spawnfile_version": "0.1", "root": "/abs/path/to/Spawnfile", "nodes": [], "diagnostics": []}Node Entry
Section titled “Node Entry”Each compiled graph node gets an entry:
{ "id": "agent:analyst", "kind": "agent", "source": "/abs/path/to/Spawnfile", "runtime": "openclaw", "output_dir": "runtimes/openclaw/agents/analyst", "capabilities": [], "diagnostics": []}Capability Outcomes
Section titled “Capability Outcomes”For every declared capability, the compiler reports one of:
| Outcome | Meaning |
|---|---|
supported | Fully preserved in the target with equivalent intent |
degraded | Partially mapped; runtime behavior may differ |
unsupported | Cannot be expressed in the target |
Example:
{ "key": "execution.model", "outcome": "supported", "message": ""}Canonical Capability Keys
Section titled “Canonical Capability Keys”The compiler reports on these keys:
docs.identity,docs.soul,docs.system,docs.memory,docs.heartbeat,docs.extras.<name>skills.<name-or-ref>mcp.<name>execution.model,execution.workspace,execution.sandboxagent.subagentsteam.members,team.structure.mode,team.structure.leader,team.structure.external,team.shared,team.nested
Adapters may add runtime-specific keys under runtime.options.* and runtime.native.*.
Policy Enforcement
Section titled “Policy Enforcement”The compile report is always emitted regardless of policy. What changes is whether degradation stops the build:
-
policy.mode: permissive— continues, records outcomes -
policy.mode: warn— continues with warnings -
policy.mode: strict— fails on any unverifiable capability -
policy.on_degrade: allow— degradations are silent -
policy.on_degrade: warn— degradations produce warnings -
policy.on_degrade: error— degradations fail the build
CLI Commands
Section titled “CLI Commands”Scaffold and Grow
Section titled “Scaffold and Grow”# Scaffold a new agent project (defaults to openclaw)spawnfile init
# Scaffold for a specific runtimespawnfile init --runtime tinyclaw
# Scaffold a new team projectspawnfile init --team
# Add a member agent to a teamspawnfile add agent writer ./my-team --runtime tinyclaw
# Add a subagent to an agentspawnfile add subagent critic ./my-agent
# Add a nested team to a teamspawnfile add team platform ./my-teamspawnfile init generates runtime-specific markdown docs (SOUL.md, IDENTITY.md, AGENTS.md) tailored to each runtime’s personality and capabilities. Each runtime adapter provides its own scaffold templates.
spawnfile add grows an existing manifest graph in place. It creates the child directory, scaffolds a Spawnfile, and appends the reference to the parent manifest. The CLI enforces parent kind rules: add agent and add team only work on team projects, and add subagent only works on agent projects.
Model Editing
Section titled “Model Editing”# Set the primary modelspawnfile model set anthropic claude-opus-4-6 --auth claude-code
# Set a model with custom endpointspawnfile model set local qwen2.5:14b --auth none \ --compat openai --base-url http://host.docker.internal:11434/v1
# Add a fallback modelspawnfile model add-fallback openai gpt-4o-mini --auth codex
# Remove all fallback modelsspawnfile model clear-fallbacks
# Update all agents in a team recursivelyspawnfile model set anthropic claude-opus-4-6 ./my-team --auth claude-code --recursivespawnfile model edits model intent in place and rewrites touched manifests to the canonical inline shape. When targeting a team project, --recursive is required and only descendant agent manifests are updated — the team manifest itself is left unchanged (teams do not declare execution).
Compile and Validate
Section titled “Compile and Validate”# Validate without compilingspawnfile validate ./fixtures/single-agent
# Compile the project in the current directoryspawnfile compile
# Compile a specific projectspawnfile compile ./fixtures/single-agent
# Compile with custom output directoryspawnfile compile ./fixtures/single-agent --out ./build