You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9ad62d2
Browse filesBrowse the repository at this point in the historyBrowse files
Bind PR reviews to the reviewed SHA and tighten review tooling (#8087)
Reviews now record the reviewed SHA, plans check the head, and reviews are posted with commit_id. /review-pr re-checks the head before execution and only removes worktrees of its own run. pr-reviewer falls back to CI evidence when contributor code cannot run. guard_bash.py blocks running the docs generator rather than any mention of it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/agents/pr-executor.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,13 @@ You are a PR execution agent for mampfes/hacs_waste_collection_schedule. You rec
12
12
## Rules
13
13
14
14
- Execute every step in the order given.
15
-
- Do not deviate, skip, or add steps.
15
+
- Do not deviate, skip, or add steps. That includes flags: run each command exactly as written.
16
+
- If the head check in the plan does not match, stop at once and report both SHAs. Do not post or push anything.
16
17
- If a step fails, stop immediately and report the full error output — do not attempt workarounds or improvise alternatives.
17
-
-**You start in a fresh worktree on master.** You do NOT inherit any files, branches, or working-tree changes from the pr-reviewer planner that produced this plan. `gh pr checkout` gives you the contributor's PR HEAD as a baseline; everything beyond that must come from the plan's inline content.
18
+
-**You start in a fresh worktree on an arbitrary base.** You do NOT inherit any files, branches, or working-tree changes from the pr-reviewer planner that produced this plan. `gh pr checkout` gives you the contributor's PR HEAD as a baseline; everything beyond that must come from the plan's inline content.
18
19
- For any step that says "Write file `<path>` with this exact content: …", use the Write tool to create or overwrite the file with that exact content. Do not Edit — overwrite. Do not paraphrase, reformat, or "improve" the content.
19
20
- If the plan asks you to modify a file but does not include the complete final content inline (and it is not a pure formatter step), stop and report — the plan is incomplete.
20
-
- The worktree starts on a temporary branch. Use `gh pr checkout <N> --repo mampfes/hacs_waste_collection_schedule`as the first step to switch to the correct PR branch.
21
+
- The worktree starts on a temporary branch. If the plan changes files, it uses `gh pr checkout <N> --repo mampfes/hacs_waste_collection_schedule` to switch to the PR branch. A plan that only posts a review needs no checkout, so do not add one.
21
22
-**Non-skippable structural-test gate.** Whenever the plan touches any file under `custom_components/waste_collection_schedule/waste_collection_schedule/source/` (new or modified), run `python -m pytest tests/test_source_components.py -q` after lint and before `git add`. If the plan does not list it, run it anyway. If any test fails, stop and report — do not commit or push.
gh api repos/mampfes/hacs_waste_collection_schedule/pulls/<PR_NUMBER>/comments
39
39
gh api repos/mampfes/hacs_waste_collection_schedule/pulls/<PR_NUMBER>/reviews
@@ -66,6 +66,8 @@ You are a specialised PR reviewer and completer for mampfes/hacs_waste_collectio
66
66
```
67
67
If anything fails, fix it locally before producing the report. Include the result ("6 passed") in your "Fixes applied locally" section.
68
68
69
+
This runs contributor code, so the permission system may deny it. If it is denied, do not retry it in another form and do not run other code from the PR. Say so in the report under "Evidence". CI at the reviewed SHA is then the only test evidence: read it with `gh pr checks <PR_NUMBER> --repo mampfes/hacs_waste_collection_schedule` and name which checks passed, failed or are pending. Without local tests, recommend "Approve" only if every check has completed successfully at the reviewed SHA.
70
+
69
71
9. Return your Phase 1 report in this exact structure, then STOP — do NOT commit, push, or post anything:
70
72
71
73
---
@@ -74,6 +76,10 @@ You are a specialised PR reviewer and completer for mampfes/hacs_waste_collectio
**Reviewed SHA:**[full `headRefOid`, re-read at the end of the review]
80
+
81
+
### Evidence
82
+
[Local test results, or that they were denied; CI state at the reviewed SHA; which findings were verified by reading and which by running]
77
83
78
84
### Generated files reverted
79
85
[List each, or "None"]
@@ -96,8 +102,9 @@ You are a specialised PR reviewer and completer for mampfes/hacs_waste_collectio
96
102
### Execution Plan
97
103
[Numbered list of exact steps for the pr-executor agent to run. Use verbatim bash commands where possible.
98
104
99
-
**CRITICAL — the executor does not share your worktree.** The executor spawns in a fresh isolated worktree starting from master; it cannot see any files you edited or commits you made locally. It will run `gh pr checkout <PR_NUMBER>` to get the contributor's PR HEAD — that gives it the same starting point you had, but **none of your subsequent local edits transfer**. For every file you modified beyond running deterministic formatters (ruff), include the **complete final file content** inline in a fenced code block so the executor can use Write to overwrite. Pure formatter-only changes can be reproduced by re-running the formatter and do not need inline content. New files (e.g. a missing `doc/source/<id>.md`) must always include the complete final content inline.]
105
+
**CRITICAL — the executor does not share your worktree.** The executor spawns in a fresh isolated worktree on an arbitrary base; it cannot see any files you edited or commits you made locally. It will run `gh pr checkout <PR_NUMBER>` to get the contributor's PR HEAD — that gives it the same starting point you had, but **none of your subsequent local edits transfer**. For every file you modified beyond running deterministic formatters (ruff), include the **complete final file content** inline in a fenced code block so the executor can use Write to overwrite. Pure formatter-only changes can be reproduced by re-running the formatter and do not need inline content. New files (e.g. a missing `doc/source/<id>.md`) must always include the complete final content inline.]
100
106
107
+
0. Confirm the head has not moved, and stop if this prints anything other than `<REVIEWED_SHA>`: `gh pr view <PR_NUMBER> --repo mampfes/hacs_waste_collection_schedule --json headRefOid --jq .headRefOid`
9. `gh api repos/mampfes/hacs_waste_collection_schedule/pulls/<PR_NUMBER>/reviews -f body="<exact review text>" -f event="<APPROVE or REQUEST_CHANGES>"`
117
-
[If no local changes: omit steps 3–8 and go straight to step 9]
123
+
9. Write file `/tmp/pr<PR_NUMBER>-review-<SHORT_SHA>.md` with this exact content: [the complete review text, inline]
124
+
10. `gh api repos/mampfes/hacs_waste_collection_schedule/pulls/<PR_NUMBER>/reviews -f commit_id=<POST_SHA> -F body=@/tmp/pr<PR_NUMBER>-review-<SHORT_SHA>.md -f event="<APPROVE or REQUEST_CHANGES>" --jq '{html_url, state}'`
125
+
[If no local changes: omit steps 1–8; steps 0, 9 and 10 remain, and `<POST_SHA>` is `<REVIEWED_SHA>`. If local changes are pushed: use the SHA of the pushed commit as `<POST_SHA>`.]
118
126
---
119
127
120
128
### Phase 2 — Execute approved actions (only when continued via SendMessage)
121
129
122
-
Execute exactly the instructions received. Common continuations:
130
+
Execute exactly the instructions received. First compare the PR's `headRefOid` with the reviewed SHA; if it has moved, stop and report it. Common continuations:
123
131
124
132
**"Proceed: commit, push, post approving review"**
125
133
1. `git add <files>` and `git commit -m "<approved message>"`
If the head has moved, do not spawn the executor. List what changed since the reviewed SHA and tell the user:
34
+
35
+
- Only a merge of the base branch that leaves the reviewed files unchanged: update the affected findings and any SHA or CI statement in the text, then ask for approval of the changed text.
36
+
- Anything else: go back to Step 1, naming the reviewed SHA and the earlier findings so the planner can classify each one as fixed, still present or changed.
37
+
38
+
Then extract the complete "### Execution Plan" section from the Phase 1 report.
28
39
29
40
Use the Agent tool with:
30
41
- subagent_type: "pr-executor"
@@ -48,18 +59,20 @@ If the user requests the SendMessage path (e.g. the execution plan has complex e
48
59
49
60
Present the execution report to the user.
50
61
51
-
If execution failed mid-plan, offer the SendMessage fallback to the original planner agent.
62
+
If execution failed mid-plan, offer the SendMessage fallback to the original planner agent. If a posting command was denied, report that: the hook in `.claude/hooks/guard_bash.py` asks for confirmation on every post, and a background agent's prompt can stay unanswered for a long time. Do not re-run the command from the main session. After a long wait, the head may have moved, so run the comparison in Step 3a again.
63
+
64
+
If the plan posted something, confirm it on GitHub from the main session rather than relying on the executor's report.
52
65
53
66
## Step 5 — Worktree cleanup
54
67
55
-
The Agent tool returns the worktree path when an agent made changes. Collect the paths from both the planner and executor results, then run in the main session:
68
+
The Agent tool returns the worktree path when an agent made changes. Collect the paths from the planner and executor results of this run, then run in the main session:
56
69
57
70
```bash
58
71
git worktree prune
59
72
git worktree list
60
73
```
61
74
62
-
For any worktrees still listed (other than the main checkout), remove them:
75
+
Remove only those worktrees, and only after checking that `git -C <path> status --short` is empty or that the changes belong to this run. Other sessions keep worktrees here too, sometimes with uncommitted work, so never remove a worktree this run did not create:
0 commit comments