# Kanban Decision Criteria

When to include a kanban board definition in the generated bundle — and when
not to.

---

## The Principle

Kanban adds value when work flows through a **predictable, repeatable
sequence of states** where **limiting work-in-progress** and **visualizing
flow** produces actionable insight.

Kanban subtracts value when work is **emergent, exploratory, or reactive** —
situations where the states are unpredictable and WIP limits don't apply
because there's nothing to limit.

---

## Kanban-Appropriate Signals

Include a kanban board when the interview reveals:

### 1. Linear Phase Structure

The user describes their workflow as a sequence:
> "I always start with triage, then pick something to build, then review
> it, then ship it."

**Translation:** A → B → C → D structure. Each phase has a clear entry and
exit. Phases don't overlap or loop.

### 2. Explicit Hand-Offs

The user mentions waiting on others or passing work between people:
> "After I finish my part, it goes to review. Sometimes it sits there for
> a day."

**Translation:** There are queues. Work accumulates between phases. Visualizing
the queue helps manage flow.

### 3. Multiple Concurrent Items

The user tracks more than one active thing:
> "I usually have 3-4 things in progress at various stages."

**Translation:** WIP limits are meaningful. Without a board, the user may
not realize they're overcommitted.

### 4. Status as a Common Question

The user asks "where is X" or "what's the status of Y":
> "People keep asking me where their PRs are in the review queue."

**Translation:** The workflow lacks visibility. A board provides it.

### 5. Fixed Completion Criteria

Each phase has a clear "done" condition:
> "It's in review until someone approves it, then it's done."

**Translation:** Lane transitions are unambiguous. Nobody argues about
whether something is "in review" or "in progress."

---

## Kanban-Inappropriate Signals

Do NOT include a kanban board when the interview reveals:

### 1. Emergent Session Shape

Each session looks different depending on context:
> "It really depends on what happened overnight. Sometimes I'm debugging,
> sometimes I'm building, sometimes I'm just researching."

**Translation:** The workflow is too context-dependent for lanes to be stable.

### 2. Single-Item Focus

The user works on one thing at a time to completion:
> "I pick one thing and don't stop until it's done."

**Translation:** There's nothing to limit or prioritize on a board. A
simple task list is more appropriate.

### 3. Exploratory / Creative Work

The process is discovery-driven:
> "I start researching something and see where it leads. I don't know
> what I'll find until I find it."

**Translation:** The phases are emergent. Forcing a kanban structure would
add friction, not clarity.

### 4. Reactive / Event-Driven

Work is driven by external events, not planned:
> "I respond to alerts, requests, and fires. I don't really plan my
> sessions."

**Translation:** Kanban boards assume some level of planned workflow.
Reactive work needs a ticketing system, not a board.

### 5. No Clear "Done"

The user can't describe what completion looks like for each phase:
> "I know I'm done when it feels right."

**Translation:** If transitions are subjective, lanes become ambiguous.
The board will need constant reinterpretation.

---

## Decision Flowchart

```
Interview reveals workflow structure:

Is there a clear A → B → C → D sequence?
├── YES → Can the user name each phase's entry and exit?
│   ├── YES → Does the user have multiple concurrent items?
│   │   ├── YES → KANBAN. High-value fit.
│   │   └── NO  → Is there a queue or hand-off between phases?
│   │       ├── YES → KANBAN. Still valuable for flow visibility.
│   │       └── NO  → Kanban adds marginal value. Check user interest.
│   └── NO  → Is the ambiguity in exit criteria only?
│       ├── YES → Kanban with softer lane boundaries. Defer to user.
│       └── NO  → Kanban inappropriate. Use phase skills only.
└── NO → Is the workflow reactive or event-driven?
    ├── YES → Kanban inappropriate. Use phase skills only.
    └── NO → Is the user interested in a board anyway?
        ├── YES → Generate lightweight kanban. Flag the limitation.
        └── NO  → Kanban inappropriate. Phase skills only.
```

---

## Implementation

When kanban is appropriate, the bundle includes a `kanban/` directory with
three files.

### Board setup (kanban/board-setup.sh)

An executable shell script that creates the board:

```bash
#!/usr/bin/env bash
set -euo pipefail

hermes kanban boards create my-workflow \
  --name "My Workflow" \
  --description "Generated by workflow-architect" \
  --switch
```

The user reviews and runs this. It does not create tasks — just the board
container.

### Task blueprints (kanban/task-blueprints.yaml)

Maps each workflow phase to a kanban task template. Phases are ordered
sequentially; each phase's task depends on the previous one:

```yaml
board_slug: my-workflow
archetype: build-review-deploy

blueprints:
  - phase: build
    title_template: "Build: {{feature}}"
    skill: my-workflow/build
    default_priority: 3
    initial_status: todo
    body: |
      # Build Phase
      Load skill: skill_view(name='my-workflow/build')
      Definition of done: code written, tests passing, local build succeeds.
      On completion: create a "Review" task with --parent pointing to this task.

  - phase: review
    title_template: "Review: {{feature}}"
    skill: my-workflow/review
    default_priority: 2
    initial_status: ready
    body: |
      # Review Phase
      Load skill: skill_view(name='my-workflow/review')
      Definition of done: review complete, changes approved or requested.
      On approval: create a "Deploy" task with --parent pointing to this task.

  - phase: deploy
    title_template: "Deploy: {{feature}}"
    skill: my-workflow/deploy
    default_priority: 1
    initial_status: ready
    body: |
      # Deploy Phase
      Load skill: skill_view(name='my-workflow/deploy')
      Definition of done: change is live and verified. Terminal phase.
```

The dependency chain works through Hermes Kanban's built-in parent/child
task relationship. When Build (no parent) is `done`, Review (parent=Build)
auto-promotes from `todo` to `ready`. The dispatcher picks it up on the
next tick.

### Lifecycle rules

| Phase | Initial status | Dependency | Auto-promotes when |
|-------|---------------|------------|-------------------|
| First | `todo` | None | User creates task manually |
| Middle | `todo` | Previous phase task | Previous phase is `done` |
| Last | `todo` | Previous phase task | Previous phase is `done` |

- **Concurrent items:** Users can create multiple first-phase tasks for
  parallel work items. Each spawns its own dependency chain.
- **Blocked tasks:** Any task can be manually moved to `blocked` status.
  The dispatcher respects this and won't spawn blocked tasks.
- **Priority:** First phase gets highest priority (3), last phase gets
  lowest (1). Tasks within a phase inherit the blueprint's default priority.
