Skip to content

Conversation

@newhook
Copy link
Owner

@newhook newhook commented Jan 12, 2026

Summary

This PR introduces an automated end-to-end workflow mode for co work create that transforms a bead into a complete pull request without manual intervention.

Key Features

  • New --bead flag for co work create that triggers automated workflow mode
  • Auto-generated branch names from bead titles (e.g., "Add user authentication" → feat/add-user-authentication)
  • Transitive dependency collection - automatically includes all blocked_by dependencies
  • Epic support - when given an epic bead, processes all child beads
  • Automated review-fix loop - runs up to 5 iterations until code review passes
  • New co task set-review-epic command - links review tasks to their issue epics for accurate issue tracking

Changes

New Files:

  • cmd/work_automated.go - Complete automated workflow orchestration
  • cmd/work_automated_test.go - 35+ tests for branch name generation
  • internal/db/migrations/006_task_metadata.sql - Task metadata table
  • internal/db/task_metadata.go - Metadata operations (get/set/delete)
  • sql/queries/task_metadata.sql - SQLC query definitions

Modified Files:

  • cmd/work.go - Added --bead flag support
  • cmd/task.go - Added set-review-epic subcommand
  • internal/beads/client.go - Added GetTransitiveDependenciesInDir and GetBeadWithChildrenInDir
  • internal/beads/client_test.go - Integration tests for new functions
  • internal/db/schema.sql - Added task_metadata table
  • internal/db/sqlc/* - Regenerated SQLC code

Usage

# Traditional mode (unchanged)
co work create my-feature-branch

# New automated mode
co work create --bead ac-xyz

The automated workflow:

  1. Creates work unit with auto-generated branch name
  2. Collects bead and its dependencies/children
  3. Plans tasks using auto-grouping
  4. Executes all tasks
  5. Runs review-fix loop until clean (max 5 iterations)
  6. Creates PR

Technical Details

Review-Fix Loop Improvements:

  • Captures pre-review bead IDs to accurately detect new issues
  • Uses review_epic_id metadata to track which beads belong to a review
  • Falls back to new-bead detection if no epic is set

Task Metadata System:

  • Generic key-value store on tasks via task_metadata table
  • Primary use case: review_epic_id for review task tracking
  • Displayed in co task show output

Beads Resolved

  • ac-au3 (epic): Add automated bead-to-PR workflow mode to 'co work create'
  • ac-rba: Add --bead flag to co work create command
  • ac-qcz: Add helper functions for branch name generation and dependency collection
  • ac-ys9: Add transitive dependency collection to beads client
  • ac-2rz: Implement automated workflow orchestration
  • ac-7pu: Add database migrations for automated workflow
  • ac-8es: Implement automated review-fix loop

Test Plan

  • Unit tests for branch name generation (35+ test cases)
  • Unit tests for beads client functions
  • Integration tests for transitive dependency collection
  • Tests for automated workflow functions
  • go test ./... passes
  • Manual testing of automated workflow end-to-end

🤖 Generated with Claude Code

newhook and others added 4 commits January 11, 2026 19:41
This implements the --bead flag for co work create that automatically:
1. Generates branch name from bead title
2. Collects transitive dependencies (for beads with blocked_by relations)
3. Collects child beads (for epic beads with parent_of relations)
4. Plans tasks with auto-grouping
5. Executes all tasks
6. Runs review-fix loop until clean (max 5 iterations)
7. Creates a pull request

New features:
- cmd/work.go: Added --bead flag to work create command
- cmd/work_automated.go: New file with automated workflow orchestration
- internal/beads/client.go: Added GetTransitiveDependenciesInDir() and
  GetBeadWithChildrenInDir() for dependency collection

The traditional co work create <branch> flow remains unchanged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tion

- Add task_metadata table for storing key-value metadata on tasks
- Add co task set-review-epic command to associate review epic with review task
- Update planAndExecuteFixTasks to use review epic children instead of all ready beads
- Update checkForReviewIssues to check review epic first
- Add metadata display to co task show command

Fixes the race condition where unrelated ready beads could be incorrectly
processed during the review-fix loop. Now the workflow explicitly tracks
which epic was created by the review task.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 31 unit tests for generateBranchNameFromBead covering edge cases:
  uppercase, special chars, unicode, long titles, empty titles, etc.
- Add error handling tests for collectBeadsForAutomatedWorkflow
- Add tests for GetTransitiveDependenciesInDir and GetBeadWithChildrenInDir:
  non-existent beads, empty IDs, invalid directories
- Add integration tests for beads functions that verify correct behavior
  with real beads data when bd CLI is available

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed checkForReviewIssues fallback logic to capture bead IDs before
running review and only detect truly new beads, instead of matching any
bead containing 'Review:' or the work ID in its title.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@newhook newhook merged commit bf93797 into main Jan 12, 2026
newhook added a commit that referenced this pull request Jan 12, 2026
* Add automated bead-to-PR workflow mode to 'co work create'

This implements the --bead flag for co work create that automatically:
1. Generates branch name from bead title
2. Collects transitive dependencies (for beads with blocked_by relations)
3. Collects child beads (for epic beads with parent_of relations)
4. Plans tasks with auto-grouping
5. Executes all tasks
6. Runs review-fix loop until clean (max 5 iterations)
7. Creates a pull request

New features:
- cmd/work.go: Added --bead flag to work create command
- cmd/work_automated.go: New file with automated workflow orchestration
- internal/beads/client.go: Added GetTransitiveDependenciesInDir() and
  GetBeadWithChildrenInDir() for dependency collection

The traditional co work create <branch> flow remains unchanged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add co task set-review-epic command to fix review-fix loop race condition

- Add task_metadata table for storing key-value metadata on tasks
- Add co task set-review-epic command to associate review epic with review task
- Update planAndExecuteFixTasks to use review epic children instead of all ready beads
- Update checkForReviewIssues to check review epic first
- Add metadata display to co task show command

Fixes the race condition where unrelated ready beads could be incorrectly
processed during the review-fix loop. Now the workflow explicitly tracks
which epic was created by the review task.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add tests for automated workflow functions

- Add 31 unit tests for generateBranchNameFromBead covering edge cases:
  uppercase, special chars, unicode, long titles, empty titles, etc.
- Add error handling tests for collectBeadsForAutomatedWorkflow
- Add tests for GetTransitiveDependenciesInDir and GetBeadWithChildrenInDir:
  non-existent beads, empty IDs, invalid directories
- Add integration tests for beads functions that verify correct behavior
  with real beads data when bd CLI is available

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix review issue detection to track pre-review beads

Changed checkForReviewIssues fallback logic to capture bead IDs before
running review and only detect truly new beads, instead of matching any
bead containing 'Review:' or the work ID in its title.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@newhook newhook deleted the feat/ac-au3 branch January 16, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants