Skip to content

Commit a5fd530

Browse files
committed
Add PPL bugfix harness and /ppl-bugfix slash command
- ppl-bugfix-harness.md: systematic bugfix SOP distilled from 15+ historical commits, covering triage, TDD-style fix paths (A-E by bug layer), test templates (UT/IT/YAML), verification, PR creation, decision log, and post-PR follow-up - .claude/commands/ppl-bugfix.md: slash command that auto-resolves issue↔PR, dispatches subagent with worktree isolation and scoped permissions, handles both initial fix and follow-up flows - CLAUDE.md: reference to /ppl-bugfix as the entry point for PPL bugs - .gitignore: allow .claude/commands/ and settings.json to be tracked Signed-off-by: Heng Qian <qianheng@amazon.com>
1 parent a72e462 commit a5fd530

4 files changed

Lines changed: 502 additions & 1 deletion

File tree

.claude/commands/ppl-bugfix.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
allowed-tools: Agent, Read, Bash(gh:*), Bash(git:*)
3+
description: Run the PPL bugfix harness for a GitHub issue or follow up on an existing PR
4+
---
5+
6+
Fix a PPL bug or follow up on an existing PR using the harness in `ppl-bugfix-harness.md`.
7+
8+
## Input
9+
10+
- `/ppl-bugfix #1234` or `/ppl-bugfix 1234` — issue number
11+
- `/ppl-bugfix PR#5678` or `/ppl-bugfix pr 5678` — PR number
12+
- `/ppl-bugfix https://github.com/opensearch-project/sql/issues/1234` — URL
13+
14+
If no argument given, ask for an issue or PR number.
15+
16+
## Step 1: Resolve Issue ↔ PR
17+
18+
```bash
19+
# Issue → PR
20+
gh pr list --search "Resolves #<issue_number>" --json number,url,state --limit 5
21+
22+
# PR → Issue
23+
gh pr view <pr_number> --json body | jq -r '.body' | grep -oP 'Resolves #\K[0-9]+'
24+
```
25+
26+
| State | Action |
27+
|-------|--------|
28+
| Issue exists, no PR | **Initial Fix** (Step 2A) |
29+
| Issue exists, open PR found | **Follow-up** (Step 2B) |
30+
| PR provided directly | **Follow-up** (Step 2B) |
31+
32+
## Step 2A: Initial Fix
33+
34+
1. `gh issue view <issue_number>`
35+
2. `Read ppl-bugfix-harness.md`
36+
3. Dispatch subagent:
37+
38+
```
39+
Agent(
40+
mode: "acceptEdits",
41+
isolation: "worktree",
42+
name: "bugfix-<issue_number>",
43+
description: "PPL bugfix #<issue_number>",
44+
prompt: "<FULL harness content> + <issue details>
45+
Follow Phase 0 through Phase 3 in order.
46+
Phase 0.3 defines TDD execution flow. Do NOT skip any phase.
47+
Post the Decision Log (Phase 3.4) before completing."
48+
)
49+
```
50+
51+
The `isolation: "worktree"` creates a temporary git worktree branched from the current HEAD. The agent works in a clean, isolated copy of the repo — no interference with the user's working directory. If the agent makes changes, the worktree path and branch are returned in the result.
52+
53+
4. Report back: classification, fix summary, PR URL, **worktree branch name**, items needing human attention.
54+
55+
## Step 2B: Follow-up
56+
57+
1. Load PR state:
58+
```bash
59+
gh pr view <pr_number> --json title,body,state,reviews,comments,statusCheckRollup,mergeable
60+
gh pr checks <pr_number>
61+
```
62+
63+
2. Categorize:
64+
65+
| Signal | Type |
66+
|--------|------|
67+
| `statusCheckRollup` has failures | CI failure |
68+
| `reviews` has CHANGES_REQUESTED | Review feedback |
69+
| `mergeable` is CONFLICTING | Merge conflict |
70+
| All pass + approved | Ready — run `gh pr ready` |
71+
72+
3. `Read ppl-bugfix-harness.md`
73+
4. Dispatch follow-up subagent:
74+
75+
```
76+
Agent(
77+
mode: "acceptEdits",
78+
isolation: "worktree",
79+
name: "bugfix-<issue_number>-followup",
80+
description: "PPL bugfix #<issue_number> followup",
81+
prompt: "<Phase 3.5 content from harness>
82+
PR: <pr_number> (<pr_url>), Issue: #<issue_number>
83+
Follow-up type: <CI failure / review feedback / merge conflict>
84+
Read the Decision Log PR comment FIRST before making any changes.
85+
Checkout the PR branch before starting: git checkout <pr_branch>"
86+
)
87+
```
88+
89+
5. Report back: what was addressed, current PR state, whether another round is needed.
90+
91+
## Subagent Lifecycle
92+
93+
Subagents are task-scoped. They complete and release context — they cannot poll for events.
94+
95+
```
96+
Agent A (Phase 0-3) → creates PR → completes
97+
(CI runs, reviewers comment, conflicts arise)
98+
Agent B (Phase 3.5) → handles feedback → completes
99+
(repeat as needed)
100+
Agent N (Phase 3.5) → gh pr ready → done
101+
```
102+
103+
Context is preserved across agents via:
104+
- **Decision Log** (PR comment) — single source of truth for rejected alternatives, pitfalls, design rationale
105+
- **GitHub state** (PR diff, review comments, CI logs) — reconstructed by each follow-up agent
106+
107+
## Rules
108+
109+
- Always inline harness content in the subagent prompt — subagents cannot read skill files
110+
- If bug is not reproducible (Phase 0.1), stop and report — do not proceed
111+
- Issue ↔ PR auto-resolution means the user never needs to track PR numbers manually

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ http-client.env.json
5353
.factorypath
5454

5555
# Coding agent files (could be symlinks)
56-
.claude
56+
.claude/*
57+
!.claude/settings.json
58+
!.claude/commands/
59+
.claude/settings.local.json
5760
.clinerules
5861
memory-bank

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ plugin (OpenSearch plugin entry point, Guice DI wiring)
123123
- **PhysicalPlan** implements `Iterator<ExprValue>` for streaming execution
124124
- **Guice** dependency injection in `OpenSearchPluginModule`
125125

126+
## Fixing PPL Bugs
127+
128+
Use the `/ppl-bugfix #<issue_number>` slash command to fix PPL bugs. It dispatches a subagent with scoped permissions that follows all phases in `ppl-bugfix-harness.md` — from Phase 0 (Triage & Classification) through Phase 4 (Retrospective & Improvement). The full harness content is inlined into the subagent prompt to guarantee compliance. If a user asks to fix a PPL bug without using the slash command, remind them to use `/ppl-bugfix` or invoke it on their behalf.
129+
126130
## Adding New PPL Commands
127131

128132
Follow the checklist in `docs/dev/ppl-commands.md`:

0 commit comments

Comments
 (0)