|
| 1 | +# Plan: Implement TCR Workflow for `/task` |
| 2 | + |
| 3 | +## Objective |
| 4 | +Refactor the `task` command in `.gemini/commands/task.toml` to prioritize a strict Test-Commit-Revert (TCR) protocol for the 'Work' action, ensuring all development happens on feature branches with granular, verified commits. |
| 5 | + |
| 6 | +## Context & Requirements |
| 7 | +- **Strict Pre-requisites:** Clean working tree, on `main` branch, all tests pass (`make`). |
| 8 | +- **Isolation:** All work must occur on an auto-generated feature/bugfix branch. |
| 9 | +- **TCR Protocol:** |
| 10 | + - Break tasks into granular steps. |
| 11 | + - **Red:** Write a failing test and verify failure. |
| 12 | + - **Green:** Implement solution. |
| 13 | + - **Commit:** If tests pass, commit immediately. |
| 14 | + - **Revert:** If tests fail (after brief leeway), revert to the last green state. |
| 15 | +- **User Interaction:** Frequent checkpoints using `ask_user` after each step and before final merge. |
| 16 | +- **Finalization:** Full test run on branch before merging/rebasing to `main`. |
| 17 | + |
| 18 | +## Proposed Changes |
| 19 | + |
| 20 | +### 1. Refactor `.gemini/commands/task.toml` |
| 21 | +Update the `Action: Work` section of the prompt to explicitly define the TCR workflow phases: |
| 22 | + |
| 23 | +- **Phase 1: Pre-flight Verification** |
| 24 | + - Use `git status --porcelain` to ensure a clean tree. |
| 25 | + - Use `git branch --show-current` to ensure the branch is `main`. |
| 26 | + - Run `make` to establish a green baseline. |
| 27 | +- **Phase 2: Task Setup** |
| 28 | + - Update `TASKS.md` status. |
| 29 | + - Generate a kebab-case branch name from the task description. |
| 30 | + - Create and switch to the branch (`git checkout -b <branch-name>`). |
| 31 | +- **Phase 3: The TCR Loop** |
| 32 | + - Divide the task into small, testable increments. |
| 33 | + - For each increment: |
| 34 | + 1. Write a failing test. |
| 35 | + 2. Run tests to confirm failure. |
| 36 | + 3. Implement the minimal code to pass. |
| 37 | + 4. Run `make`. |
| 38 | + 5. If pass: `git add . && git commit -m "Step: <step-description>"`. |
| 39 | + 6. If fail: Attempt quick fix; if failure persists, `git checkout .` to revert. |
| 40 | + 7. Use `ask_user` to report status and confirm the next increment. |
| 41 | +- **Phase 4: Integration** |
| 42 | + - Run the full test suite one final time. |
| 43 | + - Use `ask_user` to request permission to merge/rebase. |
| 44 | + - Perform the merge/rebase to `main`, switch back to `main`, and clean up the feature branch. |
| 45 | + |
| 46 | +## Verification Strategy |
| 47 | +- **Logical Consistency:** Review the prompt to ensure instructions are unambiguous and cover all edge cases (e.g., failure during merge). |
| 48 | +- **Manual Walkthrough:** Simulate the workflow with a dummy task to verify the agent correctly identifies when to commit versus revert. |
| 49 | +- **Git State Audit:** Confirm that the final state results in a clean `main` branch with all tests passing. |
0 commit comments