@ai-support-agent/cli 0.1.32 → 0.1.33-beta.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/dist/alert-processor.d.ts +0 -8
- package/dist/alert-processor.d.ts.map +1 -1
- package/dist/alert-processor.js +5 -73
- package/dist/alert-processor.js.map +1 -1
- package/dist/api-client.d.ts +0 -4
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +0 -4
- package/dist/api-client.js.map +1 -1
- package/dist/commands/claude-code-args.d.ts +1 -0
- package/dist/commands/claude-code-args.d.ts.map +1 -1
- package/dist/commands/claude-code-args.js +3 -0
- package/dist/commands/claude-code-args.js.map +1 -1
- package/dist/commands/claude-code-runner.d.ts.map +1 -1
- package/dist/commands/claude-code-runner.js +2 -1
- package/dist/commands/claude-code-runner.js.map +1 -1
- package/dist/commands/plugin-dir.d.ts +20 -0
- package/dist/commands/plugin-dir.d.ts.map +1 -0
- package/dist/commands/plugin-dir.js +71 -0
- package/dist/commands/plugin-dir.js.map +1 -0
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -1
- package/dist/constants.js.map +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +9 -0
- package/dist/plugin/LICENSE +26 -0
- package/dist/plugin/README.md +86 -0
- package/dist/plugin/SYNC.md +113 -0
- package/dist/plugin/agents/build-error-resolver.md +159 -0
- package/dist/plugin/agents/code-reviewer.md +277 -0
- package/dist/plugin/agents/django-reviewer.md +159 -0
- package/dist/plugin/agents/infra-reviewer.md +172 -0
- package/dist/plugin/agents/investigator.md +75 -0
- package/dist/plugin/agents/nextjs-reviewer.md +191 -0
- package/dist/plugin/agents/php-reviewer.md +167 -0
- package/dist/plugin/agents/planner.md +184 -0
- package/dist/plugin/agents/python-reviewer.md +161 -0
- package/dist/plugin/agents/react-reviewer.md +150 -0
- package/dist/plugin/agents/silent-failure-hunter.md +158 -0
- package/dist/plugin/agents/typescript-reviewer.md +179 -0
- package/dist/plugin/agents/ui-reviewer.md +203 -0
- package/dist/plugin/commands/add-feature.md +301 -0
- package/dist/plugin/commands/build-fix.md +47 -0
- package/dist/plugin/commands/code-review.md +228 -0
- package/dist/plugin/commands/fix-defect.md +393 -0
- package/dist/plugin/commands/learn-eval.md +94 -0
- package/dist/plugin/commands/learn.md +84 -0
- package/dist/plugin/commands/plan.md +211 -0
- package/dist/plugin/commands/test-coverage.md +64 -0
- package/dist/plugin/commands/update-docs.md +98 -0
- package/dist/plugin/hooks/hooks.json +59 -0
- package/dist/plugin/hooks/scripts/auto-format.sh +63 -0
- package/dist/plugin/hooks/scripts/check-secrets-before-commit.sh +50 -0
- package/dist/plugin/hooks/scripts/guard-dangerous-commands.sh +55 -0
- package/dist/plugin/hooks/scripts/on-command-resume.sh +112 -0
- package/dist/plugin/hooks/scripts/on-command-stop.sh +200 -0
- package/dist/plugin/hooks/scripts/protect-sensitive-files.sh +58 -0
- package/dist/plugin/rules/common/coding-guidelines.md +73 -0
- package/dist/plugin/rules/documentation/api-docs.md +46 -0
- package/dist/plugin/rules/documentation/docs-site.md +60 -0
- package/dist/plugin/rules/documentation/source-docs.md +89 -0
- package/dist/plugin/rules/documentation/test-docs.md +39 -0
- package/dist/plugin/rules/logging/logging-rules.md +83 -0
- package/dist/plugin/rules/php/coding-rules.md +40 -0
- package/dist/plugin/rules/python/coding-rules.md +40 -0
- package/dist/plugin/rules/typescript/coding-rules.md +45 -0
- package/dist/plugin/skills/api-design/SKILL.md +269 -0
- package/dist/plugin/skills/backend-patterns/SKILL.md +312 -0
- package/dist/plugin/skills/database-migrations/SKILL.md +323 -0
- package/dist/plugin/skills/docker-patterns/SKILL.md +308 -0
- package/dist/plugin/skills/docs-site/SKILL.md +341 -0
- package/dist/plugin/skills/e2e-testing/SKILL.md +334 -0
- package/dist/plugin/skills/frontend-patterns/SKILL.md +318 -0
- package/dist/plugin/skills/integration-testing/SKILL.md +273 -0
- package/package.json +2 -2
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix a bug through a gated pipeline that's reproduction-test-first, proving the fix with a red-to-green transition
|
|
3
|
+
argument-hint: "[bug description / repro steps / issue number]"
|
|
4
|
+
resumable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Fix-defect pipeline
|
|
8
|
+
|
|
9
|
+
Fix a reported bug through a disciplined, gated pipeline. Three things are non-negotiable:
|
|
10
|
+
|
|
11
|
+
1. **Not one line of fix code gets written until the root cause is identified.**
|
|
12
|
+
2. **If the code under test doesn't have adequate coverage, build that up first before going test-first.**
|
|
13
|
+
3. **Write a failing test that reproduces the bug before touching the fix (red), and prove the fix by
|
|
14
|
+
making that same test pass (green).**
|
|
15
|
+
|
|
16
|
+
A bug that can't be reproduced can't be fixed, and a test that never went red proves nothing.
|
|
17
|
+
A fix without a root cause is just a symptom hidden away — and that's a failure.
|
|
18
|
+
|
|
19
|
+
Target bug: $ARGUMENTS
|
|
20
|
+
|
|
21
|
+
## Scope
|
|
22
|
+
|
|
23
|
+
- In scope: fixing "broken behavior" — something not working as expected.
|
|
24
|
+
- Out of scope: spec changes or new features — use /add-feature for those.
|
|
25
|
+
If partway through the work it turns out this is actually a spec change rather than a bug fix,
|
|
26
|
+
report that to the user and switch commands.
|
|
27
|
+
|
|
28
|
+
## Two gates
|
|
29
|
+
|
|
30
|
+
This pipeline has two gates that must never be crossed early.
|
|
31
|
+
|
|
32
|
+
1. Plan-approval gate: for standard-or-larger changes, don't write fix code until the user
|
|
33
|
+
has approved the plan.
|
|
34
|
+
2. Commit gate: never commit without the user's confirmation, under any circumstances.
|
|
35
|
+
|
|
36
|
+
Even when it's tempting to push forward autonomously, always stop at the gate and get confirmation.
|
|
37
|
+
|
|
38
|
+
## Completion Marker Convention
|
|
39
|
+
|
|
40
|
+
This command runs under `claude -p` (non-interactive), which restarts as a fresh process every turn — past turn 1, this command body is not guaranteed to be re-expanded, so gate discipline (the two gates above) can silently erode across turns. To compensate, a hooks-based mechanism re-injects a digest of this command's must-obey constraints on the next turn whenever the pipeline is left incomplete.
|
|
41
|
+
|
|
42
|
+
If this command's flow is **not yet complete** (e.g. mid root-cause investigation, stopped at the plan-approval gate, awaiting the regression test's red confirmation, mid-fix, awaiting review fixes, or stopped at the commit gate), your response **MUST end** with a line that is an exact match of:
|
|
43
|
+
|
|
44
|
+
`<!-- ai-support-agent:resume name="fix-defect" -->`
|
|
45
|
+
|
|
46
|
+
If the flow **is complete** (fix finished, committed with user confirmation, and the post-commit options were handled), do **not** output this marker.
|
|
47
|
+
|
|
48
|
+
Never output this marker inside a code block or as an illustrative example — only emit it as the actual last line of real output when the flow is genuinely incomplete.
|
|
49
|
+
|
|
50
|
+
<!-- RESUME_DIGEST_START -->
|
|
51
|
+
When resuming this command on turn 2+ without the full command body re-expanded, obey these constraints:
|
|
52
|
+
|
|
53
|
+
- **Two gates, never crossed early**:
|
|
54
|
+
1. Plan-approval gate (standard-or-larger changes): no fix code until the user has approved the fix plan.
|
|
55
|
+
2. Commit gate: never commit without the user's explicit confirmation, under any circumstances.
|
|
56
|
+
- **Root cause before any fix code**: never write fix code on a hunch of "probably here." State the hypothesis as "X is the cause, because Y," verify it with the smallest possible change, and don't layer a new fix on top of a failed hypothesis — start over.
|
|
57
|
+
- **Regression test must go red before green**: write a test that reproduces the bug and confirm it fails (red) before touching fix code. If you accidentally wrote fix code first, discard it (`git restore`) and start over from the test. After fixing, confirm that same test goes green.
|
|
58
|
+
- Never self-interpret "roughly agreed to," silence, or an unrelated follow-up as plan approval or as commit confirmation.
|
|
59
|
+
- **Don't hide the symptom**: no swallowed exceptions, no special-casing around the failing scenario, no loosened test expectations just to go green.
|
|
60
|
+
- **Step 8 verification requires evidence, not speculation**: never claim "tests pass" / "build passes" / "the bug is fixed" without having actually run the command in this conversation and read its output. A stale or previous run's result does not count as evidence.
|
|
61
|
+
- **Review gate (Step 7)**: every CRITICAL / HIGH finding from the code-reviewer / silent-failure-hunter review must be resolved, followed by a re-run of Step 6's checks (regression test green, no regressions), before moving on.
|
|
62
|
+
- Follow the Step 9 commit-gate flow exactly: present the diff + proposed commit message, wait for confirmation, commit only after confirmation, then present the four post-commit options and execute the chosen one in the correct order (never remove a worktree before merge/PR is settled).
|
|
63
|
+
<!-- RESUME_DIGEST_END -->
|
|
64
|
+
|
|
65
|
+
## Procedure
|
|
66
|
+
|
|
67
|
+
### 1. Declare the size classification
|
|
68
|
+
|
|
69
|
+
Before starting work, declare which of the following applies.
|
|
70
|
+
|
|
71
|
+
- Trivial: a change of one file, a few lines, with an obvious cause.
|
|
72
|
+
- Small: a change of one or two files, where identifying the cause takes a bit of investigation.
|
|
73
|
+
- Standard or larger: a change spanning multiple files, or where the cause is unclear.
|
|
74
|
+
|
|
75
|
+
Regardless of the size of the change, fixes touching authentication/authorization, input handling,
|
|
76
|
+
databases, external service integrations, or anything money-related are always treated as
|
|
77
|
+
"standard or larger."
|
|
78
|
+
|
|
79
|
+
### 2. Create a worktree
|
|
80
|
+
|
|
81
|
+
Create a dedicated branch and worktree for the work, and do everything from here on inside that worktree.
|
|
82
|
+
|
|
83
|
+
First check the existing isolation state.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
MAIN_ROOT=$(git rev-parse --show-toplevel)
|
|
87
|
+
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
|
|
88
|
+
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
|
|
89
|
+
SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null)
|
|
90
|
+
echo "MAIN_ROOT=$MAIN_ROOT"
|
|
91
|
+
echo "GIT_DIR=$GIT_DIR"
|
|
92
|
+
echo "GIT_COMMON=$GIT_COMMON"
|
|
93
|
+
echo "SUPERPROJECT=${SUPERPROJECT:-(none)}"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Use the output above to determine which of three states applies.
|
|
97
|
+
|
|
98
|
+
| Condition | State | Action |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `SUPERPROJECT` has a value | Inside a submodule | Don't create a worktree — work directly |
|
|
101
|
+
| `SUPERPROJECT` is empty and `GIT_DIR != GIT_COMMON` | Already inside a worktree | Don't create a new one — keep working in the existing worktree |
|
|
102
|
+
| `SUPERPROJECT` is empty and `GIT_DIR == GIT_COMMON` | Regular repository | Create a worktree (steps below) |
|
|
103
|
+
|
|
104
|
+
Create the worktree.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
git worktree add -b <branch-name> <path>
|
|
108
|
+
# e.g. git worktree add -b fix/login-error ../worktrees/fix-login-error
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Name the branch after the bug (a `fix/` prefix is recommended).
|
|
112
|
+
- A sibling directory outside the repo is usually the most convenient path (e.g. `../worktrees/<name>`).
|
|
113
|
+
- If placing it inside the project (`.worktrees/`), confirm it's in `.gitignore` before creating it (`git check-ignore -q .worktrees`). If it's not listed, add it and commit that first.
|
|
114
|
+
- Working inside a worktree keeps the main working directory clean, and rolling back is as simple as deleting the whole directory.
|
|
115
|
+
|
|
116
|
+
Once created, run the test suite to confirm a clean baseline. If there are pre-existing failures, report them to the user and confirm whether to proceed.
|
|
117
|
+
|
|
118
|
+
### 3. Investigate the root cause (four phases)
|
|
119
|
+
|
|
120
|
+
**Iron rule: not one line of fix code until the root cause is identified.**
|
|
121
|
+
|
|
122
|
+
Don't start fixing on a hunch of "probably here." A guessed fix tends to create a different bug.
|
|
123
|
+
|
|
124
|
+
#### Phase 1: Gather facts
|
|
125
|
+
|
|
126
|
+
- **Read the error message carefully**: read the stack trace to the end.
|
|
127
|
+
Record line numbers, file paths, and error codes. Don't skim.
|
|
128
|
+
- **Confirm the reproduction is consistent**: pin down the repro steps and check whether it
|
|
129
|
+
happens every time. If it's not reproducible, gather more data instead of guessing at a fix.
|
|
130
|
+
- **Check recent changes**: review `git diff`, recent commits, dependency changes, and
|
|
131
|
+
any configuration or environment differences.
|
|
132
|
+
- **In multi-layer systems, gather evidence at each boundary**: for architectures like
|
|
133
|
+
API → service → DB, measure and log "input, output, state" at each component boundary to
|
|
134
|
+
identify which layer is broken before digging into the cause. Don't make sweeping changes across every layer at once.
|
|
135
|
+
- **Trace the data flow backward**: when the error surfaces deep in the call stack, walk the
|
|
136
|
+
callers back to where the bad value originated. Fix the source, not the symptom.
|
|
137
|
+
|
|
138
|
+
#### Phase 2: Pattern analysis
|
|
139
|
+
|
|
140
|
+
- Look for a working, similar implementation elsewhere in the same codebase.
|
|
141
|
+
- List the differences between the broken code and the working code (don't overlook small ones).
|
|
142
|
+
- When consulting an external library's docs or a spec, read it in full rather than skimming a section.
|
|
143
|
+
|
|
144
|
+
#### Phase 3: Hypothesize and verify
|
|
145
|
+
|
|
146
|
+
- State the hypothesis in one clear sentence: "X is the cause, because Y."
|
|
147
|
+
- Make the **smallest possible change** to test the hypothesis (one variable at a time).
|
|
148
|
+
- Don't apply multiple fixes at once — you'll lose the ability to isolate what worked.
|
|
149
|
+
- If the hypothesis is wrong, **form a new hypothesis from scratch** rather than layering another fix on top of the failed one.
|
|
150
|
+
|
|
151
|
+
#### Plan-approval gate (standard or larger)
|
|
152
|
+
|
|
153
|
+
Once the Phase 1-3 investigation is complete, for standard-or-larger changes, draft a fix plan,
|
|
154
|
+
present it to the user, and get approval. Don't write fix code before approval.
|
|
155
|
+
Use the planner subagent or /plan.
|
|
156
|
+
|
|
157
|
+
#### If you get stuck
|
|
158
|
+
|
|
159
|
+
- **After 3 or more failed fix attempts**: stop trying individual fixes and question the
|
|
160
|
+
architecture itself. If "every fix creates a problem somewhere else" or "the fix would require
|
|
161
|
+
major refactoring," that's an architectural problem. Report the situation to the user and
|
|
162
|
+
propose a fundamental design review.
|
|
163
|
+
|
|
164
|
+
#### Excuses to watch for (all of them are off-limits)
|
|
165
|
+
|
|
166
|
+
| Excuse | Reality |
|
|
167
|
+
|---|---|
|
|
168
|
+
| "It's a simple bug, the process is overkill" | Even simple bugs have a root cause |
|
|
169
|
+
| "We're in a hurry, let's just guess a fix" | Guessing causes rework — systematic investigation is actually faster |
|
|
170
|
+
| "Probably here, let me try it" | Looking at the symptom isn't the same as understanding the root cause |
|
|
171
|
+
| "Fix it now, investigate later" | Fixing first contaminates the investigation |
|
|
172
|
+
| "One more fix attempt" (on the 3rd+ try) | Question the architecture instead |
|
|
173
|
+
|
|
174
|
+
### 4. Check test coverage of the affected code
|
|
175
|
+
|
|
176
|
+
Before starting the fix, check whether the affected code already has adequate test coverage.
|
|
177
|
+
Going test-first against inadequate coverage risks "I thought I made it red, but I just tripped
|
|
178
|
+
over a pre-existing defect." Proving the fix requires a test foundation that guarantees the
|
|
179
|
+
pre-bug, correct behavior.
|
|
180
|
+
|
|
181
|
+
What to check:
|
|
182
|
+
|
|
183
|
+
| Layer | What to confirm |
|
|
184
|
+
|---|---|
|
|
185
|
+
| Unit tests | Do they cover the normal and error paths of the affected function/method/class? |
|
|
186
|
+
| Integration tests | Is the affected code's interaction with external dependencies (DB, API, filesystem, etc.) verified? |
|
|
187
|
+
| Regression tests | Do tests exist for past, similar bugs? |
|
|
188
|
+
|
|
189
|
+
**If coverage is adequate**, move to the next step.
|
|
190
|
+
|
|
191
|
+
**If coverage is inadequate**, do the following before moving to the next step.
|
|
192
|
+
|
|
193
|
+
1. Implement the missing tests (don't write fix code yet).
|
|
194
|
+
2. Run the new tests and confirm they all **pass (green)**.
|
|
195
|
+
If any don't pass, they may be tripping over a separate pre-existing bug, or encoding a buggy
|
|
196
|
+
spec as the expected value — report this to the user and get a decision.
|
|
197
|
+
3. Get the added tests reviewed (see "Test review" below).
|
|
198
|
+
4. Resolve every CRITICAL / HIGH finding before moving to the next step.
|
|
199
|
+
|
|
200
|
+
#### Test review (only when coverage was inadequate)
|
|
201
|
+
|
|
202
|
+
Run a review using the same parallel Workflow execution as `/code-review` (Mode A).
|
|
203
|
+
|
|
204
|
+
1. Identify the added test files, and select reviewers per `/code-review`'s "Selecting reviewers" table (`code-reviewer` is always included).
|
|
205
|
+
2. Invoke the Workflow script described in `/code-review` and run the selected reviewers in parallel.
|
|
206
|
+
3. Resolve every CRITICAL / HIGH finding, and re-run the tests to confirm they're all green.
|
|
207
|
+
|
|
208
|
+
### 5. Write a regression test and confirm it fails (red)
|
|
209
|
+
|
|
210
|
+
**Iron rule: fix code must never be written before the test.**
|
|
211
|
+
|
|
212
|
+
If you accidentally write fix code before the test, **discard it immediately** and start over from writing the test.
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
git restore <the file you accidentally fixed>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
"It was just a small change," "I'll write the test right after" are not acceptable excuses. A fix without a test is an unproven claim.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
- Write a regression test that reproduces the bug, at whichever layer best reproduces it
|
|
223
|
+
(a logic bug calls for a unit test; a bug involving DB reads/writes, queries, or transactions
|
|
224
|
+
calls for an integration test against a real database; a bug in a cross-screen flow may call
|
|
225
|
+
for an E2E test).
|
|
226
|
+
- Run the test and **confirm it fails**.
|
|
227
|
+
- Check that the failure (error message, expected vs. actual value) matches the reported bug.
|
|
228
|
+
If it doesn't match, your understanding of the root cause is likely wrong — go back to step 3.
|
|
229
|
+
|
|
230
|
+
#### Test anti-patterns (avoid these)
|
|
231
|
+
|
|
232
|
+
- **Testing that a mock was called**: a test that only confirms a mock exists proves nothing
|
|
233
|
+
about actual behavior. Test the implementation.
|
|
234
|
+
- **Using a mock without understanding it**: understand the side effects of the method being
|
|
235
|
+
mocked before mocking it. Mocking "just in case" strips out the side effects it depends on and
|
|
236
|
+
makes the test meaningless.
|
|
237
|
+
- **Incomplete mock objects**: include every field the real API actually returns. A mock missing
|
|
238
|
+
some fields lets code that depends on those fields slip through untested.
|
|
239
|
+
- **Adding test-only methods to production code**: put test cleanup helpers and the like in test
|
|
240
|
+
utilities. Don't pollute production classes with them.
|
|
241
|
+
|
|
242
|
+
### 6. Fix the root cause (green)
|
|
243
|
+
|
|
244
|
+
- Fix the root cause identified in step 3.
|
|
245
|
+
- **Don't hide the symptom**: don't swallow exceptions, special-case around the failing
|
|
246
|
+
scenario with a conditional, or loosen a test's expected value just to make it pass.
|
|
247
|
+
- Confirm the regression test goes green.
|
|
248
|
+
- Run the existing test suite and confirm there's no regression. Include E2E tests
|
|
249
|
+
(`playwright.config.*` etc., if present). If they can't run due to environment constraints,
|
|
250
|
+
report that to the user.
|
|
251
|
+
- If the fix spans multiple repositories, run the test suite in every repository that was
|
|
252
|
+
changed and confirm there's no regression.
|
|
253
|
+
- If the build breaks, restore it with /build-fix before continuing.
|
|
254
|
+
|
|
255
|
+
#### Defense-in-depth validation
|
|
256
|
+
|
|
257
|
+
If the bug was caused by invalid data flowing through the system, consider not just fixing the
|
|
258
|
+
one spot but adding validation at every layer the data passes through, making the bug
|
|
259
|
+
**structurally impossible** rather than merely patched.
|
|
260
|
+
|
|
261
|
+
| Layer | What to add |
|
|
262
|
+
|---|---|
|
|
263
|
+
| Entry point | Reject invalid values early at the API/endpoint |
|
|
264
|
+
| Business logic | Add a guard at the entry of the processing function too |
|
|
265
|
+
| Environment guard | Block dangerous operations in specific contexts, like test runs |
|
|
266
|
+
| Debug logging | Log the stack trace and input values to make future investigation easier |
|
|
267
|
+
|
|
268
|
+
Each layer catches a different code path or a different mock-based bypass.
|
|
269
|
+
Whether every layer is needed depends on the nature of the bug. Include which layers you applied and why in the change.
|
|
270
|
+
|
|
271
|
+
#### Logging considerations (for projects that follow a logging convention)
|
|
272
|
+
|
|
273
|
+
Alongside the fix, check the following.
|
|
274
|
+
|
|
275
|
+
- If **ERROR/WARN logging was missing** at the point that caused the bug, add it now
|
|
276
|
+
(ask yourself: would this log have caught the bug earlier?).
|
|
277
|
+
- Confirm ERROR logs include the exception, `request_id`, and the ID of the affected resource.
|
|
278
|
+
- Confirm the correlation ID for requests passing through the fixed code is consistent end-to-end across the logs.
|
|
279
|
+
- See your project's logging conventions doc for details.
|
|
280
|
+
|
|
281
|
+
### 7. Get a review
|
|
282
|
+
|
|
283
|
+
Run a review using the same parallel Workflow execution as `/code-review` (Mode A).
|
|
284
|
+
|
|
285
|
+
1. Identify the changed files with `git diff HEAD --name-only`, and select reviewers per `/code-review`'s
|
|
286
|
+
"Selecting reviewers" table (`code-reviewer` and `silent-failure-hunter` are always included).
|
|
287
|
+
2. Invoke the Workflow script described in `/code-review` and run the selected reviewers in parallel.
|
|
288
|
+
3. Review the returned `findings` and resolve every CRITICAL / HIGH finding.
|
|
289
|
+
After making the fixes, re-run step 6's checks (regression test green, no regressions).
|
|
290
|
+
|
|
291
|
+
### 8. Verify before declaring done (no claims without evidence)
|
|
292
|
+
|
|
293
|
+
**Iron rule: run the verification commands and read the output before claiming completion.**
|
|
294
|
+
|
|
295
|
+
"Should pass," "probably fine," "I don't think there's a problem" are guesses, not claims.
|
|
296
|
+
Before crossing the commit gate, actually run the following **in this conversation** and confirm:
|
|
297
|
+
|
|
298
|
+
| Claim | Required evidence |
|
|
299
|
+
|---|---|
|
|
300
|
+
| Tests pass | Ran the test command and saw zero failures in the output |
|
|
301
|
+
| Regression test went red then green | Ran both the pre-fix red and the post-fix green and confirmed each |
|
|
302
|
+
| Build passes | Ran the build command and saw exit code 0 |
|
|
303
|
+
| The bug is fixed | Confirmed the operation/test that reproduces the original symptom now passes |
|
|
304
|
+
| No regressions | Ran the existing test suite and confirmed no failures |
|
|
305
|
+
|
|
306
|
+
All of the following are prohibited:
|
|
307
|
+
|
|
308
|
+
- Claiming completion with phrases like "should pass," "probably," "I believe"
|
|
309
|
+
- Claiming something "passes" based on a previous run (a stale result is not evidence)
|
|
310
|
+
- Trusting a subagent's "done successfully" report without verifying it yourself
|
|
311
|
+
- Reporting partial verification (only some tests) as complete verification
|
|
312
|
+
- Skipping verification because you're tired or in a hurry
|
|
313
|
+
|
|
314
|
+
### 9. Commit and clean up the worktree (commit gate)
|
|
315
|
+
|
|
316
|
+
- Present a summary of the diff and a proposed commit message, and wait for the user's confirmation.
|
|
317
|
+
- Commit only once confirmation is given.
|
|
318
|
+
- Follow the project's existing conventions (commit log style, etc.) for message format and granularity.
|
|
319
|
+
|
|
320
|
+
After committing, present the user with these four options.
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
The fix is complete. What would you like to do with this change?
|
|
324
|
+
|
|
325
|
+
1. Merge it into <base branch> locally
|
|
326
|
+
2. Push and open a Pull Request
|
|
327
|
+
3. Keep this branch as-is (handle it later)
|
|
328
|
+
4. Discard this work
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Handle each choice as follows.
|
|
332
|
+
|
|
333
|
+
**1. Local merge**
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Move out of the worktree (to the main repo root) before running this
|
|
337
|
+
cd "$MAIN_ROOT"
|
|
338
|
+
git checkout <base-branch>
|
|
339
|
+
git pull
|
|
340
|
+
git merge <fix-branch>
|
|
341
|
+
# Run the test suite after merging to confirm no regression
|
|
342
|
+
git worktree remove <worktree-path>
|
|
343
|
+
git worktree prune
|
|
344
|
+
git branch -d <fix-branch>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**2. Open a PR**
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
git push -u origin <fix-branch>
|
|
351
|
+
gh pr create --base <base-branch> --head <fix-branch> \
|
|
352
|
+
--title "<fix title>" --body "<summary of the fix and root cause>"
|
|
353
|
+
# Don't remove the worktree — it's needed for handling PR feedback
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**3. Keep as-is**
|
|
357
|
+
|
|
358
|
+
Leave both the worktree and the branch in place. Tell the user the path and stop.
|
|
359
|
+
|
|
360
|
+
**4. Discard**
|
|
361
|
+
|
|
362
|
+
Ask the user to type `discard` first, and only proceed once confirmed.
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
cd "$MAIN_ROOT"
|
|
366
|
+
git worktree remove <worktree-path>
|
|
367
|
+
git worktree prune
|
|
368
|
+
git branch -D <fix-branch>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Order and prohibitions to observe**
|
|
372
|
+
|
|
373
|
+
- Never run `git worktree remove` from inside the worktree (always move to the main repo root first).
|
|
374
|
+
- Run `git branch -d` **after** `git worktree remove` (the reverse order fails).
|
|
375
|
+
- Don't remove the worktree before the merge (confirm the merge succeeded first).
|
|
376
|
+
- Don't remove the worktree after creating a PR (option 2).
|
|
377
|
+
|
|
378
|
+
## Verification checklist
|
|
379
|
+
|
|
380
|
+
Before reporting completion, confirm all of the following.
|
|
381
|
+
|
|
382
|
+
- [ ] Identified the root cause at the code level before fixing (not a guess).
|
|
383
|
+
- [ ] Checked the affected code's test coverage. If it was inadequate, added tests first, got them reviewed, and only then moved to the next step.
|
|
384
|
+
- [ ] Wrote the test before writing the fix code (if the fix was accidentally written first, it was discarded and redone).
|
|
385
|
+
- [ ] Confirmed the regression test was red before the fix and green after.
|
|
386
|
+
- [ ] No regressions in the existing test suite (including E2E tests, if present).
|
|
387
|
+
- [ ] If the fix spans multiple repositories, ran the test suite in every changed repository and confirmed no regression.
|
|
388
|
+
- [ ] Fixed the root cause rather than hiding the symptom.
|
|
389
|
+
- [ ] Resolved every CRITICAL / HIGH review finding.
|
|
390
|
+
- [ ] Ran verification commands and read the output before claiming completion (didn't guess "should pass").
|
|
391
|
+
- [ ] Committed only after the user's confirmation (left uncommitted if not yet confirmed).
|
|
392
|
+
- [ ] Presented the four-option worktree cleanup and executed it in the correct order (remove worktree → delete branch) for the chosen option.
|
|
393
|
+
- [ ] If a logging convention applies: filled in logging that was missing at the point of the bug, and confirmed ERROR logs include the correlation ID and affected resource ID.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Evaluate a session's insights through a quality gate, keeping only records worth saving
|
|
3
|
+
argument-hint: "[optional topic to focus the extraction on]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /learn-eval - Record insights through a quality gate
|
|
7
|
+
|
|
8
|
+
The strict version of /learn. After extracting insights, it runs them through a quality gate to keep
|
|
9
|
+
memory and CLAUDE.md from bloating with low-value records. If you just want a quick save, use /learn instead.
|
|
10
|
+
|
|
11
|
+
## Procedure
|
|
12
|
+
|
|
13
|
+
### 1. Extract insights
|
|
14
|
+
|
|
15
|
+
Reflect on the session and surface candidate insights worth reusing: root causes and fixes for errors,
|
|
16
|
+
non-obvious debugging techniques, library quirks or version-specific workarounds, and project-specific
|
|
17
|
+
conventions or design decisions. Trivial fixes and one-off incidents don't count as candidates.
|
|
18
|
+
If an argument is given, narrow this to insights related to that topic.
|
|
19
|
+
|
|
20
|
+
### 2. Mandatory checks (run for every candidate)
|
|
21
|
+
|
|
22
|
+
For each candidate, always confirm the following. None of these may be skipped.
|
|
23
|
+
|
|
24
|
+
1. Search existing memory: search both global and project memory files for the same or a near-duplicate record.
|
|
25
|
+
2. Cross-check the index: check MEMORY.md and each level's CLAUDE.md for duplicate content.
|
|
26
|
+
3. Consider appending instead: decide whether appending to/updating an existing record would be better than creating a new one.
|
|
27
|
+
4. Confirm reusability: confirm there's a concrete, plausible future scenario where this would actually get referenced.
|
|
28
|
+
|
|
29
|
+
### 3. Quality evaluation
|
|
30
|
+
|
|
31
|
+
Score each candidate on the following four dimensions, each as High/Medium/Low.
|
|
32
|
+
|
|
33
|
+
- Concreteness: does it include ready-to-use code, commands, or steps? Or is it just an abstract lesson?
|
|
34
|
+
- Focus: is it scoped to one record, one pattern? Or does it mix multiple topics?
|
|
35
|
+
- Novelty: is this information not already in an existing record or in general official documentation?
|
|
36
|
+
- Reuse likelihood: is it realistic that the same situation will recur?
|
|
37
|
+
|
|
38
|
+
### 4. Verdict
|
|
39
|
+
|
|
40
|
+
Based on the evaluation, assign each candidate one of the following four verdicts.
|
|
41
|
+
|
|
42
|
+
| Verdict | Rough criteria |
|
|
43
|
+
|------|-----------|
|
|
44
|
+
| Save | Passes the mandatory checks, and all four dimensions score Medium or higher |
|
|
45
|
+
| Improve then save | Has value, but concreteness or focus scores low. Re-evaluate once after improving. |
|
|
46
|
+
| Merge into an existing record | Useful, but overlaps or nearly duplicates an existing record |
|
|
47
|
+
| Discard | Novelty or reuse likelihood is low — not worth recording |
|
|
48
|
+
|
|
49
|
+
Re-evaluation for "improve then save" happens once only. If it still doesn't meet the bar after that, discard it.
|
|
50
|
+
|
|
51
|
+
### 5. Present the check results
|
|
52
|
+
|
|
53
|
+
Present the results for each candidate in the following format.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Insight: [name]
|
|
57
|
+
Verdict: [Save / Improve then save / Merge into an existing record / Discard]
|
|
58
|
+
Scores: Concreteness=[High/Medium/Low] Focus=[High/Medium/Low] Novelty=[High/Medium/Low] Reuse likelihood=[High/Medium/Low]
|
|
59
|
+
Duplicate check: [None / Yes (name of the existing record)]
|
|
60
|
+
Rationale: [1-2 sentence basis for the verdict]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 6. Confirmation flow per verdict
|
|
64
|
+
|
|
65
|
+
- Save: present the draft record and destination to the user, and save after approval.
|
|
66
|
+
- Improve then save: re-evaluate the improved draft, and proceed to the save flow once it passes.
|
|
67
|
+
- Merge into an existing record: present the target record and the content to append, and update after approval.
|
|
68
|
+
- Discard: just explain why. Don't write anything to a file.
|
|
69
|
+
|
|
70
|
+
### 7. Saving
|
|
71
|
+
|
|
72
|
+
Save to the memory feature (individual memory files plus the MEMORY.md index) if available; otherwise
|
|
73
|
+
append to the appropriate section of the CLAUDE.md at the applicable level.
|
|
74
|
+
Decide the level (global vs. project) by whether it would help in other projects too — when in doubt, go global.
|
|
75
|
+
|
|
76
|
+
Record format:
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
## [Insight name]
|
|
80
|
+
|
|
81
|
+
- Applies when: which environment, version, or situation this holds for
|
|
82
|
+
- Problem: what happened
|
|
83
|
+
- Solution: concrete steps, code, or commands
|
|
84
|
+
- When to use this: what future situation should trigger looking this up
|
|
85
|
+
- Recorded: YYYY-MM-DD
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Notes
|
|
89
|
+
|
|
90
|
+
- Don't save things "just in case." When in doubt, lean toward discarding, and state why.
|
|
91
|
+
- Respect the user's objection to a verdict — if the user wants something saved, they can override the verdict.
|
|
92
|
+
- Even if every candidate gets discarded, report that outcome and the reasons as a list.
|
|
93
|
+
|
|
94
|
+
Note: the extraction criteria, storage-level rules, and record format are intentionally duplicated between learn.md and learn-eval.md, since each command needs to be self-contained. Keep both files in sync when changing either.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Reflect on the session and record reusable insights for future sessions
|
|
3
|
+
argument-hint: "[optional topic to focus the extraction on]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /learn - Record insights from a session
|
|
7
|
+
|
|
8
|
+
Reflect on the current session and extract insights worth saving for reuse in future sessions.
|
|
9
|
+
If an argument is given, narrow the extraction to insights related to that topic.
|
|
10
|
+
|
|
11
|
+
## Procedure
|
|
12
|
+
|
|
13
|
+
### 1. Reflect on the session and extract insights
|
|
14
|
+
|
|
15
|
+
Look back over the whole session and surface anything that fits these categories.
|
|
16
|
+
|
|
17
|
+
What to extract:
|
|
18
|
+
- Root causes and fixes for errors (things you could act on immediately if this recurs)
|
|
19
|
+
- Non-obvious debugging techniques (an investigation approach or way of narrowing down the cause that was distinctive)
|
|
20
|
+
- Library quirks or version-specific workarounds
|
|
21
|
+
- Project-specific conventions or design decisions (including context that isn't obvious just from reading the code)
|
|
22
|
+
|
|
23
|
+
What to exclude:
|
|
24
|
+
- Trivial fixes like typo corrections
|
|
25
|
+
- One-off incidents (an outage at a specific time, a transient glitch in a specific environment)
|
|
26
|
+
- General knowledge that's obvious from official documentation
|
|
27
|
+
|
|
28
|
+
If nothing qualifies, report "No insights worth recording were found" and stop.
|
|
29
|
+
|
|
30
|
+
### 2. Decide the storage level
|
|
31
|
+
|
|
32
|
+
For each insight, judge it against "would this help in other projects too?"
|
|
33
|
+
|
|
34
|
+
- Useful in other projects → global (user-level)
|
|
35
|
+
- Only meaningful in this project → project-level
|
|
36
|
+
- When in doubt → save it globally
|
|
37
|
+
|
|
38
|
+
### 3. Decide where to save it
|
|
39
|
+
|
|
40
|
+
Check whether a memory feature (individual memory files plus a MEMORY.md index) is available.
|
|
41
|
+
|
|
42
|
+
- If available: create an individual memory file for each insight, and add a one-line entry to the MEMORY.md index.
|
|
43
|
+
- If not available: append to the appropriate section of the CLAUDE.md at the level decided in step 2.
|
|
44
|
+
If no matching section exists, create a new "Lessons learned" section.
|
|
45
|
+
|
|
46
|
+
### 4. Check for duplicates
|
|
47
|
+
|
|
48
|
+
Before saving, search existing memory files, MEMORY.md, and CLAUDE.md for the same or similar content
|
|
49
|
+
already on record. If a duplicate or near-duplicate is found, propose appending to/updating the existing
|
|
50
|
+
record instead of creating a new one.
|
|
51
|
+
|
|
52
|
+
### 5. Draft the record
|
|
53
|
+
|
|
54
|
+
Draft using the following format.
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
## [Insight name (concise and easy to search for)]
|
|
58
|
+
|
|
59
|
+
- Applies when: which environment, version, or situation this holds for
|
|
60
|
+
- Problem: what happened, what the symptoms were
|
|
61
|
+
- Solution: concrete steps, code, or commands
|
|
62
|
+
- When to use this: what future situation should trigger looking this up
|
|
63
|
+
- Recorded: YYYY-MM-DD
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Prefer including code or commands in the solution that can be copied and used as-is.
|
|
67
|
+
|
|
68
|
+
### 6. Confirm with the user and save
|
|
69
|
+
|
|
70
|
+
Present the draft and the intended location (level and file) to the user and get confirmation.
|
|
71
|
+
|
|
72
|
+
- If approved: save it and report the path where it was saved.
|
|
73
|
+
- If changes are requested: revise and re-present.
|
|
74
|
+
- If deemed unnecessary: finish without saving.
|
|
75
|
+
|
|
76
|
+
If there are multiple insights, present them as a list and let the user choose which to save.
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- One record, one pattern. Split multiple insights into separate records.
|
|
81
|
+
- Don't record speculation — only facts actually confirmed during the session.
|
|
82
|
+
- For a stricter quality gate, use /learn-eval instead.
|
|
83
|
+
|
|
84
|
+
Note: the extraction criteria, storage-level rules, and record format are intentionally duplicated between learn.md and learn-eval.md, since each command needs to be self-contained. Keep both files in sync when changing either.
|