Techlead Loop

Autonomous feature delivery loop for the Tech Lead agent. Orchestrates all agents (frontend, backend, tester, reviewer) through t…

darshan-rambhia updated 1mo ago
Claude CodeGeneric
View source ↗
# /techlead-loop Command

Autonomous feature delivery loop for the Tech Lead agent. Orchestrates all agents (frontend, backend, tester, reviewer) through their complete lifecycle.

## Usage

```bash
/techlead-loop "Feature description" [--max-iterations <n>] [--completion-promise "<text>"]

Parameters

  • <feature-description> - Description of the feature to implement (required)
  • --max-iterations <n> - Maximum iterations before timeout (recommended: 50, prevents infinite loops)
  • --completion-promise "<text>" - Signal text to exit loop (default: "FEATURE_COMPLETE")

Example

/techlead-loop "Add email notifications when users make suggestions" --max-iterations 50 --completion-promise "FEATURE_COMPLETE"

How It Works

The Tech Lead agent runs in a self-referential loop:

  1. Iteration 1 (Analysis & Planning)

    • Tech Lead analyzes the feature request
    • Creates epic + implementation beads
    • Presents plan to user
    • Waits for user to say "approved"
    • Since "approved" not found, loop continues
  2. Iteration 2+ (Orchestration)

    • Tech Lead checks if user approved (looks for "approved" in conversation)
    • If approved: Invokes @frontend and @backend in parallel
    • Polls bead status every 30 seconds via bd show
    • When both report ready: Invokes @tester
    • Monitors tester progress
    • When tester reports ready: Invokes @reviewer
    • Monitors reviewer progress
    • If reviewer closes beads: Asks user "Ready to commit?"
    • If issues found: Identifies responsible agent, reassigns, re-invokes reviewer
    • Loop continues until completion promise is output
  3. Final Iteration (Completion)

    • Tech Lead outputs: <promise>FEATURE_COMPLETE</promise>
    • Stop hook detects this exact string
    • Loop exits
    • User can now see all completed work

Stop Hook

The system includes a stop hook that:

  • Checks for <promise>FEATURE_COMPLETE</promise> in output
  • If found: Allows normal exit (work is complete)
  • If not found: Re-feeds the entire prompt to Tech Lead
  • Enforces --max-iterations limit for safety

Agent Invocation Sequence

Iteration 1: Planning
  ├─ Analyze feature
  ├─ Create beads
  ├─ Present plan
  └─ Wait for approval

Iteration 2+: Orchestration (after "approved")
  ├─ Invoke @frontend and @backend (parallel)
  ├─ Poll both until ready (max 120 min)
  ├─ Invoke @tester
  ├─ Poll tester until ready (max 120 min)
  ├─ Invoke @reviewer
  ├─ Poll reviewer until beads closed (max 30 min)
  │  ├─ If issues found:
  │  │  ├─ Identify responsible agent
  │  │  ├─ Reassign bead
  │  │  ├─ Re-invoke @reviewer
  │  │  └─ Loop until all pass
  │  └─ If all pass: Ask user to commit
  ├─ After user says "commit": Commit changes
  └─ Output completion promise

Loop: Exits when <promise>FEATURE_COMPLETE</promise> found or max-iterations reached

Status Polling

Tech Lead polls bead status using:

bd show {bead-id}  # Check status field for: open, in_progress, ready, closed

Polling strategy:

  • Check status every 30 seconds
  • Timeout per phase: 120 minutes (frontend/backend), 120 minutes (tester), 30 minutes (reviewer)
  • If timeout occurs, notify user of stalled agent

Issue Resolution Loop

If reviewer finds issues:

Reviewer: bd comment {bead-id} --body "Issues found: ..."
  ↓
Tech Lead: Reads comments
  ↓
Tech Lead: Identifies responsible agent:
  - UI/components/pages → @frontend
  - Server actions/schemas/database → @backend
  - Tests/coverage → @tester
  ↓
Tech Lead: bd assign {bead-id} @{agent-name}
  ↓
Tech Lead: @{agent-name} - Issues found. See {bead-id} comments.
  ↓
Agent: Fixes issues → bd status ready
  ↓
Tech Lead: @reviewer review {bead-id}
  ↓
Reviewer: Validates → closes or reports new issues
  ↓
Loop: Repeat until all pass

Success Criteria

Loop exits successfully when Tech Lead outputs:

<promise>FEATURE_COMPLETE</promise>

This indicates:

  • ✓ All beads created
  • ✓ User approved plan
  • ✓ Frontend implemented and reported ready
  • ✓ Backend implemented and reported ready
  • ✓ Tester wrote tests and reported ready
  • ✓ Reviewer ran all quality gates and closed beads
  • ✓ User approved commit
  • ✓ Changes committed to git

Failure Scenarios

Loop exits with failure if:

  1. Max iterations reached - Feature took too long, likely stalled agent

    • Check which agent was last working
    • Manually invoke that agent to resume
  2. Agent timeout - Agent didn't report ready within time limit

    • Check bd show {bead-id} to see current status
    • Manually invoke agent if needed
  3. User interruption - User says "cancel" or "stop"

    • Tech Lead should exit gracefully
    • All beads remain in their current state
    • Can resume later by manually invoking agents

Example Session

User: /techlead-loop "Add email notifications" --max-iterations 50

Tech Lead (Iteration 1):
  Analyzing feature request...
  Creating beads...

  ## Plan: Email Notifications Feature

  ### Beads Created
  - vamsa-epic-123: Email notifications for suggestions
  - vamsa-frontend-124: UI for notification preferences
  - vamsa-backend-125: Email service + database model

  ### Acceptance Criteria
  - [ ] User receives email when suggestion created
  - [ ] User can disable notifications in settings
  - [ ] Professional email template with unsubscribe link

  Reply "approved" to proceed, or provide feedback.

User: approved

Tech Lead (Iteration 2+):
  Plan approved! Invoking agents...

  @frontend implement vamsa-frontend-124
  @backend implement vamsa-backend-125

  Waiting for implementations... checking status every 30 seconds.

Tech Lead (Iteration 3+):
  Frontend status: in_progress
  Backend status: in_progress

Tech Lead (Iteration 4+):
  Frontend status: ready ✓
  Backend status: ready ✓

  Both implementations complete! Invoking tester...

  @tester write tests for vamsa-epic-123

  Waiting for tests... checking status every 30 seconds.

Tech Lead (Iteration 5+):
  Test

Maintain Techlead Loop?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Techlead Loop on getagentictools](https://getagentictools.com/loops/darshan-rambhia-techlead-loop-command?ref=badge)
npx agentictools info loops/darshan-rambhia-techlead-loop-command

The second line is the CLI lookup for this page — handy in READMEs and docs.