Docs/Task Workflow

Task Workflow

Understanding the Clotion task lifecycle

Task Workflow

Clotion manages tasks through a state machine that mirrors your Notion workflow. Understanding this lifecycle helps you work effectively with automated development.

State Machine

PENDING → IN_PROGRESS ⟷ BLOCKED → FAILED
              ↓
         COMPLETED → IN_REVIEW → DONE

States

StateNotion StatusDescription
PENDINGTodoCard picked up, waiting to start
IN_PROGRESSIn ProgressClaude is actively working
BLOCKEDIn Progress + Blocked ✓Claude needs human input
COMPLETEDIn ProgressWork done, pushing code
IN_REVIEWIn ReviewPR created, awaiting review
DONEDoneMerged and cleaned up
FAILED(varies)Task failed (terminal)

Lifecycle Flow

1. Task Pickup (PENDING)

When you move a Notion card to "Todo":

  1. Poller detects the status change
  2. Clotion verifies it's a Todo status
  3. Task record created in SQLite
  4. Clotion ID assigned (CLO-001, etc.)
  5. Task enters PENDING state

2. Starting Work (IN_PROGRESS)

Clotion then:

  1. Creates a git worktree at .worktrees/{clotion-id}
  2. Creates branch clotion/{clotion-id}
  3. Updates Notion card:
    • Status → "In Progress"
    • Branch → branch name
    • Current Status → "Starting work..."
  4. Starts Claude Code session with the task prompt

3. Working

Claude Code:

  1. Analyzes the card title and description
  2. Explores the codebase
  3. Implements the solution
  4. Writes/updates tests
  5. Commits changes

During this phase, the Current Status property updates in real-time:

  • "Reading files..."
  • "Writing code..."
  • "Running tests..."

4. Blocked (BLOCKED)

If Claude encounters an issue:

  1. Outputs BLOCKED: [reason]
  2. Clotion detects the blocked state
  3. Updates Notion card:
    • Blocked checkbox → ✓
    • Current Status → reason
  4. Polls for new comments
  5. When you comment, Claude resumes

5. Completion (COMPLETED → IN_REVIEW)

When Claude outputs TASK_COMPLETE:

  1. Pushes branch to origin
  2. Creates PR via gh pr create
  3. Updates Notion card:
    • Status → "In Review"
    • PR URL → GitHub PR link
    • Current Status → "PR created"

6. Merging (DONE)

When you move the card to "Done":

  1. PR is merged (if not already)
  2. Worktree is cleaned up
  3. Branch is optionally deleted
  4. Task marked as DONE
  5. Current Status → "Completed"

Notion Properties Updated

PropertyWhen UpdatedExample Value
StatusState changes"In Progress"
BlockedWhen blocked/unblocked✓ / ✗
Current StatusContinuously"Running tests..."
Clotion IDOn pickup"CLO-042"
BranchOn worktree creation"clotion/CLO-042"
PR URLOn PR creation"https://github.com/..."

Timeouts

SituationDefaultConfiguration
Blocked timeout1 hourBLOCKED_TIMEOUT
Task stall detection5 minutesBuilt-in

Error Handling

If a task fails:

  • Error is logged
  • Notion card gets a comment with the error
  • Blocked checkbox is set
  • Current Status shows the error
  • Task enters FAILED state
  • Worktree is preserved for debugging

To retry a failed task:

  1. Fix the underlying issue
  2. Uncheck the Blocked checkbox
  3. Move the card back to "Backlog"
  4. Move it to "Todo" again