slash-do 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/do/better.md +58 -32
- package/lib/code-review-checklist.md +5 -0
- package/package.json +1 -1
package/commands/do/better.md
CHANGED
|
@@ -59,6 +59,7 @@ When compacting during this workflow, always preserve:
|
|
|
59
59
|
- `BUILD_CMD`, `TEST_CMD`, `PROJECT_TYPE`, `WORKTREE_DIR` values
|
|
60
60
|
- `VCS_HOST`, `CLI_TOOL`, `DEFAULT_BRANCH`, `CURRENT_BRANCH`
|
|
61
61
|
|
|
62
|
+
|
|
62
63
|
## Phase 0: Discovery & Setup
|
|
63
64
|
|
|
64
65
|
Detect the project environment before any scanning or remediation.
|
|
@@ -98,15 +99,6 @@ Record as `BUILD_CMD` and `TEST_CMD`.
|
|
|
98
99
|
- Check for `.changelog/` directory → `HAS_CHANGELOG`
|
|
99
100
|
- Check for existing `../better-*` worktrees: `git worktree list`. If found, inform the user and ask whether to resume (use existing worktree) or clean up (remove it and start fresh)
|
|
100
101
|
|
|
101
|
-
### 0e: Browser Authentication (GitHub only)
|
|
102
|
-
If `VCS_HOST` is `github`, proactively verify browser authentication for the Copilot review loop later:
|
|
103
|
-
1. Navigate to the repo URL using `browser_navigate` via Playwright MCP
|
|
104
|
-
2. Take a snapshot and check for user avatar/menu indicating logged-in state
|
|
105
|
-
3. If NOT logged in: navigate to `https://github.com/login`, inform the user **"Please log in to GitHub in the browser. I'll wait for you to complete authentication."**, and use `AskUserQuestion` to wait for the user to confirm they've logged in
|
|
106
|
-
4. Do NOT close the browser — it stays open for the entire session
|
|
107
|
-
5. Record `BROWSER_AUTHENTICATED = true` once confirmed
|
|
108
|
-
|
|
109
|
-
This ensures the browser is ready before we need it in Phase 6, avoiding interruptions mid-flow.
|
|
110
102
|
|
|
111
103
|
<audit_instructions>
|
|
112
104
|
|
|
@@ -329,6 +321,34 @@ After all agents complete:
|
|
|
329
321
|
4. Shut down all agents via `SendMessage` with `type: "shutdown_request"`
|
|
330
322
|
5. Clean up team via `TeamDelete`
|
|
331
323
|
|
|
324
|
+
## Phase 4b: Internal Code Review
|
|
325
|
+
|
|
326
|
+
Before creating PRs, run a deep code review on all remediation changes to catch issues that automated agents may have introduced.
|
|
327
|
+
|
|
328
|
+
1. Generate the diff of all changes in the worktree:
|
|
329
|
+
```bash
|
|
330
|
+
cd {WORKTREE_DIR} && git diff {DEFAULT_BRANCH}...HEAD
|
|
331
|
+
```
|
|
332
|
+
2. Review the diff against the code review checklist:
|
|
333
|
+
```
|
|
334
|
+
!`cat ~/.claude/lib/code-review-checklist.md`
|
|
335
|
+
```
|
|
336
|
+
3. For each issue found:
|
|
337
|
+
- Fix in a new commit: `fix: {description of review finding}`
|
|
338
|
+
- Re-run `{BUILD_CMD}` and `{TEST_CMD}` to verify
|
|
339
|
+
4. Present a summary of review findings and fixes to the user via `AskUserQuestion`:
|
|
340
|
+
```
|
|
341
|
+
AskUserQuestion([{
|
|
342
|
+
question: "Code review complete. {N} issues found and fixed. {list}. Proceed to PR creation?",
|
|
343
|
+
options: [
|
|
344
|
+
{ label: "Proceed", description: "Create per-category PRs" },
|
|
345
|
+
{ label: "Show diff", description: "Show the full diff for manual review before proceeding" },
|
|
346
|
+
{ label: "Abort", description: "Stop here — I'll review manually" }
|
|
347
|
+
]
|
|
348
|
+
}])
|
|
349
|
+
```
|
|
350
|
+
5. If "Show diff" selected, print the diff and re-ask. If "Abort", stop and print the worktree path.
|
|
351
|
+
|
|
332
352
|
## Phase 5: Per-Category PR Creation
|
|
333
353
|
|
|
334
354
|
Instead of one mega PR, create **separate branches and PRs for each category**. This enables independent review, targeted CI, and granular merge decisions.
|
|
@@ -459,34 +479,17 @@ Maximum 5 iterations per PR to prevent infinite loops.
|
|
|
459
479
|
|
|
460
480
|
**Sub-agent delegation** (prevents context exhaustion): delegate each PR's review loop to a **separate general-purpose sub-agent** via the Agent tool. Launch sub-agents in parallel (one per PR). Each sub-agent runs the full loop (request → wait → check → fix → re-request) autonomously and returns only the final status.
|
|
461
481
|
|
|
462
|
-
### 6.
|
|
463
|
-
|
|
464
|
-
If `BROWSER_AUTHENTICATED` is not true (e.g., Phase 0e was skipped or failed):
|
|
465
|
-
1. Navigate to the first PR URL using `browser_navigate`
|
|
466
|
-
2. Check for user avatar/menu
|
|
467
|
-
3. If not logged in: navigate to `https://github.com/login`, inform the user **"Please log in to GitHub in the browser. I'll wait for you to confirm."**, and use `AskUserQuestion` to wait
|
|
468
|
-
|
|
469
|
-
### 6.1: Determine review request method
|
|
470
|
-
|
|
471
|
-
**Try the API first** on any one PR:
|
|
472
|
-
```bash
|
|
473
|
-
gh api repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/requested_reviewers \
|
|
474
|
-
-f 'reviewers[]=copilot-pull-request-reviewer[bot]'
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
If this returns 422 ("not a collaborator"), record `REVIEW_METHOD=playwright`. Otherwise record `REVIEW_METHOD=api`.
|
|
478
|
-
|
|
479
|
-
### 6.2: Launch parallel sub-agents (one per PR)
|
|
482
|
+
### 6.1: Launch parallel sub-agents (one per PR)
|
|
480
483
|
|
|
481
484
|
For each PR, spawn a general-purpose sub-agent using the shared review loop template:
|
|
482
485
|
|
|
483
486
|
!`cat ~/.claude/lib/copilot-review-loop.md`
|
|
484
487
|
|
|
485
|
-
Pass each sub-agent the PR-specific variables: `{PR_NUMBER}`, `{OWNER}/{REPO}`, `better/{CATEGORY_SLUG}`,
|
|
488
|
+
Pass each sub-agent the PR-specific variables: `{PR_NUMBER}`, `{OWNER}/{REPO}`, `better/{CATEGORY_SLUG}`, and `{BUILD_CMD}`.
|
|
486
489
|
|
|
487
490
|
Launch all PR sub-agents in parallel. Wait for all to complete.
|
|
488
491
|
|
|
489
|
-
### 6.
|
|
492
|
+
### 6.2: Handle sub-agent results
|
|
490
493
|
|
|
491
494
|
For each sub-agent result:
|
|
492
495
|
- **clean**: mark PR as ready to merge
|
|
@@ -494,9 +497,28 @@ For each sub-agent result:
|
|
|
494
497
|
- **max-iterations-reached**: inform the user "Reached max review iterations (5) on PR #{number}. Remaining issues may need manual review."
|
|
495
498
|
- **error**: inform the user and ask whether to retry or skip
|
|
496
499
|
|
|
500
|
+
### 6.3: Merge Gate (MANDATORY)
|
|
501
|
+
|
|
502
|
+
**Do NOT merge any PR until Copilot review has completed (approved or commented) on ALL PRs, or the user explicitly approves skipping.**
|
|
503
|
+
|
|
504
|
+
Present the review status summary to the user via `AskUserQuestion`:
|
|
505
|
+
```
|
|
506
|
+
AskUserQuestion([{
|
|
507
|
+
question: "Copilot review status:\n{for each PR: #number - status (approved/comments/pending/timeout)}\n\nHow would you like to proceed?",
|
|
508
|
+
options: [
|
|
509
|
+
{ label: "Merge approved PRs", description: "Merge only PRs with passing review" },
|
|
510
|
+
{ label: "Merge all", description: "Merge all PRs regardless of review status" },
|
|
511
|
+
{ label: "Wait", description: "Wait longer for pending reviews" },
|
|
512
|
+
{ label: "Don't merge", description: "Leave PRs open for manual review" }
|
|
513
|
+
]
|
|
514
|
+
}])
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Only proceed with merging based on the user's selection. Never auto-merge without user confirmation.
|
|
518
|
+
|
|
497
519
|
### 6.4: Merge
|
|
498
520
|
|
|
499
|
-
For each PR
|
|
521
|
+
For each PR approved for merge (in dependency order if applicable):
|
|
500
522
|
```bash
|
|
501
523
|
gh pr merge {PR_NUMBER} --merge
|
|
502
524
|
```
|
|
@@ -524,11 +546,16 @@ If merge fails (e.g., branch protection, merge conflicts from a prior PR):
|
|
|
524
546
|
```bash
|
|
525
547
|
git worktree remove {WORKTREE_DIR}
|
|
526
548
|
```
|
|
527
|
-
2. Delete local branches (only if merged):
|
|
549
|
+
2. Delete local AND remote branches (only if merged):
|
|
528
550
|
```bash
|
|
529
551
|
git branch -d better/{DATE}
|
|
530
552
|
git branch -d better/security better/code-quality better/dry better/arch-bugs better/stack-specific
|
|
531
553
|
```
|
|
554
|
+
```bash
|
|
555
|
+
git push origin --delete better/{DATE}
|
|
556
|
+
git push origin --delete better/security better/code-quality better/dry better/arch-bugs better/stack-specific
|
|
557
|
+
```
|
|
558
|
+
Ignore errors from `--delete` if a branch doesn't exist remotely.
|
|
532
559
|
3. Restore stashed changes (if stashed in Phase 3a):
|
|
533
560
|
```bash
|
|
534
561
|
git stash pop
|
|
@@ -563,7 +590,6 @@ If merge fails (e.g., branch protection, merge conflicts from a prior PR):
|
|
|
563
590
|
- **Copilot review loop exceeds 5 iterations per PR**: stop iterating on that PR, inform user, proceed to merge
|
|
564
591
|
- **Existing worktree found at startup**: ask user — resume (reuse worktree) or cleanup (remove and start fresh)
|
|
565
592
|
- **No findings above LOW**: skip Phases 3-7, print "No actionable findings" with the LOW summary
|
|
566
|
-
- **Browser not authenticated**: use `AskUserQuestion` to ask the user to log in — never skip this or close the browser
|
|
567
593
|
- **Merge conflict after prior PR merged**: rebase the branch onto the updated default branch, push with `--force-with-lease`, re-run CI
|
|
568
594
|
|
|
569
595
|
!`cat ~/.claude/lib/graphql-escaping.md`
|
|
@@ -142,6 +142,11 @@
|
|
|
142
142
|
- Tracking/checkpoint files that default to empty on parse failure — causes full re-execution. Fail loudly instead
|
|
143
143
|
- Registering references to resources without verifying the resource exists — dangling references after failed operations
|
|
144
144
|
|
|
145
|
+
**Automated pipeline discipline**
|
|
146
|
+
- Internal code review must run on all automated remediation changes BEFORE creating PRs — never go straight from "tests pass" to PR creation
|
|
147
|
+
- Copilot review must complete (approved or commented) on all PRs before merging — never merge while reviews are still pending unless the user explicitly approves
|
|
148
|
+
- Automated agents may introduce subtle issues that pass tests but violate project conventions — review agent output against CLAUDE.md conventions
|
|
149
|
+
|
|
145
150
|
**AI-generated code quality** _(Claude 4.6 specific failure modes)_
|
|
146
151
|
- Over-engineering: new abstractions, wrapper functions, helper files, or utility modules that serve only one call site — inline the logic instead
|
|
147
152
|
- Feature flags, configuration options, or extension points with only one possible value or consumer
|
package/package.json
CHANGED