Workflows define how agents collaborate to complete tasks. This guide explains how to create, customize, and use workflows in APEX.
A workflow is defined by a YAML file in .apex/workflows/. It specifies:
- Stages - Sequential steps in the workflow
- Agents - Which agent handles each stage
- Dependencies - How stages relate to each other
- Outputs - What each stage produces
name: workflow-name
description: What this workflow accomplishes
stages:
- name: stage-name
agent: agent-name
description: What this stage does
outputs:
- output_name| Field | Required | Description |
|---|---|---|
name |
Yes | Unique workflow identifier |
description |
Yes | Brief description of the workflow |
trigger |
No | Events that can trigger this workflow |
stages |
Yes | Array of stage definitions |
| Field | Required | Description |
|---|---|---|
name |
Yes | Unique stage identifier |
agent |
Yes | Name of agent to use |
description |
Yes | What this stage accomplishes |
dependsOn |
No | Array of stage names that must complete first |
outputs |
No | Array of output names produced |
condition |
No | Expression that must be true to run |
timeout |
No | Maximum time in seconds |
retries |
No | Number of retry attempts on failure |
APEX includes three default workflows:
The standard workflow for implementing new features:
name: feature
description: Full feature implementation workflow
stages:
- name: planning
agent: planner
description: Create implementation plan
outputs:
- implementation_plan
- subtasks
- name: architecture
agent: architect
description: Design technical solution
dependsOn: [planning]
outputs:
- technical_design
- name: implementation
agent: developer
description: Write the code
dependsOn: [architecture]
outputs:
- code_changes
- branch_name
- name: testing
agent: tester
description: Create and run tests
dependsOn: [implementation]
outputs:
- test_files
- coverage_report
- name: review
agent: reviewer
description: Review code quality
dependsOn: [implementation, testing]
outputs:
- review_findingsStreamlined workflow for fixing bugs:
name: bugfix
description: Bug investigation and fix workflow
stages:
- name: investigation
agent: developer
description: Investigate and locate the bug
outputs:
- root_cause
- affected_files
- name: fix
agent: developer
description: Implement the fix
dependsOn: [investigation]
outputs:
- code_changes
- name: testing
agent: tester
description: Add regression tests
dependsOn: [fix]
outputs:
- test_files
- name: review
agent: reviewer
description: Review the fix
dependsOn: [fix, testing]
outputs:
- review_findingsWorkflow for code refactoring:
name: refactor
description: Code refactoring workflow
stages:
- name: analysis
agent: architect
description: Analyze current code and plan refactoring
outputs:
- refactoring_plan
- name: refactor
agent: developer
description: Execute refactoring
dependsOn: [analysis]
outputs:
- code_changes
- name: testing
agent: tester
description: Verify no regressions
dependsOn: [refactor]
outputs:
- test_results
- name: review
agent: reviewer
description: Review refactored code
dependsOn: [refactor, testing]
outputs:
- review_findings# .apex/workflows/docs.yaml
name: docs
description: Generate or update documentation
stages:
- name: analysis
agent: planner
description: Identify what needs documentation
outputs:
- documentation_plan
- name: writing
agent: documenter
description: Write the documentation
dependsOn: [analysis]
outputs:
- documentation_files
- name: review
agent: reviewer
description: Review documentation quality
dependsOn: [writing]
outputs:
- review_findings# .apex/workflows/security-audit.yaml
name: security-audit
description: Comprehensive security audit
stages:
- name: code-scan
agent: security
description: Scan code for vulnerabilities
outputs:
- vulnerability_report
- name: dependency-check
agent: security
description: Check for vulnerable dependencies
outputs:
- dependency_report
- name: remediation
agent: developer
description: Fix identified issues
dependsOn: [code-scan, dependency-check]
outputs:
- fixes
- name: verification
agent: security
description: Verify fixes
dependsOn: [remediation]
outputs:
- verification_reportMinimal workflow for simple changes:
# .apex/workflows/quick.yaml
name: quick
description: Quick fix without full review cycle
stages:
- name: fix
agent: developer
description: Make the change
outputs:
- code_changesFor reviewing external pull requests:
# .apex/workflows/pr-review.yaml
name: pr-review
description: Review a pull request
stages:
- name: code-review
agent: reviewer
description: Review code quality and patterns
- name: security-review
agent: security
description: Check for security issues
- name: test-review
agent: tester
description: Verify test coverageStages run in order when dependencies are specified:
stages:
- name: step1
agent: planner
- name: step2
agent: developer
dependsOn: [step1]
- name: step3
agent: tester
dependsOn: [step2]Stages without dependencies on each other can run concurrently:
stages:
- name: planning
agent: planner
- name: frontend # These run in parallel
agent: developer
dependsOn: [planning]
- name: backend # These run in parallel
agent: developer
dependsOn: [planning]
- name: integration
agent: tester
dependsOn: [frontend, backend] # Waits for bothstages:
- name: plan
agent: planner
- name: code
agent: developer
dependsOn: [plan]
- name: test
agent: tester
dependsOn: [plan]
- name: review
agent: reviewer
dependsOn: [code, test] # Waits for both pathsRun stages only when conditions are met:
stages:
- name: analysis
agent: planner
outputs:
- has_breaking_changes
- name: migration
agent: developer
dependsOn: [analysis]
condition: "outputs.analysis.has_breaking_changes == true"Set maximum execution time:
stages:
- name: long-analysis
agent: architect
timeout: 600 # 10 minutesConfigure automatic retries on failure:
stages:
- name: flaky-operation
agent: developer
retries: 3stages:
- name: robust-stage
agent: developer
timeout: 300
retries: 2
condition: "outputs.planning.proceed == true"Define how workflows can be triggered:
trigger:
- manual # Via CLI
- apex:feature # Via specific command
- github:issue # On GitHub issue creation
- cron:daily # Scheduled executionapex run "Add user authentication" --workflow feature
apex run "Fix login bug" --workflow bugfix
apex run "Update README" --workflow docsapex workflowsSet in config:
# .apex/config.yaml
workflow:
default: featureStart with minimal workflows and add complexity only when needed.
# Simple is often better
stages:
- name: do-the-thing
agent: developerCreate workflows that fit your actual development patterns:
feature- New functionalitybugfix- Bug fixesrefactor- Code cleanupdocs- Documentationquick- Small changes
More stages = more thorough but slower.
# Thorough workflow (slower)
stages: [plan, architecture, implement, test, review, document]
# Quick workflow (faster)
stages: [implement, test]Match agent capabilities to stage requirements:
- Planning stages: Use
opusmodel agents - Implementation: Use
sonnetmodel agents - Quick reviews: Use
haikumodel agents
Specify what each stage produces:
outputs:
- implementation_plan # Good - specific
- result # Bad - too vagueAdd review stages after critical operations:
stages:
- name: database-migration
agent: developer
- name: verify-migration
agent: tester
dependsOn: [database-migration]apex run "task" --workflow feature --verboseapex status <task-id>apex logs <task-id>Plan without executing:
apex run "task" --workflow feature --dry-run- Agent Authoring Guide - Create custom agents
- Configuration Reference - Configure APEX settings
- Best Practices - Tips for effective usage
- API Reference - REST API documentation