Skip to content

Latest commit

 

History

History
561 lines (455 loc) · 25.8 KB

workflow-syntax.md

File metadata and controls

561 lines (455 loc) · 25.8 KB

Workflow Syntax Reference

Markdown workflows have two parts: YAML frontmatter that declares the DAG, and Markdown sections that provide the prompts for non-input nodes.

Use this page for the exact authoring contract. For the mental model, start with Workflow Authoring.

Contents

Need Start here
Smallest valid Markdown workflow Minimum Valid Workflow
Provider fanout with findings Multi-Provider Review Workflow
Exact node fields Nodes
Execution patterns Node Modes
Template syntax Templates

Use the map above for common authoring tasks; the contents list is the complete field index.

Minimum Valid Workflow

---
schema_version: "1.0"
name: "Example"
description: "Optional description"
nodes:
  - id: inspect
    mode: parallel
    providers: ["claude"]
---

## inspect
Inspect the project.

Multi-Provider Review Workflow

---
schema_version: "1.0"
name: "Review"
nodes:
  - id: review.project
    mode: parallel
    providers: ["claude", "codex"]
    findings: true
---

## review.project
Review the project and report correctness, security, and regression risks.

Frontmatter Fields

Field Description
schema_version Workflow schema version. Must match SCHEMA_VERSION.
name Workflow name.
description Optional workflow description.
repeat_force_run_count Optional whole number above zero. Runs the whole workflow this many times, starting from the beginning each time.
inputs Mapping of declared workflow input names to local input node IDs.
imports Markdown workflow imports.
worktrees Logical workspace declarations.
nodes Workflow node list.

Repeat a workflow

Add repeat_force_run_count to the workflow you run, either in Markdown frontmatter or in a YAML workflow file. For example, repeat_force_run_count: 3 runs the whole workflow three times in one command. Each run starts from the beginning. Set it to 1 to run once from the beginning; leave it out to keep the usual behavior of skipping or resuming work when possible.

Use a whole number above zero, without quotes. null, true, "3", 1.5, 0, and negative numbers are invalid. Only the workflow you run controls the count. If an imported workflow also sets a count, its value must be valid, but it does not add runs.

When you set a count, including 1, set settings.workspace.enabled: false and remove all worktrees declarations from the workflow and its imports, even if they are unused. This rule still applies during later runs if the workflow removes the count. See run a workflow more than once for what happens between runs and when a run fails.

Imports

Field Description
path Markdown workflow path.
as Import alias namespace. Must match [a-z0-9._-]+.
with String parameter bindings for {{param:key}}.
inputs Bind child workflow input names to local node IDs.
needs Optional list of caller-scoped node IDs that gate every provider entry in the import.

Import paths resolve relative to the workflow file that declares them. Imports are Markdown-only, alias-namespaced, cycle-checked, and bounded to the project root. Duplicate aliases fail. Unused with parameters fail so misspelled parameter names do not silently disappear. inputs keys and bound node IDs must be non-empty strings after trimming.

Import prerequisites

imports[].needs adds ordering to an imported workflow without changing its source. Omission and [] add no ordering. The value must be a list of strings; surrounding whitespace is trimmed, and each ID must be non-empty and match [a-z0-9._-]+. null, scalars, mappings, non-string elements, template expressions, and parameter substitution are not supported.

IDs resolve in the workflow declaring the import, using the same rules as node dependencies. They can name parent-local nodes or concrete nodes in sibling imports, including imports declared later. An alias alone does not mean “wait for the entire workflow”; name the required nodes explicitly. In nested imports, IDs acquire the caller's namespace. To refer to a caller input boundary, use its local node ID, not its public input name; a bound input ID resolves to its replacement node.

After nested imports and input bindings are composed, a provider entry is any non-input node with no dependency on another non-input node in that imported subtree. Every such entry receives the prerequisites, even if it already depends on a caller node or an unbound file input. Existing dependencies come first, followed by the import prerequisites. Exact duplicates are removed in first-seen order; transitive edges remain. Internal provider dependencies are preserved. Input nodes remain dependency-free. Nonempty needs fails if the composed child has no provider entries, including input-only imports and imports whose nodes were all pruned.

inputs and needs can coexist: bindings replace input consumers' dependencies, while prerequisites gate all provider entry branches. Prerequisites add no prompt text or artifact references and do not select review material. Add explicit prompt references or input bindings when a provider needs upstream content.

These are ordinary node dependencies after composition. Unknown targets (including pruned inputs), self-dependencies, and cycles fail validation before execution. Prerequisites must succeed under their normal execution policies; failed prerequisites block dependent branches. The edges also participate in workflow signatures, duplicate detection, and dependency-closed resume.

Import prerequisites have the same workspace effects as node needs: they can order writers on one logical worktree, but direct dependencies across different mutable worktrees remain invalid and no implicit merge occurs. See Workspace Isolation.

Ordering does not defer file-input resolution. Unbound file inputs retain their preflight or project-initial source semantics and may materialize before the prerequisite providers finish. A file that an upstream provider will create is not a deferred input; a missing fallback file still fails preflight.

Worktrees

Workflow-level worktrees are valid only when settings.workspace.enabled: true. They declare workflow-local logical source lines and disposable workspaces; project config does not define default worktree selectors.

Field Description
kind worktree or snapshot.
setup_profile Optional setup profile name. Only valid for worktree.
create_branch Optional branch export for worktree. Defaults to false.
branch_name Optional branch name. Requires create_branch: true.

Worktree names must match [a-z0-9._-]+; none is reserved.

Kinds:

  • worktree: mutable Git-backed source line that can emit workspace-state*.json, workspace-bundles/*.bundle, and optional local branch export.
  • snapshot: writable disposable scratch space. It never emits source lineage or a branch.

Node selection:

  • worktree: <name> selects a declared logical worktree.
  • worktree: none opts out and uses the project root.
  • If exactly one worktree is declared, provider nodes without an explicit selector inherit it.
  • If multiple worktrees are declared, provider nodes must select one explicitly or set worktree: none.

Same-name kind: worktree writers must be ordered by the DAG. Different logical worktree names are independent source lines and are not merged implicitly. setup_profile, create_branch, and branch_name are valid only for kind: worktree; branch_name requires create_branch: true.

Nodes

Field Description
id Node ID.
mode parallel, sequential, input, or foreach.
providers Provider shorthand strings or provider objects.
needs Upstream node IDs.
continue_on_failure Treat selected parallel or review-loop failure policies as successful node completion.
findings Write a findings artifact for this node. Defaults to false.
source Input node file source. Only valid for mode: input.
depth Positive sequential execution depth. Defaults to 1.
audit_rounds Positive sequential review-loop audit round count. Defaults to 1 when reviewers are present.
review_starts_with executor or reviewer for sequential executor/reviewer review loops. Defaults to executor.
failure_threshold Parallel-node failure threshold. Must be less than provider count.
token_budget Node token budget override.
worktree Node worktree selector. Not valid for input or foreach nodes.

Node IDs must match [a-z0-9._-]+, cannot be . or .., and cannot use the reserved run-root names logs, manifests, preflight, or workspace-exports.

Node Modes

mode selects the execution pattern inside a node:

Mode Providers Mode-specific controls Result selection
input None. source only. The referenced file is copied as the node result.
foreach None on the group; child nodes may use providers. workflow, item_input, items, max_items, inputs, with. An ordered index of terminal child results.
parallel One or more executors. Reviewers are rejected. failure_threshold, continue_on_failure. Latest artifact for each provider task is aggregated.
sequential with one provider Exactly one executor. depth. Latest executor round is selected.
sequential with multiple providers One or more executors followed by one or more reviewers. depth, audit_rounds, review_starts_with, continue_on_failure. Runtime review-loop status selects canonical executor and reviewer artifacts.

Provider nodes can also use findings, token_budget, and worktree where the field is otherwise valid.

Parallel nodes render one executor prompt and send it to each provider concurrently. settings.max_parallel_invocations can cap provider calls inside the node. failure_threshold defaults to 0, so any provider failure fails the node unless a threshold or continue_on_failure allows completion.

Sequential single-provider nodes do not run review loops. depth is the total number of executor rounds, and audit_rounds is invalid.

For task-oriented examples, see Node modes and provider roles and Review loops.

Review-Loop Details

Sequential multi-provider nodes run review loops. Providers must start with a contiguous executor segment and end with a contiguous reviewer segment. In each review round, reviewers receive the same reviewer prompt and current executor output. With one reviewer, that reviewer must approve. With multiple reviewers, all reviewers must approve.

For a visual walkthrough of executor output, reviewer verdicts, remediation, depth, and audit_rounds, see Review loops.

review_starts_with controls only the first phase inside a sequential review loop. It does not change mode, provider roles, or provider declaration order. Omit it or set executor for the usual executor-candidate-then-reviewer flow. Set reviewer to run a round-0 reviewer pass against existing review context before the local-round-1 executor candidate. Reviewer-first nodes still require both executor and reviewer providers, still finalize through the canonical executor output, and do not add a downstream artifact protocol.

For review loops, depth is remediation depth inside each audit round. A depth of 1 allows one fix attempt after the initial reviewed candidate. audit_rounds controls fresh audit passes and must not exceed settings.max_audit_rounds.

Executor-first review-loop order is:

for audit_round in 1..audit_rounds:
  for local_round in 1..depth+1:
    executor candidate exists or is remediated
    reviewer providers review the current candidate
    stop if all reviewers approve

Local round 1 reviews the initial candidate. Later local rounds are remediation attempts. If a later audit round has a valid output from the prior audit round, it starts by re-reviewing that output as local round 1; otherwise it invokes the executor for local round 1. A clean local-round-1 approval stops the whole loop.

Reviewer-first audit round 1 starts with a round-0 reviewer pass. If reviewers approve, the local-round-1 executor still runs with preservation guidance so the node produces a canonical same-node executor output. If reviewers report major or minor issues, that feedback becomes the local-round-1 executor handoff. depth still counts remediation attempts after the local-round-1 executor candidate; the round-0 review does not consume depth.

Review Responses

The structured review format and an example appear in the review loop guide. NO_FINDINGS and NITS_ONLY approve only when the major and minor issue sections are empty. Major or minor issues block approval regardless of the stated verdict. CHANGES_REQUESTED always blocks approval, even if all sections are empty or contain only nitpicks. Otherwise, Crewplane records NITS_ONLY when nitpicks are present and NO_FINDINGS when they are not.

Without a structured verdict, the entire response must be one of approved, good to go, lgtm, looks good, looks great, looks solid, merge ready, no blockers, no blocking issues, ready to merge, or ship it to count as approval. Matching ignores case and whitespace differences and permits one final . or !. Quotes, Markdown formatting, questions, conditions, and surrounding prose prevent a match. Nitpick prose alone does not imply approval. Crewplane recognizes some plain-text requests for changes; other responses are saved as feedback but do not count as approval.

Provider Objects

providers:
  - provider: codex
    model: gpt-5.5
    reasoning: xhigh
    role: executor

Provider object fields:

Field Description
provider Agent name from .crewplane/config.yml. Required.
model Optional model override for this provider use.
reasoning Optional provider-native reasoning request for the built-in CLI invoker with provider_kind: codex or claude; also accepted and ignored by the built-in mock invoker.
role executor or reviewer. Defaults to executor.

Roles are executor and reviewer. Parallel nodes do not allow reviewers. Sequential single-provider nodes must use one executor provider and cannot set audit_rounds; depth is the total number of executor rounds. Sequential multi-provider review loops must start with a contiguous executor segment and end with a contiguous reviewer segment. Use review_starts_with, not provider reordering, when reviewers should run before the first executor candidate.

Provider shorthand strings are executor providers. Use provider objects when a provider needs a model or reasoning override, or role: reviewer.

reasoning is an opaque provider-native token, not a portable Crewplane effort scale. Crewplane records it as requested_reasoning and includes it in execution identity. When omitted or set to null, Crewplane supplies no reasoning argument and the provider's existing configuration remains in control. With the built-in CLI invoker, direct reasoning selectors in cli_cmd, extra_args, or CLAUDE_CODE_EFFORT_LEVEL conflict with a first-class request and fail preflight. For Claude, that includes effortLevel and env.CLAUDE_CODE_EFFORT_LEVEL in explicit --settings JSON or files. Unrelated Claude settings remain valid.

The built-in mock invoker accepts valid reasoning tokens for any provider kind. See Mock Validation for its validation and provenance behavior.

Input Nodes

Input nodes load a file without invoking a provider:

nodes:
  - id: standards.file
    mode: input
    source: "{{file:docs/standards.md}}"

Rules:

  • source must be exactly one raw {{file:...}} template.
  • source follows the same terminal-result access policy as other file templates.
  • No Markdown body section is allowed.
  • No providers, needs, findings, depth, audit_rounds, review_starts_with, failure_threshold, continue_on_failure, token_budget, or worktree selector is allowed.

Foreach Nodes

mode: foreach runs one fixed child workflow for each object in an ordered collection. It uses the parent run and scheduler. The group completes after all instances succeed and publishes a JSON result index through {{group.output}}.

Field Contract
id, mode, needs Group identity, foreach, and authored prerequisites.
workflow Fixed .md path relative to the declaring workflow, within the project root.
item_input Name of a declared child input that receives one JSON object.
items Literal array of JSON objects, or exactly one upstream {{node.output}} or {{node.findings}} reference.
max_items Optional for literal arrays; required for artifact references. When supplied, must be a strict positive integer.
inputs Optional mapping of other child input names to caller node IDs.
with Optional string parameters substituted for {{param:key}} during composition, shared by every instance.

These are the only foreach fields. Provide an empty or HTML-comment-only ## <id> section. Provider, prompt, worktree, findings, and invocation/review/ failure-policy fields are rejected even when explicitly empty or false.

items max_items Result
Literal array, including [] Omitted Accepted; preflight uses the array length as its bound.
Literal array Positive integer at least its length Accepted; the cap acts as an optional assertion.
Literal array Smaller than its length Rejected during preflight.
Artifact reference Omitted Rejected during declaration validation.
Artifact reference Positive integer Accepted; the resolved collection must fit before any child starts.
Either form Explicit null, boolean, string, fractional number, zero, or negative value Rejected.

Omit the key to infer a literal bound; max_items: null does not mean omission. Every artifact reference requires an explicit cap, including references to input outputs and earlier foreach result indexes. Literal arrays contribute their actual length to the generated-node budget, even when an explicit cap is larger.

Every collection or shared source must already be an ancestor through needs. Bindings do not authorize unrelated nodes. .output collection sources must be input or foreach nodes, whose outputs preserve raw data. Provider-generated collections use .findings from a node with findings: true and exactly one executor. Aggregate findings and ordinary wrapped provider outputs are rejected. Paths, commands, globbing, expressions, concatenated references, and metadata references such as output_path are not collections. Read a collection file through an ordinary input node.

For a .findings collection, Crewplane automatically adds max_items to the producer's executor prompt and reviewer task context as a limit on the executor's findings array. When multiple groups consume the same producer's findings, the prompt uses their smallest cap; each group keeps its own runtime cap. Configure collection size through max_items and keep authored prompts focused on item selection and structure. Crewplane does not rewrite conflicting limits in prose. Literal arrays, input outputs, and earlier foreach result indexes add no prompt instruction; index-source caps do not propagate to earlier producers or children. Runtime validation remains the hard limit: an oversized collection fails the group before its children start, without truncation or regeneration.

Collections must be arrays of objects with unique string keys and JSON values. Order and repeated objects are preserved; [] succeeds without child execution. Non-finite numbers, unsupported YAML values, invalid Unicode, cycles, and container nesting deeper than 64 are rejected, counting the collection array as depth 1. Collections and result indexes are limited to 1 MiB of canonical UTF-8 JSON; runtime collection artifacts must also fit that limit before decoding. The projected result index is checked before any child starts. Use smaller items or artifact references when the index would exceed its byte or depth limit. Template-looking strings inside items remain data.

Child input bindings follow static-import rules. Bound input fallback files are not read. Unknown names, duplicate normalized keys, or aliases binding the same child input twice are invalid. Distinct inputs may share a caller source. Unbound inputs retain their file sources. Child imports can forward both item and shared inputs. Parameters retain inheritance, override, unused-binding checks, and unbound param → var rewriting.

Preflight freezes and validates every child, including for an empty collection. Nested foreach is forbidden, including through child imports. Child repetition metadata does not create additional runs. Set a finite settings.max_concurrent_nodes and keep the combined bound within settings.max_expanded_nodes.

Generated IDs use ordinals, for example chunks.i0.analyze, never item fields. The <group-id>. prefix is reserved for generated nodes and worktrees; parent nodes cannot reference individual generated children. Each item input waits for the group's original prerequisites, independent child roots wait for that input, and the group waits for every instance terminal. Waiting groups consume no node concurrency slot. A failed child blocks the group and its downstream consumers; independent branches can continue.

Worktrees declared by the child are separate for each instance. Managed worktrees start from the captured project base and preserve internal lineage. Child provider nodes without a selected worktree use the shared project root. Shared artifact bindings retain existing cross-worktree restrictions and never transfer mutable caller checkouts. Explicit branch names must remain unique across instances.

See iteration examples and expansion artifacts and resume.

Prompt Sections

Every non-input node requires one ## <node-id> section.

Unmarked Markdown is shared prompt content. Authored role markers are only:

<!-- crewplane:executor -->
Executor-only prompt.
<!-- /crewplane:executor -->

<!-- crewplane:reviewer -->
Reviewer-only prompt.
<!-- /crewplane:reviewer -->

There is no authored shared marker.

Role markers must be standalone root-level HTML comments. Markers inside code fences, blockquotes, or lists are treated as literal prompt text.

Executors receive shared content plus executor segments. Reviewers receive shared content plus reviewer segments. In review loops, Crewplane also wraps reviewer prompts with reviewer-only instructions, current executor output, previous unresolved feedback when present, and the structured review contract. For review_starts_with: reviewer, the round-0 reviewer prompt uses the same shared plus reviewer content as existing review context before any same-node executor candidate exists.

Templates

Runtime template forms:

  • {{file:path}}
  • {{env:KEY}}
  • {{var:KEY}}
  • {{node.output}}
  • {{node.findings}}
  • {{node.output_path}}
  • {{node.findings_path}}
  • {{node.output_size}}
  • {{node.findings_size}}
  • {{node.output_sha256}}
  • {{node.findings_sha256}}

{{param:key}} is composition-time only. Bound parameters are substituted during Markdown workflow composition; unbound parameters are rewritten to {{var:key}} for runtime variable resolution.

Relative {{file:path}} paths resolve from the project root, including when the token is authored in an imported Markdown workflow. Imported workflow source paths remain provenance metadata for diagnostics and audit. All resolved paths are bounded to the project root unless explicitly allowlisted with settings.file_access.allowed_template_paths.

File references may read .crewplane/execution-results/<run-key>/ after the source run reaches succeeded, failed, or cancelled. Preflight verifies the terminal manifest and materializes the result into the immutable static bundle. Results from a running source run and all other runtime-owned paths remain blocked.

Node artifact references are valid only for upstream dependencies. Findings references require the upstream node to declare findings: true.

needs orders nodes but does not automatically decide what reviewers inspect. For reviewer-first review/fix nodes, put the review context in the prompt with explicit references such as multiple upstream {{node.output}} or {{node.findings}} values, metadata references like {{node.output_sha256}}, or {{file:path}}. A standalone project-root reviewer-first node can review visible project files with {{file:...}}; with managed workspaces, reviewer-first file references read the compiled Git source state selected by workspace policy rather than uncommitted manual edits.

Token Budget Override

token_budget:
  warn_threshold_chars: 100000
  fail_threshold_chars: 150000

fail_threshold_chars must be greater than or equal to warn_threshold_chars when both are set.