Skip to content

Workflows

Workflows are the orchestration engine of Red Station. They define how work gets done, chaining together Agents, Tools, and Human interactions into a reliable, repeatable process.

The Concept

A Workflow is a state machine defined in YAML. Unlike a simple script, a workflow handles:

  • Context Passing: Passing outputs from one step (e.g., a Plan) as inputs to the next (e.g., the Coder).
  • Resilience: Automatic retries and error handling.
  • Human-in-the-Loop: Pause execution for human approval.

Structure

A workflow consists of:

  1. Steps: Atomic units of work.
    • agent: Run an AI agent.
    • script: Run a shell script.
    • mcp: Call a tool directly.
    • human: Wait for approval.
  2. Transitions: Logic defining the flow between steps.
  3. Triggers: Events that start the workflow (Manual, Webhook, Schedule).

Example: Ticket to PR

The default ticket-to-pr workflow demonstrates this power:

  1. Planner analyzes the ticket and existing code.
  2. Coder implements the changes based on the plan.
  3. Human reviews the changes (Hold for approval).
  4. System opens a Pull Request via GitHub MCP.

CLI Commands

bash
# List available workflows
pilot workflow list

# Show workflow details
pilot workflow show ticket-to-pr

# Run a task using a specific workflow
pilot workflow run ticket-to-pr --task PROJ-123

Configuration (YAML)

Workflows are defined in ~/.pilot/workflows/.

yaml
workflow:
  id: deploy-flow
  name: Deploy and Notify

steps:
  - id: build
    type: script
    command: ./scripts/build.sh

  - id: approve
    type: human
    message: "Build successful. Deploy to prod?"

  - id: deploy
    type: script
    command: ./scripts/deploy.sh

transitions:
  - from: build
    to: approve
    when: build.exit_code == 0
  - from: approve
    to: deploy
    when: approved == true

See Workflow YAML Spec for full details.

Released under the MIT License.