Skip to main content
A workflow file defines how your agents execute: the order they run and how they interact with users.
Before creating a workflow, make sure you’ve already configured your agents and written your prompts.

Workflow File Location

Workflow files live in templates/workflows/ and use the .workflow.js extension:
my-workflow-codemachine
templates
workflows
my-workflow.workflow.js

Basic Structure

Every workflow exports a default object with a name and steps:
templates/workflows/my-workflow.workflow.js

Name

Names should be short and descriptive. They define the objective of your workflow and help users understand what it accomplishes.
Example names:
  • Code Review Pipeline
  • API Generator
  • Documentation Writer
  • Bug Fixer

Steps

Steps are agents set in sequence. The resolveStep() function loads an agent from your config/main.agents.js. Arrangement matters. Each step receives context from previous steps, so the order determines how information flows through your workflow.

Workflow Modes

Choose how your workflow runs: Set the mode using autonomousMode:

Adding Separators

Use separator() to add visual dividers between workflow phases:
templates/workflows/code-review.workflow.js
Separators appear in the TUI timeline to help users understand workflow progress.

Interactive vs Non-Interactive Steps

By default, steps are interactive - the workflow waits for user input. Set interactive: false to auto-advance:
A common pattern is making the first step interactive for gathering requirements, then running subsequent steps non-interactively.

Complete Simple Example

Here’s a complete workflow for a basic code generation pipeline:
templates/workflows/code-generator.workflow.js

Running Your Workflow

Once your workflow is complete, run it with:
Or select it from the TUI workflow picker.

Keyboard Shortcuts


Validation Checklist

Before running your workflow, verify:
1

Agent IDs Match

Every agent ID in resolveStep() exists in config/main.agents.js
2

Prompt Files Exist

All promptPath references in agent configs point to existing files
3

Placeholders Registered

All placeholders used in prompts are registered in config/placeholders.js

Next Steps

Ready for more? Learn about tracks, conditions, modules, controllers, and sub-agents.

Advanced Workflows

Tracks, conditions, modules, and controllers

Workflow Examples

Complete real-world examples