Skip to content

Commit c54129b

Browse files
committed
feat(task): implement strict TCR (Test-Commit-Revert) protocol for working on tasks
1 parent 4d9ad3f commit c54129b

2 files changed

Lines changed: 78 additions & 8 deletions

File tree

.gemini/commands/task.toml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,35 @@ Add a new task to `TASKS.md`.
1313
5. Ensure the task follows the existing formatting conventions and verify the file after the update.
1414
1515
### **Action: Work**
16-
Mark a task as 'In Progress' and assign user to it.
17-
1. Identify the target task from the arguments or context.
18-
2. Read `TASKS.md` and locate the corresponding entry.
19-
3. Update its status to `[/]` In Progress.
20-
4. Append the tag "(@!{{ git config user.email | cut -d'@' -f1 }})" to the task line.
21-
5. Ensure you don't overwrite existing assignments unless requested.
22-
6. If there is a plan for the task, use `ask_user` to confirm the next steps and start working on it.
23-
7. Otherwise, suggest user to invoke `/plan` command to create a plan before starting work.
16+
Implement a task using a strict Test-Commit-Revert (TCR) protocol on a feature branch.
17+
1. **Pre-flight Verification:**
18+
- Verify `git status --porcelain` is empty (clean tree).
19+
- Verify `git branch --show-current` is `main`.
20+
- Run `make test` and ensure all tests pass. If any fail, notify the user and stop.
21+
2. **Task Setup:**
22+
- Identify the target task from arguments or context.
23+
- Mark it as `[/] In Progress (@!{{ git config user.email | cut -d'@' -f1 }})` in `TASKS.md`.
24+
- Generate a descriptive kebab-case branch name (e.g., `feature/task-description`).
25+
- Create and switch to the branch: `git checkout -b <branch-name>`.
26+
3. **The TCR Loop:**
27+
- Break the task into granular, testable steps.
28+
- For each step:
29+
- **Red:** Write a failing test. Run `make test` to confirm it fails specifically for the new case.
30+
- **Green:** Implement the minimal code needed to pass the test.
31+
- **Verify:** Run `make test`.
32+
- **If Pass:** Run `git add . && git commit -m "Step: <description of changes>"`.
33+
- **If Fail:** Attempt one quick fix. If it still fails, run `git checkout .` to revert to the last green state.
34+
- **Check-in:** Use `ask_user` to report the step's result (Commit or Revert) and confirm the next step.
35+
4. **Integration & Finalization:**
36+
- Once all steps are complete, run a full `make test`.
37+
- Use `ask_user` to request permission to merge back to `main`.
38+
- If approved:
39+
- Switch to `main`: `git checkout main`.
40+
- Merge/Rebase the branch: `git merge <branch-name>`.
41+
- Run `make test` on `main`.
42+
- Delete the feature branch: `git branch -d <branch-name>`.
43+
- Update `TASKS.md` to reflect the current state (mark as `[x] Done` if complete).
44+
5. **Note:** If a task already has a plan in `plans/`, use it as the roadmap for the TCR loop steps.
2445
2546
### **Action: Report**
2647
Produce a strategic report of current tasks.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

Comments
 (0)