|
| 1 | +# Plan: Integrate `coder` Subagent into `/task work` Workflow |
| 2 | + |
| 3 | +This plan outlines the steps to create a specialized `coder` subagent and refactor the `/task` command to delegate granular implementation tasks to it, following a strict Red-Green-Verify (TCR) protocol. |
| 4 | + |
| 5 | +## Objective |
| 6 | +Enhance the `/task work` workflow by introducing a `coder` subagent responsible for the "grunt work" of test-driven development. This separation of concerns allows the primary project manager (PM) agent to focus on high-level orchestration (branching, task tracking, integration) while the `coder` ensures rigorous implementation through a "test-first" mantra. |
| 7 | + |
| 8 | +## Architectural Impact |
| 9 | +- **Agentic Specialization:** Introduces a new `local` agent (`coder`) with full access to file modification and shell tools. |
| 10 | +- **Workflow Orchestration:** Refactors the `/task` command to act as an orchestrator that delegates implementation steps to the `coder` subagent. |
| 11 | +- **TCR Enforcement:** The `coder` agent is explicitly instructed to follow the Red-Green-Verify loop, ensuring all code is backed by tests and remains simple and maintainable. |
| 12 | + |
| 13 | +## File Operations |
| 14 | + |
| 15 | +### Create |
| 16 | +1. **.gemini/agents/coder.md**: Definition and instructions for the new `coder` subagent. |
| 17 | +2. **tests/test_task_command.py**: Integration tests to verify the `coder` subagent's role in the `/task` workflow. |
| 18 | + |
| 19 | +### Modify |
| 20 | +1. **.gemini/commands/task.toml**: Update the `work` action to delegate implementation steps to the `coder`. |
| 21 | +2. **docs/user-guide.md**: Update the documentation to reflect the new agentic delegation in the `/task work` workflow. |
| 22 | + |
| 23 | +## Step-by-Step Execution |
| 24 | + |
| 25 | +### Step 1: Create the `coder` Subagent |
| 26 | +Create `.gemini/agents/coder.md` with the following configuration: |
| 27 | +- **Role:** Expert "grunt coder" specialized in granular, test-driven changes. |
| 28 | +- **Mantra:** Red (Write failing test) -> Green (Implement minimal code) -> Verify (Run tests). |
| 29 | +- **Style:** Simple, non-clever code, no premature optimization, PEP 257-compliant docstrings. |
| 30 | +- **Tools:** `list_directory`, `read_file`, `grep_search`, `glob`, `write_file`, `replace`, `run_shell_command`. |
| 31 | +- **Instruction:** Explicitly mandate that the agent must run tests before and after implementation and report success/failure back to the orchestrator. |
| 32 | + |
| 33 | +### Step 2: Refactor the `/task` Command |
| 34 | +Modify `.gemini/commands/task.toml` to update the `Work` action: |
| 35 | +- **Delegation:** Change Phase 3 ("The TCR Loop") to instruct the orchestrator to: |
| 36 | + 1. Break the task into granular steps. |
| 37 | + 2. For each step, invoke the `coder` subagent. |
| 38 | + 3. Based on the `coder`'s report, perform the corresponding Git operation (`git commit` on success, `git checkout .` on failure). |
| 39 | +- **Control:** Ensure the orchestrator retains control over branching, merging, and user check-ins. |
| 40 | + |
| 41 | +### Step 3: Update User Documentation |
| 42 | +Modify `docs/user-guide.md`: |
| 43 | +- Locate the `/task` and "Full Feature Development Walkthrough" sections. |
| 44 | +- Update the description of the Red-Green-Verify loop to mention that implementation is handled by the specialized `coder` subagent. |
| 45 | + |
| 46 | +### Step 4: Implement Validation Tests |
| 47 | +Create `tests/test_task_command.py`: |
| 48 | +- **Structure Test:** Verify `.gemini/agents/coder.md` exists and follows the framework's agent structure. |
| 49 | +- **Integration Test:** Verify that `.gemini/commands/task.toml` contains a reference to the `coder` agent within its `prompt`. |
| 50 | +- **Consistency Test:** Ensure the `coder` agent's toolset includes all required tools (`write_file`, `replace`, `run_shell_command`). |
| 51 | + |
| 52 | +## Testing Strategy |
| 53 | + |
| 54 | +### Automated Tests |
| 55 | +- **Structural Integrity:** Run `pytest tests/test_structure.py` to ensure the new files match the framework's expectations. |
| 56 | +- **Command/Agent Sync:** Run `pytest tests/test_sync.py` to ensure the new/updated commands are correctly documented in the README and User Guide. |
| 57 | +- **Delegation Logic:** Run the newly created `pytest tests/test_task_command.py`. |
| 58 | + |
| 59 | +### Manual Verification |
| 60 | +- **Prompt Review:** Read the final `task.toml` prompt to ensure the delegation instructions are clear and the PM's role in the TCR loop (pre-flight, isolation, integration) is correctly defined. |
| 61 | +- **Agent Instruction Review:** Read `coder.md` to ensure the Red-Green-Verify mantra is the central focus of the agent's behavior. |
0 commit comments