Skip to content

Add mix loop: autonomous AI-driven issue resolution - #38

Closed
KTSCode wants to merge 1 commit into
mainfrom
claude/eloquent-tesla-PfGBO
Closed

Add mix loop: autonomous AI-driven issue resolution#38
KTSCode wants to merge 1 commit into
mainfrom
claude/eloquent-tesla-PfGBO

Conversation

@KTSCode

@KTSCode KTSCode commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

Introduces mix loop, a new Mix task that autonomously resolves GitHub issues by driving a self-correcting AI loop. The task picks an open issue, classifies it as a feature or bug, repeatedly invokes the claude agent to implement/fix it, verifies each attempt with mix quality, and feeds failures back into subsequent attempts until the suite passes or the iteration budget is exhausted.

Key Changes

  • New task module (lib/mix/tasks/loop.ex): 619-line implementation with:

    • Issue fetching and classification (feature vs. bug based on labels)
    • Iterative prompt generation (initial + retry prompts with failure context)
    • Self-correcting loop: runs claude headless → mix quality → decision logic
    • Git workflow: branch creation, commit, push, PR opening, issue commenting
    • Comprehensive error handling with clear user feedback
  • Pure functions (unit-testable):

    • parse_issues/1, parse_issue/1: JSON decoding from gh CLI
    • classify_issue/1: label-based feature/bug detection
    • slugify/1, build_branch_name/2: branch naming conventions
    • pr_title/2, commit_message/2: conventional commit formatting
    • build_initial_prompt/3, build_retry_prompt/5: context-aware prompts
    • should_continue?/3: loop termination logic (done/retry/exhausted)
    • build_summary/4, extract_pr_url/1: result reporting
  • Test suite (test/mix/tasks/loop_test.exs): 302 lines covering all pure functions with 40+ test cases

  • Documentation:

    • Design spec (docs/specs/2026-06-08-feature-debug-loop-design.md)
    • README section under Development workflow
    • CHANGELOG entry

Notable Implementation Details

  • Non-destructive on failure: exhausted loops leave the branch in place for manual review rather than force-pushing or reverting
  • No auto-merge: opens a PR for human review (unlike mix todo)
  • Bounded execution: --max flag (default 5) prevents infinite loops
  • Tool validation: checks gh and claude are installed upfront
  • Failure context: retry prompts include the tail of mix quality output (last 40 lines by default) to guide the agent's fixes
  • Clean CLI: status messages to stderr, clean summary to stdout
  • Flexible issue selection: --issue N for specific issues, --label L to filter, or auto-pick the next open issue
  • Quick mode: --quick (default) for faster iteration; --full for comprehensive quality checks

Usage

mix loop                 # work the next open issue
mix loop --issue 42      # work a specific issue
mix loop --label bug     # only consider issues with this label
mix loop --max 8         # cap the loop at 8 attempts (default 5)
mix loop --full          # run the full `mix quality` each iteration

https://claude.ai/code/session_01FJ7GGnsNFWoyqr8KzDEyyp

Adds Mix.Tasks.Loop, a self-correcting loop that picks an open GitHub
issue, classifies it as a feature or bug from its labels, and repeatedly
drives `claude` headless to implement/fix it — verifying each attempt
with `mix quality` and feeding failures back into the next attempt until
the suite is green or the iteration budget is spent. On success it
commits, pushes, opens a PR closing the issue, and comments the outcome.

Inspired by the mix todo / mix bump prompt-emitting pattern, extended into
an autonomous cycle. Pure functions (issue parsing, classification, prompt
building, loop decision) are unit-tested; git/gh/claude shell wrappers
follow the project convention of manual testing.

https://claude.ai/code/session_01FJ7GGnsNFWoyqr8KzDEyyp
@KTSCode

KTSCode commented Jun 8, 2026

Copy link
Copy Markdown
Owner Author

Closing this. Severance isn't complex enough to justify an autonomous feature/debug loop — the manual mix todo flow covers our needs and keeps a human in the loop. Branch left in place for reference.

@KTSCode KTSCode closed this Jun 8, 2026
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