Claude Code / OpenCode + T-Mux + Worktrees: This SELF-SPAWNING AI Coder TEAM is INSANITY!

AICodeKingAbout 4 min readJun 8, 2025Watch original
THE SUMMARYAI-generated

AI Coder Teams: Asynchronous Task Completion with Open Code

Key Concepts:

  • AI Coders (Claude Code, Open Code, Aider)
  • Task Claiming System
  • Git Worktrees
  • Tmux (Terminal Multiplexer)
  • Agent Spawner Workflow

1. Introduction

The video addresses the challenge of efficiently utilizing AI coders (like Claude Code, Open Code, and Aider) for complex projects. It proposes a system for creating a team of AI coders that can work asynchronously on different tasks, addressing the limitations of manually managing multiple AI coder instances.

2. The Problem with Manual AI Coder Management

  • Tedious and Inefficient: Manually assigning tasks to multiple AI coders and navigating between them is time-consuming.
  • Code Overwrites: Multiple AI coders working on the same project simultaneously can overwrite each other's code, leading to conflicts and errors.

3. Task Claiming System

The proposed solution involves a task claiming system based on a task file.

  • Task File: A markdown file containing a list of tasks to be accomplished.
  • Task Organization: Tasks are organized into sets of tasks and subtasks that can be accomplished simultaneously.
  • Task Fields: Each task entry includes:
    • Branch Name: The name of the existing branch to work on (if applicable).
    • Status: The current state of the task (e.g., "claimed," "intervention required").
    • Tmux Session Name: The name of the tmux session associated with the task.

4. Git Worktrees Explained

Git worktrees are used to create isolated working directories for each task.

  • Physical Copies: Git worktrees are physical copies of the entire repository or project.
  • Independent Execution: Worktrees can be run without switching branches.
  • Git Governance: Changes in worktrees are still governed by Git, allowing for merging back into the main repository.
  • Command Example: git worktree add -b <feature_name> work/<feature_name> creates a new worktree named <feature_name> in the work directory.

5. Tmux: Terminal Multiplexer

Tmux is a terminal multiplexer that enables the creation of multiple terminal sessions running in the background.

  • Session Management: Tmux allows users to create, detach from, and reattach to terminal sessions.
  • Background Processes: Long-running commands can be executed in tmux sessions without interrupting the main terminal.
  • Command Examples:
    • tmux new-session -s <session_name> creates a new tmux session named <session_name>.
    • Ctrl+b d detaches from the current tmux session.
    • tmux attach -t <session_name> attaches to an existing tmux session named <session_name>.

6. Agent Spawn Workflow

The core of the solution is an "agent spawn workflow" implemented as a Claude Code command.

  • Agent Spawner Role: The AI coder is instructed to act as an agent spawner and orchestrator.
  • Task File Reading: The agent spawner reads the tasks file to identify tasks that can be solved by one agent.
  • Task Assignment: The agent spawner assigns tasks to new agents based on dependencies (dependent tasks are assigned to the same agent, independent tasks to separate agents).
  • Workflow Steps: For each assigned task:
    1. Create Git Worktree: A new Git worktree is created for the task.
    2. Build Agent Prompt: A prompt is constructed for the AI coder agent.
    3. Create Tmux Session: A new tmux session is created and detached.
    4. Run Claude Code Instance: A Claude Code instance is launched within the tmux session with the generated prompt and allowed tools (edit, write, bash, replace).
    5. Update Task File: The tasks file is updated with the "claimed" status and any new information from the tmux sessions.

7. Implementation Example

  • Tasks File Example: The example tasks include creating a light theme and adding a filter to the options.
  • Workflow Execution: The agent spawn workflow is executed in Claude Code.
  • Automated Actions: The workflow automatically runs the git worktree and tmux commands.
  • Session Monitoring: Users can navigate to the tmux sessions to monitor progress or ask Claude Code for status updates.
  • Merging: The master Claude Code instance can be used to merge the completed worktrees back into the main repository.

8. Benefits and Advantages

  • Asynchronous Task Completion: AI coders work on tasks independently in the background.
  • Reduced Manual Intervention: The workflow automates task assignment, environment setup, and session management.
  • Improved Efficiency: Tasks are completed more quickly and efficiently compared to manual management.
  • Scalability: The system can be scaled to handle a large number of tasks and AI coder agents.

9. Conclusion

The video presents a practical and efficient workflow for creating a team of AI coders that can work asynchronously on different tasks. By leveraging Git worktrees and tmux, the system automates task assignment, environment setup, and session management, enabling users to complete complex projects more quickly and efficiently. The agent spawn workflow, implemented as a Claude Code command, provides a flexible and scalable solution for managing multiple AI coder instances.

AI summaries can miss context or contain errors. Check important details against the original video.

MAKE IT YOURS

Read. Remember. Reuse.

Free tools

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.