> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sudocode.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Dispatching Workflows

> Execute workflows with automated agent coordination from your spec

## What are Workflows?

Workflows in sudocode allow you to execute multiple issues in their dependency order. Just specify a spec, a root issue, or manually select issues to run as a coordinated workflow.

sudocode ensures all dependencies are respected and handles the execution order automatically.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/crazy-workflow.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=8fe7cd0561efa569ba8f6e8a81037468" alt="A workflow in progress" width="3818" height="1966" data-path="images/walkthroughs/workflow-example/crazy-workflow.png" />
</Frame>

## Example: Implementing Execution Badges

Let's walk through a complete example of how to combine spec-driven development with workflows to implement a new feature in sudocode.

### The Goal

We want to add badges to sudocode execution chats. When chatting with sudocode during an issue execution, users should see visual badges showing all the specs and issues that have been created or modified throughout the session. This provides better context awareness and helps track what the agent has been working on.

### Phase 1: Create and Refine the Spec

**Step 1: Create a new spec**

Navigate to `localhost:3000` and click the "Create Spec" button to start defining your feature.

<Frame>
  <img src="https://mintcdn.com/sudocode/MO2Drlz_NEwnOn-1/images/walkthroughs/workflow-example/create-spec.png?fit=max&auto=format&n=MO2Drlz_NEwnOn-1&q=85&s=0af84771a1f7a62f8e217290d35143af" alt="Creating a new spec in the sudocode web interface" width="3800" height="1972" data-path="images/walkthroughs/workflow-example/create-spec.png" />
</Frame>

**Step 2: Co-write the spec with an agent**

You can work with an agent to draft the specification. The agent helps you think through requirements, edge cases, and implementation details.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/write-spec.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=a0e87b272891fcc9d49178f02698d93c" alt="Co-writing a spec with an AI agent" width="3838" height="1994" data-path="images/walkthroughs/workflow-example/write-spec.png" />
</Frame>

Ask the agent to help define:

* User-facing behavior (what badges should show)
* Technical requirements (which entities to track)
* UI/UX considerations (badge placement, styling)
* Success criteria (how to validate it works)
* Abstractions (what interfaces will be modified as an outcome)

**Step 3: Converse with the agent to refine the spec**

Continue the conversation to add details, clarify requirements, and ensure the spec is comprehensive.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/converse-spec.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=a4c013727e58114ba9575402fc5e952e" alt="Conversing with agent to refine specification details" width="3828" height="1978" data-path="images/walkthroughs/workflow-example/converse-spec.png" />
</Frame>

The agent can help you:

* Identify missing requirements
* Suggest implementation approaches
* Consider edge cases
* Define acceptance criteria

**Step 4: Inspect and edit the spec**

You can review and edit the spec directly in the interface or continue collaborating with the agent to refine it.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/edit-spec-plan.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=e740ff6267cbd10038626c4f5037c871" alt="Inspecting and editing the spec inline or with agent assistance" width="3822" height="1990" data-path="images/walkthroughs/workflow-example/edit-spec-plan.png" />
</Frame>

This step ensures your spec is clear, complete, and ready for implementation planning.

### Phase 2: Plan Implementation

**Step 5: Generate implementation plan**

Once your spec is ready, click "Plan Implementation" to have sudocode break down the spec into actionable issues.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/plan-implementation.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=3580218bedf254eb220e3e6e8c158847" alt="Planning implementation by breaking spec into issues" width="1462" height="736" data-path="images/walkthroughs/workflow-example/plan-implementation.png" />
</Frame>

sudocode analyzes your spec and creates:

* Individual issues for each component or step
* Dependency relationships between issues and specifications

**Step 6: Inspect the generated issues**

Review the issues that were created from your spec. You can see modify issues as needed.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/inspect-issues.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=bb8301c066f39c795a57bf8c9d47be55" alt="Inspecting generated issues and their dependencies" width="3832" height="1956" data-path="images/walkthroughs/workflow-example/inspect-issues.png" />
</Frame>

Each issue includes:

* Clear description of what needs to be implemented
* Links to the parent spec
* Dependency relationships with other issues

**Step 7: Click Run Workflow**

When you're ready to execute the implementation, click the "Run Workflow" button.

<Frame>
  <img src="https://mintcdn.com/sudocode/MO2Drlz_NEwnOn-1/images/specs/run-spec-workflow.png?fit=max&auto=format&n=MO2Drlz_NEwnOn-1&q=85&s=ceb763e2254bf6a4ae7446af6a05123f" alt="Run Workflow button to start execution" width="3834" height="1996" data-path="images/specs/run-spec-workflow.png" />
</Frame>

### Phase 3: Execute the Workflow

**Step 8: Configure workflow execution**

The workflow creation screen lets you choose which issues to run and how to execute them.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/create-workflow-screen.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=58dde9acab95f040645a2376f424d418" alt="Workflow creation screen showing execution options" width="1232" height="1846" data-path="images/walkthroughs/workflow-example/create-workflow-screen.png" />
</Frame>

You can:

* Select specific issues to include
* Choose to run from a spec (runs all implementing issues)
* Choose to run from a root issue (runs all blocking dependencies)
* Review the execution order before starting

**Step 9: Monitor workflow progress**

Once started, the workflow executes issues in dependency order. You can monitor progress in real-time.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/workflow-started.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=633749ecb61cd9014178f9b27e7e0dc4" alt="Workflow in progress showing active and completed issues" width="3818" height="2004" data-path="images/walkthroughs/workflow-example/workflow-started.png" />
</Frame>

As the workflow executes:

* Issues with no blockers start immediately
* Subsequent issues automatically start when dependencies complete
* Each issue runs in an isolated worktree
* You can click any issue to view its progress and agent conversation
* Real-time status updates show what's being worked on

### Phase 4: Review and Merge Changes

**Step 10: Review workflow changes**

When the workflow completes, you can review all the changes that were made across all issues.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/workflow-merge-changes.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=53230dfb1c9fdbcca67e2d4d5aad31e8" alt="Reviewing changes from completed workflow" width="3820" height="1968" data-path="images/walkthroughs/workflow-example/workflow-merge-changes.png" />
</Frame>

The workflow review shows:

* All completed issues
* Files modified by each issue
* Full diff of changes
* Test results and validation
* Agent decisions and implementation notes

**Step 11: Merge worktree to main branch**

Once you've reviewed the changes and are satisfied with the implementation, click "Merge Worktree" to integrate all changes into your main branch.

<Frame>
  <img src="https://mintcdn.com/sudocode/jD7tbur9b9xr5ZvW/images/walkthroughs/workflow-example/merge-worktree.png?fit=max&auto=format&n=jD7tbur9b9xr5ZvW&q=85&s=f9096dad4ac6e242d474ee29a51a8151" alt="Merging worktree changes to main branch" width="2000" height="1558" data-path="images/walkthroughs/workflow-example/merge-worktree.png" />
</Frame>

When you merge:

* All commits from the workflow worktree are merged into your main branch

<Note>
  **What just happened?**

  You successfully implemented execution badges using a complete spec-driven workflow:

  1. Created a spec collaboratively with an agent
  2. Refined the requirements through conversation
  3. Generated an implementation plan with dependency-ordered issues
  4. Executed all issues in an automated workflow
  5. Reviewed and merged the complete implementation
</Note>

## Benefits of Workflows

<CardGroup cols={2}>
  <Card title="Automated Coordination" icon="gears">
    **No manual orchestration needed**

    * sudocode handles execution order
    * Parallel work runs concurrently
    * Dependencies respected automatically
    * Hands-off execution
  </Card>

  <Card title="Isolated Execution" icon="box">
    **Safe, conflict-free processing**

    * Each issue in separate worktree
    * No interference between agents
    * Easy rollback per issue
    * Clean merge points
  </Card>

  <Card title="Visibility" icon="eye">
    **Track progress in real-time**

    * See all issues in workflow
    * Monitor agent decisions
    * Review files as they're modified
    * Understand implementation choices
  </Card>
</CardGroup>

## When to Use Workflows

Workflows are ideal for:

* **Feature development from specs**: Break down specs into coordinated implementation steps
* **Multi-component features**: UI → logic → API → testing phases that depend on each other
* **Refactoring projects**: Multiple coordinated code changes across related files
* **Multi-step bug fixes**: Test writing, strategy planning, implementation, validation
* **Migration tasks**: Sequential steps with clear dependencies

Workflows are less useful for:

* Single, standalone issues with no dependencies
* Exploratory work without clear structure
* Tasks requiring frequent human decision-making between steps

## Best Practices

<AccordionGroup>
  <Accordion title="Start with a clear spec">
    Begin your workflow by creating a detailed spec collaboratively with an agent. A good spec should include:

    **Essential elements:**

    * Clear user-facing behavior description
    * Technical requirements and constraints
    * UI/UX considerations
    * Success criteria and acceptance tests
    * Edge cases and error handling

    **Why this matters:**

    * Agents can generate better implementation plans from detailed specs
    * Issues created from specs have clearer scope and dependencies
    * You catch requirement gaps before implementation starts
    * The spec serves as documentation for the feature

    You can always refine the spec through conversation before planning implementation.
  </Accordion>

  <Accordion title="Let sudocode plan the implementation">
    Use the "Plan Implementation" feature to automatically break down specs into issues rather than creating issues manually.

    **Benefits:**

    * Automatically generates dependency relationships
    * Creates focused, single-responsibility issues
    * Ensures nothing from the spec is missed
    * Saves time compared to manual planning

    You can always review and modify the generated issues before running the workflow.
  </Accordion>

  <Accordion title="Run workflows from specs">
    When starting a workflow, select "From Spec" to run all implementing issues in dependency order.

    **Why this works:**

    * The workflow engine automatically identifies all issues that implement the spec
    * Dependencies are traced and respected
    * You get a complete implementation without manual coordination
    * All work is tracked back to the original spec

    Alternatively, you can select "From Root Issue" to run from a specific issue and its dependencies.
  </Accordion>

  <Accordion title="Review before merging">
    Always review worktree changes before merging into your main branch.

    **What to check:**

    * Implementation matches spec requirements
    * All issues completed successfully
    * Tests are passing
    * No unintended side effects
    * Code quality meets standards
    * Agent decisions make sense

    You can inspect individual issues and files during workflow execution to catch problems early.
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Merge conflicts in issues.jsonl or specs.jsonl">
    **Cause:** Multiple worktrees modified the same issues or specs

    **Solution:**

    ```bash theme={null}
    # Run the sudocode conflict resolver
    sudocode resolve-conflicts

    # This intelligently merges changes from both versions
    # Then commit the resolved files
    git add .sudocode/
    git commit -m "Resolve sudocode conflicts from workflow"
    ```

    The `resolve-conflicts` command automatically handles concurrent modifications to sudocode metadata files.
  </Accordion>

  <Accordion title="Workflow stuck: Issue not progressing">
    **Cause:** Agent encountered an error or needs human input

    **Solution:**

    1. Click on the stuck issue to view details
    2. Review the agent conversation to identify the blocker
    3. If the agent needs clarification, provide it in the issue chat
    4. If the agent errored, you can restart the issue or manually fix and continue

    Workflows pause when an issue can't make progress, allowing you to intervene.
  </Accordion>

  <Accordion title="Want to cancel a running workflow">
    **Cause:** Need to stop execution due to errors or changed requirements

    **Solution:**
    Simply press Cancel and start a new workflow! You can remove your existing workflow and worktree as needed.

    Cancelled workflows don't affect your main branch since work is isolated in worktrees.
  </Accordion>
</AccordionGroup>

## Related Documentation

<CardGroup cols={3}>
  <Card title="Spec-Driven Development" icon="book" href="/examples/spec-driven-development">
    Complete tutorial on spec-driven workflows
  </Card>

  <Card title="Web UI Overview" icon="browser" href="/web/overview">
    Complete web interface guide
  </Card>

  <Card title="Understanding Relationships" icon="diagram-project" href="/concepts/relationships">
    How specs, issues, and dependencies connect
  </Card>
</CardGroup>
