Compose reusable workflows
Build larger workflows from pieces you author and understand how Crewplane combines them before a run.
1. Import a workflow
Assemble Markdown workflows
Markdown workflows can import other Markdown workflows. Composition combines them before runtime validation and execution; people still author the source workflows.
imports: - path: ./review-findings-producer-example.task.md as: quality with: project_name: "current project" Import a workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Calling workflow → Reusable workflow · import as quality
- Reusable workflow → Combined workflow · compose
The importing file
The calling workflow names a Markdown file and assigns it the alias quality. The path is resolved relative to the file declaring the import.
imports:
- path: ./review-findings-producer-example.task.md
as: quality The reusable source
The imported workflow declares review.findings under its own local name. It remains a separate authored file and can be reused by another caller.
The composed node ID
Composition prefixes the imported node with quality and rewrites its dependencies and artifact references. Runtime validation sees the combined workflow with the qualified ID.
review.findings → quality.review.findings Resolve the import
The path is relative to the workflow that declares it and must stay within the project root. Duplicate aliases and unused with parameters fail during composition.
imports: - path: ./review-findings-producer-example.task.md as: quality with: project_name: "current project" Import a workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Calling workflow → Reusable workflow · import as quality
- Reusable workflow → Combined workflow · compose
The importing file
The calling workflow names a Markdown file and assigns it the alias quality. The path is resolved relative to the file declaring the import.
imports:
- path: ./review-findings-producer-example.task.md
as: quality The reusable source
The imported workflow declares review.findings under its own local name. It remains a separate authored file and can be reused by another caller.
The composed node ID
Composition prefixes the imported node with quality and rewrites its dependencies and artifact references. Runtime validation sees the combined workflow with the qualified ID.
review.findings → quality.review.findings Prefix imported nodes
as: quality prefixes imported node IDs: review.findings becomes quality.review.findings. Dependencies and node output references are updated to the combined names.
imports: - path: ./review-findings-producer-example.task.md as: quality with: project_name: "current project" Import a workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Calling workflow → Reusable workflow · import as quality
- Reusable workflow → Combined workflow · compose
The importing file
The calling workflow names a Markdown file and assigns it the alias quality. The path is resolved relative to the file declaring the import.
imports:
- path: ./review-findings-producer-example.task.md
as: quality The reusable source
The imported workflow declares review.findings under its own local name. It remains a separate authored file and can be reused by another caller.
The composed node ID
Composition prefixes the imported node with quality and rewrites its dependencies and artifact references. Runtime validation sees the combined workflow with the qualified ID.
review.findings → quality.review.findings Qualify worktrees
Imported worktree declarations and selectors also receive the alias. worktree: none remains the project-root opt-out; implicit single-worktree inheritance is resolved during composition.
Import a workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Calling workflow → Reusable workflow · import as quality
- Reusable workflow → Combined workflow · compose
The importing file
The calling workflow names a Markdown file and assigns it the alias quality. The path is resolved relative to the file declaring the import.
imports:
- path: ./review-findings-producer-example.task.md
as: quality The reusable source
The imported workflow declares review.findings under its own local name. It remains a separate authored file and can be reused by another caller.
The composed node ID
Composition prefixes the imported node with quality and rewrites its dependencies and artifact references. Runtime validation sees the combined workflow with the qualified ID.
review.findings → quality.review.findings 2. Supply parameters
Set a value
with supplies the imported workflow’s {{param:project_name}} value. The substitution happens during composition, before runtime validation.
imports: - path: ./review-findings-producer-example.task.md as: quality with: project_name: "current project" Resolve a parameter
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- param:project_name → with value · bound
- param:project_name → var:project_name · unbound
The imported placeholder
The reusable workflow can use project_name without fixing its value in the source. Composition decides whether to substitute a binding or leave a runtime variable.
{{param:project_name}} Substitute the supplied value
The caller’s with entry supplies the text during composition, before runtime validation. The imported placeholder is replaced with that value.
with:
project_name: "current project"
{{param:project_name}} → current project Resolve the value at runtime
If the caller does not bind project_name, composition rewrites its placeholder as a supported runtime variable reference. The value is then resolved when the workflow runs.
{{param:project_name}} → {{var:project_name}} Leave a runtime variable
An unbound {{param:key}} is rewritten to {{var:key}} so the resulting runtime workflow uses a supported runtime template.
Resolve a parameter
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- param:project_name → with value · bound
- param:project_name → var:project_name · unbound
The imported placeholder
The reusable workflow can use project_name without fixing its value in the source. Composition decides whether to substitute a binding or leave a runtime variable.
{{param:project_name}} Substitute the supplied value
The caller’s with entry supplies the text during composition, before runtime validation. The imported placeholder is replaced with that value.
with:
project_name: "current project"
{{param:project_name}} → current project Resolve the value at runtime
If the caller does not bind project_name, composition rewrites its placeholder as a supported runtime variable reference. The value is then resolved when the workflow runs.
{{param:project_name}} → {{var:project_name}} 3. Connect an input
Declare a fallback
standards_input is the public input name; standards-input is its fallback input node. When this workflow runs alone, it loads the fallback file.
inputs: standards_input: standards-inputnodes: - id: standards-input mode: input source: "{{file:docs/standards.md}}" - id: apply mode: parallel providers: [mock] needs: [standards-input]
## applyUse the standards:
{{standards-input.output}} Standalone fallback
Running the reusable workflow alone uses the fallback input.
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- docs/standards.md → standards-input · load
- standards-input → apply · needs and output
The fallback source
When the reusable workflow runs on its own, docs/standards.md provides the standards text. The input node reads it through a file template.
{{file:docs/standards.md}} A replaceable input
The public name standards_input points to standards-input as its fallback. A caller can bind the public name to another visible node when importing the workflow.
Use the standards
Apply waits for standards-input and inserts its saved output into the prompt. When a caller binds the public input, composition redirects both relationships to the bound source.
needs: [standards-input]
{{standards-input.output}} Use the fallback
The apply node waits for the input and inserts its saved output into the prompt. The public input makes that dependency replaceable by a caller.
inputs: standards_input: standards-inputnodes: - id: standards-input mode: input source: "{{file:docs/standards.md}}" - id: apply mode: parallel providers: [mock] needs: [standards-input]
## applyUse the standards:
{{standards-input.output}} Standalone fallback
Running the reusable workflow alone uses the fallback input.
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- docs/standards.md → standards-input · load
- standards-input → apply · needs and output
The fallback source
When the reusable workflow runs on its own, docs/standards.md provides the standards text. The input node reads it through a file template.
{{file:docs/standards.md}} A replaceable input
The public name standards_input points to standards-input as its fallback. A caller can bind the public name to another visible node when importing the workflow.
Use the standards
Apply waits for standards-input and inserts its saved output into the prompt. When a caller binds the public input, composition redirects both relationships to the bound source.
needs: [standards-input]
{{standards-input.output}} Connect a source
The calling workflow maps standards_input to the visible node handoff.standards. This connection is an input binding and overrides the fallback during composition.
imports: - path: ./review-fix-consumer-example.task.md as: fix inputs: standards_input: handoff.standards Bound input
The fallback is replaced while the workflows are combined; original files stay unchanged.
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- handoff.standards → fix.apply · rewritten dependency and output
Supply the caller’s node
The caller binds standards_input to handoff.standards. Composition removes the imported fallback and uses this visible node wherever the child depended on it.
inputs:
standards_input: handoff.standards Use the redirected artifact
The imported apply node becomes fix.apply. Its dependency and output reference now point to handoff.standards, while the authored source files stay unchanged.
{{standards-input.output}} → {{handoff.standards.output}} Follow the rewritten reference
The fallback node is removed. Dependencies on it now point to handoff.standards, and {{standards-input.output}} becomes {{handoff.standards.output}} in the combined workflow.
{{standards-input.output}}{{handoff.standards.output}} Bound input
The fallback is replaced while the workflows are combined; original files stay unchanged.
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- handoff.standards → fix.apply · rewritten dependency and output
Supply the caller’s node
The caller binds standards_input to handoff.standards. Composition removes the imported fallback and uses this visible node wherever the child depended on it.
inputs:
standards_input: handoff.standards Use the redirected artifact
The imported apply node becomes fix.apply. Its dependency and output reference now point to handoff.standards, while the authored source files stay unchanged.
{{standards-input.output}} → {{handoff.standards.output}} 4. Order imported workflows
Add import prerequisites
An import can declare needs to wait for specific nodes before its provider-backed entry branches start. If the child has multiple independent provider entry branches, every branch waits. No child input declaration is required for this ordering.
imports: - path: write-implementation-plan.task.md as: plan - path: plan-implementation.task.md as: implement inputs: implementation_plan: plan.plan.final - path: review-fix-iteration.task.md as: review needs: - plan.plan.final - implement.implement.handoff Order imported workflows
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- plan.plan.final → implement.implement.handoff · input
- plan.plan.final → review.review-fix-loop · needs
- implement.implement.handoff → review.review-fix-loop · needs
Provide the implementation plan
The plan import produces plan.plan.final. The implementation import binds that node to its declared implementation_plan input, connecting the plan artifact to the child.
Produce the handoff
The implementation workflow consumes the bound plan and produces implement.implement.handoff. The review import lists that handoff as one of its prerequisites.
Wait for both prerequisites
The review import waits for the plan and implementation handoff before its provider-backed entry branches start. These needs entries establish order; they do not insert either artifact into the review prompt.
Pass material explicitly
Import needs adds order, not prompt content. Supply the plan or handoff through explicit prompt references or declared inputs. File inputs retain their resolution timing and normal workspace lineage restrictions apply.
imports: - path: write-implementation-plan.task.md as: plan - path: plan-implementation.task.md as: implement inputs: implementation_plan: plan.plan.final - path: review-fix-iteration.task.md as: review needs: - plan.plan.final - implement.implement.handoff Order imported workflows
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- plan.plan.final → implement.implement.handoff · input
- plan.plan.final → review.review-fix-loop · needs
- implement.implement.handoff → review.review-fix-loop · needs
Provide the implementation plan
The plan import produces plan.plan.final. The implementation import binds that node to its declared implementation_plan input, connecting the plan artifact to the child.
Produce the handoff
The implementation workflow consumes the bound plan and produces implement.implement.handoff. The review import lists that handoff as one of its prerequisites.
Wait for both prerequisites
The review import waits for the plan and implementation handoff before its provider-backed entry branches start. These needs entries establish order; they do not insert either artifact into the review prompt.
Reference findings separately
An input binding supplies the source node’s full output; it does not automatically select a separate findings file. For a producer imported as quality, reference its findings explicitly.
Use the review findings:
{{quality.review.findings.findings}} Review findings handoff
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- quality.review.findings → Later prompt · findings
The findings producer
Importing review.findings as quality gives the producer the ID quality.review.findings. Its separate findings artifact can be referenced by a later prompt.
Ask for the findings
The later prompt explicitly inserts the findings artifact. An input binding to the producer supplies its output and does not automatically select the separate findings file.
{{quality.review.findings.findings}} 5. Repeat a workflow for items
Set up a repeated child
Use foreach when the procedure is fixed and the number of items comes from a literal collection or upstream saved output. Declare ordinary child inputs, bind one as item_input, and connect shared context with inputs.
Here folders runs the fixed child workflow for two folder values. A literal collection supplies its own bound; the child declares an input named item.
nodes: - id: folders mode: foreach workflow: audit-folder.task.md item_input: item items: - {folder: src} - {folder: tests} Repeat a child workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Collection → foreach group · items
- foreach group → Result index · collect
- Result index → Later node · reference
Choose the collection
A literal list or an upstream artifact supplies the items. In the folder example, the two values identify src and tests for separate child runs.
Run the child for each item
The foreach group binds each item to a declared child input and runs the fixed child workflow for it. Shared inputs can supply context used by every child.
Collect ordered results
After all children succeed, the group publishes an ordered index of result descriptors. An empty collection produces an empty index, and a failed child prevents the index from being published.
Read results downstream
A later node depends on the group and reads its index. It can follow descriptors to individual terminal outputs, or another foreach group can consume the index.
Use the result index
A later node depends on the group ID and reads its ordered result index, then follows result descriptors to individual terminal outputs. Another foreach group can consume that index. The parent remains the run boundary, even when the child declares repetition metadata.
Repeat a child workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Collection → foreach group · items
- foreach group → Result index · collect
- Result index → Later node · reference
Choose the collection
A literal list or an upstream artifact supplies the items. In the folder example, the two values identify src and tests for separate child runs.
Run the child for each item
The foreach group binds each item to a declared child input and runs the fixed child workflow for it. Shared inputs can supply context used by every child.
Collect ordered results
After all children succeed, the group publishes an ordered index of result descriptors. An empty collection produces an empty index, and a failed child prevents the index from being published.
Read results downstream
A later node depends on the group and reads its index. It can follow descriptors to individual terminal outputs, or another foreach group can consume the index.
Keep static imports in composition
Static imports inside the repeated child are composed before execution. Consult the upstream examples and syntax reference for the supported limits, binding rules, and recovery behavior.
Repeat a child workflow
Hover or focus a node to preview its explanation; click to keep it.Tap a node to select its explanation.
- Collection → foreach group · items
- foreach group → Result index · collect
- Result index → Later node · reference
Choose the collection
A literal list or an upstream artifact supplies the items. In the folder example, the two values identify src and tests for separate child runs.
Run the child for each item
The foreach group binds each item to a declared child input and runs the fixed child workflow for it. Shared inputs can supply context used by every child.
Collect ordered results
After all children succeed, the group publishes an ordered index of result descriptors. An empty collection produces an empty index, and a failed child prevents the index from being published.
Read results downstream
A later node depends on the group and reads its index. It can follow descriptors to individual terminal outputs, or another foreach group can consume the index.