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
Copy file name to clipboardExpand all lines: .claude/skills/fix-pr/SKILL.md
+30-73Lines changed: 30 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,80 +9,50 @@ Resolve PR review comments, fix CI failures, and address codecov coverage gaps f
9
9
10
10
## Step 1: Gather PR State
11
11
12
-
**IMPORTANT:** Do NOT use `gh api --jq` for extracting data — it uses a built-in jq that
13
-
chokes on response bodies containing backslashes (common in Copilot code suggestions).
14
-
Always pipe to `python3 -c` instead. (`gh pr view --jq` is fine — only `gh api --jq` is affected.)
12
+
Step 1 should be a single report-generation step. Use the shared scripted helper to produce one skill-readable PR context packet. Do not rebuild this logic inline with `gh api | python3 -c` unless you are debugging the helper itself.
HEAD_SHA=$(gh api repos/$REPO/pulls/$PR| python3 -c "import sys,json; print(json.load(sys.stdin)['head']['sha'])")
25
-
```
26
+
Use the values printed in that report for the rest of this skill. If you absolutely need raw structured data for a corner case, rerun the same command with `--format json`, but do not rebuild Step 1 manually.
26
27
27
28
### 1a. Fetch Review Comments
28
29
29
30
**Check ALL four sources.** User inline comments are the most commonly missed — do not skip any.
30
31
31
-
```bash
32
-
# 1. Inline review comments on code lines (from ALL reviewers: users AND Copilot)
33
-
gh api repos/$REPO/pulls/$PR/comments | python3 -c "
Present issue summary to user. **Also review all comments** — contributors and maintainers may have posted clarifications, corrections, additional context, or design decisions that refine or override parts of the original issue body. Incorporate relevant comment content when writing the plan.
52
+
Treat `ISSUE_JSON` as the source of truth for the deterministic preflight data:
53
+
-`title`, `body`, `labels`, and `comments` provide the issue summary and comment thread
54
+
-`kind`, `source_problem`, and `target_problem` provide parsed issue metadata
55
+
-`checks.good_label`, `checks.source_model`, and `checks.target_model` provide guard outcomes
56
+
-`existing_prs`, `resume_pr`, and `action` tell you whether to resume an open PR instead of creating a new one
57
+
58
+
Present the issue summary to the user. **Also review all comments** — contributors and maintainers may have posted clarifications, corrections, additional context, or design decisions that refine or override parts of the original issue body. Incorporate relevant comment content when writing the plan.
45
59
46
60
### 3. Verify Issue Has Passed check-issue
47
61
48
62
The issue must have already passed the `check-issue` quality gate (Stage 1 validation). Do NOT re-validate the issue here.
49
63
50
-
**Gate condition:** The issue must have the `Good` label (added by `check-issue` when all checks pass).
For `[Rule]` issues, parse the source and target problem names from the title (e.g., `[Rule] BinPacking to ILP` → source=BinPacking, target=ILP). Verify that **both** models already exist in the codebase on `main`:
70
+
For `[Rule]` issues, `ISSUE_JSON` already includes `source_problem`, `target_problem`, and the deterministic model-existence checks.
62
71
63
-
```bash
64
-
grep -r "struct SourceName" src/models/
65
-
grep -r "struct TargetName" src/models/
66
-
```
67
-
68
-
- If **both** models exist → continue to step 4.
69
-
- If either model is missing → **STOP**. Comment on the issue: "Blocked: model `<name>` does not exist in main yet. Please implement it first (or file a `[Model]` issue)."
72
+
- If both `checks.source_model` and `checks.target_model` are `pass` → continue to step 4.
73
+
- If either is `fail` → **STOP**. Comment on the issue: "Blocked: model `<name>` does not exist in main yet. Please implement it first (or file a `[Model]` issue)."
70
74
71
75
**One item per PR:** Do NOT implement a missing model as part of a `[Rule]` PR. Each PR should contain exactly one model or one rule, never both. This avoids bloated PRs and repeated implementation when the model is needed by multiple rules.
72
76
@@ -106,26 +110,23 @@ Include the concrete details from the issue (problem definition, reduction algor
106
110
107
111
### 6. Create PR (or Resume Existing)
108
112
109
-
**Check for existing PR first:**
110
-
```bash
111
-
EXISTING_PR=$(gh pr list --search "Fixes #<number>" --state open --json number,headRefName --jq '.[0].number // empty')
112
-
```
113
+
Use the `ISSUE_JSON.action` and `ISSUE_JSON.resume_pr` fields from Step 2.
113
114
114
-
**If a PR already exists** (`EXISTING_PR` is non-empty):
115
-
- Switch to its branch: `git checkout <headRefName>`
116
-
- Capture `PR=$EXISTING_PR`
115
+
**If an open PR already exists** (`action == "resume-pr"`):
116
+
- Switch to its branch: `git checkout <resume_pr.head_ref_name>`
117
+
- Capture `PR=<resume_pr.number>`
117
118
- Skip plan creation — jump directly to Step 7 (execute)
118
119
119
-
**If no existing PR** — create one with only the plan file:
120
-
121
-
**Pre-flight checks** (before creating the branch):
122
-
1. Verify clean working tree: `git status --porcelain` must be empty. If not, STOP and ask user to stash or commit.
123
-
2. Check if branch already exists: `git rev-parse --verify issue-<number>-<slug> 2>/dev/null`. If it exists, switch to it with `git checkout` (no `-b`) instead of creating a new one.
120
+
**If no open PR exists** (`action == "create-pr"`) — create one with only the plan file:
@@ -261,7 +274,7 @@ Run /review-pipeline to process Copilot comments, fix CI, and run agentic tests.
261
274
| Generic plan | Use specifics from the issue, mapped to add-model/add-rule steps |
262
275
| Skipping CLI registration in plan | add-model still requires alias/create/example-db planning, but not manual CLI dispatch-table edits |
263
276
| Not verifying facts from issue | Use WebSearch/WebFetch to cross-check claims |
264
-
| Branch already exists on retry |Check with `git rev-parse --verify` before`git checkout -b`|
265
-
| Dirty working tree |Verify `git status --porcelain` is empty before branching |
277
+
| Branch already exists on retry |Use `pipeline_worktree.py prepare-issue-branch` — it will reuse the existing branch instead of failing on`git checkout -b`|
278
+
| Dirty working tree |Use `pipeline_worktree.py prepare-issue-branch` — it stops before branching if the worktree is dirty|
266
279
| Bundling model + rule in one PR | Each PR must contain exactly one model or one rule — STOP and block if model is missing (Step 3.5) |
267
280
| Plan files left in PR | Delete plan files before final push (Step 7c) |
0 commit comments