feat: use git worktree for isolated development in solve-issue workflow

All roles (developer, reviewer, tester, committer) now work in
~/repos/workflow-worktrees/fix/<issue>-<slug> instead of modifying
the main working directory. Prevents self-destructive edits.

Fixes #464
This commit is contained in:
2026-05-24 10:22:25 +00:00
parent 38112053a0
commit b0e3f4a363
+27 -11
View File
@@ -38,19 +38,26 @@ roles:
capabilities: capabilities:
- coding - coding
procedure: | procedure: |
Before starting any work, ensure a clean worktree: IMPORTANT: Always work in a git worktree, NEVER modify the main working directory directly.
1. `git checkout main && git pull` to get the latest code
2. `git checkout -b fix/<issue-number>-<short-description>` to create a fresh branch Before starting any work, set up an isolated worktree:
- If bounced back from reviewer or tester, reuse the existing branch and rebase onto latest main: 1. `cd ~/repos/workflow && git fetch origin` to get latest refs
`git checkout main && git pull && git checkout <branch> && git rebase main` 2. First time (no existing branch):
- `git worktree add ~/repos/workflow-worktrees/fix/<issue-number>-<short-slug> -b fix/<issue-number>-<short-slug> origin/main`
- `cd ~/repos/workflow-worktrees/fix/<issue-number>-<short-slug> && bun install`
3. If bounced back from reviewer or tester (branch already exists):
- The worktree should already exist at `~/repos/workflow-worktrees/fix/<issue-number>-<short-slug>`
- `cd ~/repos/workflow-worktrees/fix/<issue-number>-<short-slug>`
- `git fetch origin && git rebase origin/main`
4. ALL subsequent work must happen inside the worktree directory.
Then implement TDD: Then implement TDD:
3. Read the test spec from CAS: `uwf cas get <plan hash>` (find the hash from the latest planner step's frontmatter.plan) 5. Read the test spec from CAS: `uwf cas get <plan hash>` (find the hash from the latest planner step's frontmatter.plan)
4. If bounced back from reviewer or tester: read the previous role's output to understand what needs fixing 6. If bounced back from reviewer or tester: read the previous role's output to understand what needs fixing
5. Write tests first based on the spec 7. Write tests first based on the spec
6. Implement the code to make tests pass 8. Implement the code to make tests pass
7. Ensure `bun run build` passes with no errors 9. Ensure `bun run build` passes with no errors
8. Run `bun test` to verify all tests pass 10. Run `bun test` to verify all tests pass
output: "List all files changed and provide a summary. Frontmatter must include: status (done or failed)." output: "List all files changed and provide a summary. Frontmatter must include: status (done or failed)."
frontmatter: frontmatter:
type: object type: object
@@ -66,6 +73,8 @@ roles:
- code-review - code-review
- static-analysis - static-analysis
procedure: | procedure: |
First, cd into the worktree: `cd ~/repos/workflow-worktrees/fix/<issue-number>-*` (find the exact directory)
Before reviewing, verify the git branch: Before reviewing, verify the git branch:
1. Run `git branch --show-current` — confirm the branch name references the issue number being worked on 1. Run `git branch --show-current` — confirm the branch name references the issue number being worked on
2. If the branch doesn't correspond to the issue, flag it in your output and reject 2. If the branch doesn't correspond to the issue, flag it in your output and reject
@@ -99,6 +108,8 @@ roles:
capabilities: capabilities:
- testing - testing
procedure: | procedure: |
First, cd into the worktree: `cd ~/repos/workflow-worktrees/fix/<issue-number>-*` (find the exact directory)
1. Run `bun test` for automated test verification 1. Run `bun test` for automated test verification
2. Read the test spec from CAS: `uwf cas get <plan hash>` (find the hash from the latest planner step's frontmatter.plan) 2. Read the test spec from CAS: `uwf cas get <plan hash>` (find the hash from the latest planner step's frontmatter.plan)
3. Verify each scenario in the spec is covered and passing 3. Verify each scenario in the spec is covered and passing
@@ -119,6 +130,8 @@ roles:
goal: "You are a committer agent. You create a clean commit and push a PR linking the original issue." goal: "You are a committer agent. You create a clean commit and push a PR linking the original issue."
capabilities: [] capabilities: []
procedure: | procedure: |
First, cd into the worktree: `cd ~/repos/workflow-worktrees/fix/<issue-number>-*` (find the exact directory)
Note: You inherit the developer's worktree and branch. Do NOT create a new branch. Note: You inherit the developer's worktree and branch. Do NOT create a new branch.
1. Stage all changes: `git add -A` 1. Stage all changes: `git add -A`
2. Commit with a descriptive message referencing the issue: `git commit -m "type: description\n\nFixes #N"` 2. Commit with a descriptive message referencing the issue: `git commit -m "type: description\n\nFixes #N"`
@@ -126,6 +139,9 @@ roles:
- If push hook fails: capture the error log in your output, mark hook_failed - If push hook fails: capture the error log in your output, mark hook_failed
4. On push success: create a PR via `tea pr create --title "..." --description "..."` 4. On push success: create a PR via `tea pr create --title "..." --description "..."`
- PR description must follow the project template: What / Why / Changes / Ref sections, with `Fixes #N` in Ref - PR description must follow the project template: What / Why / Changes / Ref sections, with `Fixes #N` in Ref
5. After PR creation, clean up the worktree:
- `cd ~/repos/workflow`
- `git worktree remove ~/repos/workflow-worktrees/fix/<issue-number>-<slug>`
output: "Include PR URL on success or error log on failure. Frontmatter must include: success (true or false)." output: "Include PR URL on success or error log on failure. Frontmatter must include: success (true or false)."
frontmatter: frontmatter:
type: object type: object