@harness-engineering/cli 1.8.0 → 1.8.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/agents/skills/claude-code/harness-autopilot/SKILL.md +2 -2
- package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +5 -7
- package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +2 -2
- package/dist/agents/skills/claude-code/harness-planning/SKILL.md +2 -2
- package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +4 -5
- package/dist/agents/skills/gemini-cli/add-harness-component/SKILL.md +192 -0
- package/dist/agents/skills/gemini-cli/add-harness-component/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/align-documentation/SKILL.md +213 -0
- package/dist/agents/skills/gemini-cli/align-documentation/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/check-mechanical-constraints/SKILL.md +191 -0
- package/dist/agents/skills/gemini-cli/check-mechanical-constraints/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/cleanup-dead-code/SKILL.md +245 -0
- package/dist/agents/skills/gemini-cli/cleanup-dead-code/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/detect-doc-drift/SKILL.md +179 -0
- package/dist/agents/skills/gemini-cli/detect-doc-drift/skill.yaml +30 -0
- package/dist/agents/skills/gemini-cli/enforce-architecture/SKILL.md +240 -0
- package/dist/agents/skills/gemini-cli/enforce-architecture/skill.yaml +34 -0
- package/dist/agents/skills/gemini-cli/harness-architecture-advisor/SKILL.md +397 -0
- package/dist/agents/skills/gemini-cli/harness-architecture-advisor/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +2 -2
- package/dist/agents/skills/gemini-cli/harness-brainstorming/SKILL.md +317 -0
- package/dist/agents/skills/gemini-cli/harness-brainstorming/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-code-review/SKILL.md +681 -0
- package/dist/agents/skills/gemini-cli/harness-code-review/skill.yaml +45 -0
- package/dist/agents/skills/gemini-cli/harness-debugging/SKILL.md +366 -0
- package/dist/agents/skills/gemini-cli/harness-debugging/skill.yaml +47 -0
- package/dist/agents/skills/gemini-cli/harness-diagnostics/SKILL.md +318 -0
- package/dist/agents/skills/gemini-cli/harness-diagnostics/skill.yaml +50 -0
- package/dist/agents/skills/gemini-cli/harness-execution/SKILL.md +382 -0
- package/dist/agents/skills/gemini-cli/harness-execution/skill.yaml +51 -0
- package/dist/agents/skills/gemini-cli/harness-git-workflow/SKILL.md +268 -0
- package/dist/agents/skills/gemini-cli/harness-git-workflow/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/harness-integrity/SKILL.md +167 -0
- package/dist/agents/skills/gemini-cli/harness-integrity/skill.yaml +47 -0
- package/dist/agents/skills/gemini-cli/harness-onboarding/SKILL.md +288 -0
- package/dist/agents/skills/gemini-cli/harness-onboarding/skill.yaml +30 -0
- package/dist/agents/skills/gemini-cli/harness-parallel-agents/SKILL.md +171 -0
- package/dist/agents/skills/gemini-cli/harness-parallel-agents/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-planning/SKILL.md +389 -0
- package/dist/agents/skills/gemini-cli/harness-planning/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-pre-commit-review/SKILL.md +262 -0
- package/dist/agents/skills/gemini-cli/harness-pre-commit-review/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-refactoring/SKILL.md +169 -0
- package/dist/agents/skills/gemini-cli/harness-refactoring/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +4 -5
- package/dist/agents/skills/gemini-cli/harness-skill-authoring/SKILL.md +292 -0
- package/dist/agents/skills/gemini-cli/harness-skill-authoring/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/harness-state-management/SKILL.md +309 -0
- package/dist/agents/skills/gemini-cli/harness-state-management/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/harness-tdd/SKILL.md +177 -0
- package/dist/agents/skills/gemini-cli/harness-tdd/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-verification/SKILL.md +328 -0
- package/dist/agents/skills/gemini-cli/harness-verification/skill.yaml +42 -0
- package/dist/agents/skills/gemini-cli/harness-verify/SKILL.md +159 -0
- package/dist/agents/skills/gemini-cli/harness-verify/skill.yaml +40 -0
- package/dist/agents/skills/gemini-cli/initialize-harness-project/SKILL.md +224 -0
- package/dist/agents/skills/gemini-cli/initialize-harness-project/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/validate-context-engineering/SKILL.md +150 -0
- package/dist/agents/skills/gemini-cli/validate-context-engineering/skill.yaml +31 -0
- package/dist/bin/harness.js +3 -3
- package/dist/{chunk-SJECMKSS.js → chunk-E2RTDBMG.js} +25 -13
- package/dist/{chunk-LNI4T7R6.js → chunk-KJANDVVC.js} +20 -18
- package/dist/{chunk-3JWCBVUZ.js → chunk-RT2LYQHF.js} +1 -1
- package/dist/{dist-NT3GXHQZ.js → dist-CCM3L3UE.js} +1 -1
- package/dist/{dist-BDO5GFEM.js → dist-K6KTTN3I.js} +3 -3
- package/dist/index.js +3 -3
- package/dist/validate-cross-check-ZGKFQY57.js +7 -0
- package/package.json +6 -6
- package/dist/agents/skills/node_modules/.bin/glob +0 -17
- package/dist/agents/skills/node_modules/.bin/vitest +0 -17
- package/dist/agents/skills/node_modules/.bin/yaml +0 -17
- package/dist/templates/advanced/docs/specs/.gitkeep +0 -0
- package/dist/templates/intermediate/docs/specs/.gitkeep +0 -0
- package/dist/validate-cross-check-2OPGCGGU.js +0 -7
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: harness-code-review
|
|
2
|
+
version: "2.0.0"
|
|
3
|
+
description: Multi-phase code review pipeline with mechanical checks, graph-scoped context, and parallel review agents
|
|
4
|
+
cognitive_mode: adversarial-reviewer
|
|
5
|
+
triggers:
|
|
6
|
+
- manual
|
|
7
|
+
- on_pr
|
|
8
|
+
- on_review
|
|
9
|
+
platforms:
|
|
10
|
+
- claude-code
|
|
11
|
+
- gemini-cli
|
|
12
|
+
tools:
|
|
13
|
+
- Bash
|
|
14
|
+
- Read
|
|
15
|
+
- Glob
|
|
16
|
+
- Grep
|
|
17
|
+
- emit_interaction
|
|
18
|
+
cli:
|
|
19
|
+
command: harness skill run harness-code-review
|
|
20
|
+
args:
|
|
21
|
+
- name: path
|
|
22
|
+
description: Project root path
|
|
23
|
+
required: false
|
|
24
|
+
- name: --comment
|
|
25
|
+
description: Post inline comments to GitHub PR
|
|
26
|
+
required: false
|
|
27
|
+
- name: --deep
|
|
28
|
+
description: Add threat modeling pass (invokes security-review --deep)
|
|
29
|
+
required: false
|
|
30
|
+
- name: --no-mechanical
|
|
31
|
+
description: Skip mechanical checks (useful if already run)
|
|
32
|
+
required: false
|
|
33
|
+
- name: --ci
|
|
34
|
+
description: Enable eligibility gate, non-interactive output
|
|
35
|
+
required: false
|
|
36
|
+
mcp:
|
|
37
|
+
tool: run_skill
|
|
38
|
+
input:
|
|
39
|
+
skill: harness-code-review
|
|
40
|
+
path: string
|
|
41
|
+
type: rigid
|
|
42
|
+
state:
|
|
43
|
+
persistent: false
|
|
44
|
+
files: []
|
|
45
|
+
depends_on: []
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# Harness Debugging
|
|
2
|
+
|
|
3
|
+
> 4-phase systematic debugging with entropy analysis and persistent sessions. Phase 1 before ANY fix. "It's probably X" is not a diagnosis.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- When a test fails and the cause is not immediately obvious
|
|
8
|
+
- When a feature works in one context but fails in another
|
|
9
|
+
- When an error message does not clearly indicate the root cause
|
|
10
|
+
- When `on_bug_fix` triggers fire
|
|
11
|
+
- When a previous fix attempt did not resolve the issue
|
|
12
|
+
- NOT for known issues with documented solutions (apply the solution directly)
|
|
13
|
+
- NOT for typos, syntax errors, or other obvious fixes (just fix them)
|
|
14
|
+
- NOT for feature development (use harness-tdd instead)
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
|
|
18
|
+
### Prerequisite: Start a Debug Session
|
|
19
|
+
|
|
20
|
+
Before beginning, create a persistent debug session. This survives context resets and tracks state across multiple attempts.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
.harness/debug/active/<session-id>.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Session file format:
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
# Debug Session: <brief-description>
|
|
30
|
+
|
|
31
|
+
Status: gathering
|
|
32
|
+
Started: <timestamp>
|
|
33
|
+
Error: <the error message or symptom>
|
|
34
|
+
|
|
35
|
+
## Investigation Log
|
|
36
|
+
|
|
37
|
+
(append entries as you go)
|
|
38
|
+
|
|
39
|
+
## Hypotheses
|
|
40
|
+
|
|
41
|
+
(track what you have tried)
|
|
42
|
+
|
|
43
|
+
## Resolution
|
|
44
|
+
|
|
45
|
+
(filled in when resolved)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Status transitions:** `gathering` -> `investigating` -> `fixing` -> `verifying` -> `resolved`
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### Phase 1: INVESTIGATE — Understand Before Acting
|
|
53
|
+
|
|
54
|
+
**You must complete Phase 1 before writing ANY fix code. No exceptions.**
|
|
55
|
+
|
|
56
|
+
#### Step 1: Run Entropy Analysis
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
harness cleanup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Review the output. Entropy analysis reveals:
|
|
63
|
+
|
|
64
|
+
- Dead code and unused imports near the failure
|
|
65
|
+
- Pattern violations that may be contributing
|
|
66
|
+
- Documentation drift that may have caused incorrect usage
|
|
67
|
+
- Dependency issues that could affect behavior
|
|
68
|
+
|
|
69
|
+
Record relevant findings in the session log.
|
|
70
|
+
|
|
71
|
+
#### Step 2: Read the Error Carefully
|
|
72
|
+
|
|
73
|
+
Read the COMPLETE error message. Not just the first line — the entire stack trace, every warning, every note. Errors often contain the answer.
|
|
74
|
+
|
|
75
|
+
Ask yourself:
|
|
76
|
+
|
|
77
|
+
- What exactly failed? (Not "it broke" — what specific operation?)
|
|
78
|
+
- Where did it fail? (File, line, function)
|
|
79
|
+
- What was the input that caused the failure?
|
|
80
|
+
- What was the expected behavior vs actual behavior?
|
|
81
|
+
|
|
82
|
+
Record the answers in the session log.
|
|
83
|
+
|
|
84
|
+
#### Step 3: Reproduce Consistently
|
|
85
|
+
|
|
86
|
+
Run the failing scenario multiple times. Confirm it fails every time with the same error. If it is intermittent, record:
|
|
87
|
+
|
|
88
|
+
- How often it fails (1 in 3? 1 in 10?)
|
|
89
|
+
- Whether the failure mode changes
|
|
90
|
+
- Environmental factors (timing, ordering, state)
|
|
91
|
+
|
|
92
|
+
If you cannot reproduce the failure, you cannot debug it. Escalate.
|
|
93
|
+
|
|
94
|
+
#### Step 4: Check Recent Changes
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git log --oneline -20
|
|
98
|
+
git diff HEAD~5
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
What changed recently? Many bugs are caused by the most recent change. Compare the failing state to the last known working state.
|
|
102
|
+
|
|
103
|
+
#### Step 5: Trace Data Flow Backward
|
|
104
|
+
|
|
105
|
+
Start at the error location and trace backward:
|
|
106
|
+
|
|
107
|
+
1. What function threw the error?
|
|
108
|
+
2. What called that function? With what arguments?
|
|
109
|
+
3. Where did those arguments come from?
|
|
110
|
+
4. Continue until you find where the actual value diverges from the expected value.
|
|
111
|
+
|
|
112
|
+
Read each function in the call chain completely. Do not skim.
|
|
113
|
+
|
|
114
|
+
Update the session status to `investigating`.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Phase 2: ANALYZE — Find the Pattern
|
|
119
|
+
|
|
120
|
+
#### Step 1: Find Working Examples
|
|
121
|
+
|
|
122
|
+
Search the codebase for similar functionality that WORKS. There is almost always a working example of what you are trying to do.
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Look for:
|
|
126
|
+
- Other calls to the same function/API that succeed
|
|
127
|
+
- Similar features that work correctly
|
|
128
|
+
- Test fixtures that exercise the same code path
|
|
129
|
+
- Documentation or comments that describe expected behavior
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Step 2: Read Reference Implementations Completely
|
|
133
|
+
|
|
134
|
+
When you find a working example, read it in its entirety. Do not cherry-pick lines. Understand:
|
|
135
|
+
|
|
136
|
+
- How it sets up the context
|
|
137
|
+
- What arguments it passes
|
|
138
|
+
- How it handles errors
|
|
139
|
+
- What it does differently from the failing code
|
|
140
|
+
|
|
141
|
+
#### Step 3: Identify Differences
|
|
142
|
+
|
|
143
|
+
Compare the working example to the failing code line by line. The bug is in the differences. Common categories:
|
|
144
|
+
|
|
145
|
+
- **Missing setup:** Working code initializes something the failing code skips
|
|
146
|
+
- **Wrong arguments:** Type mismatch, wrong order, missing optional parameter
|
|
147
|
+
- **State dependency:** Working code runs after some prerequisite; failing code does not
|
|
148
|
+
- **Environment:** Working code runs in a different context (different config, different permissions)
|
|
149
|
+
- **Timing:** Working code awaits something the failing code does not
|
|
150
|
+
|
|
151
|
+
Record all differences in the session log.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Phase 3: HYPOTHESIZE — One Variable at a Time
|
|
156
|
+
|
|
157
|
+
#### Step 1: Form a Single Falsifiable Hypothesis
|
|
158
|
+
|
|
159
|
+
Based on your investigation and analysis, state a specific hypothesis:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
"The failure occurs because [specific cause].
|
|
163
|
+
If this hypothesis is correct, then [observable prediction].
|
|
164
|
+
I can test this by [specific action]."
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A good hypothesis is falsifiable — there is a concrete test that would disprove it. "Something is wrong with the configuration" is not a hypothesis. "The database connection string is missing the port number, causing connection timeout" is a hypothesis.
|
|
168
|
+
|
|
169
|
+
#### Step 2: Test ONE Variable
|
|
170
|
+
|
|
171
|
+
Change exactly ONE thing to test your hypothesis. If you change multiple things, you cannot determine which one had the effect.
|
|
172
|
+
|
|
173
|
+
- Add a single log statement to check a value
|
|
174
|
+
- Change one argument to match the working example
|
|
175
|
+
- Add one missing setup step
|
|
176
|
+
|
|
177
|
+
#### Step 3: Observe the Result
|
|
178
|
+
|
|
179
|
+
Run the failing scenario. Did the behavior change?
|
|
180
|
+
|
|
181
|
+
- **Hypothesis confirmed:** The change fixed it (or changed the error in the predicted way). Proceed to Phase 4.
|
|
182
|
+
- **Hypothesis rejected:** Revert the change. Form a new hypothesis based on what you learned. The rejection itself is valuable data — record it.
|
|
183
|
+
|
|
184
|
+
#### Step 4: Create Minimal Reproduction
|
|
185
|
+
|
|
186
|
+
If the bug is in a complex system, extract a minimal reproduction:
|
|
187
|
+
|
|
188
|
+
- Smallest possible code that exhibits the bug
|
|
189
|
+
- Fewest dependencies
|
|
190
|
+
- Simplest configuration
|
|
191
|
+
|
|
192
|
+
This serves two purposes: it confirms your understanding of the root cause, and it becomes the basis for a regression test.
|
|
193
|
+
|
|
194
|
+
Update the session status to `fixing`.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### Phase 4: FIX — Root Cause, Not Symptoms
|
|
199
|
+
|
|
200
|
+
#### Step 1: Write the Regression Test
|
|
201
|
+
|
|
202
|
+
Before writing the fix, write a test that:
|
|
203
|
+
|
|
204
|
+
- Reproduces the exact failure scenario
|
|
205
|
+
- Asserts the correct behavior
|
|
206
|
+
- Currently FAILS (proving it catches the bug)
|
|
207
|
+
|
|
208
|
+
This follows harness-tdd discipline. The fix is driven by a failing test.
|
|
209
|
+
|
|
210
|
+
#### Step 2: Implement the Fix
|
|
211
|
+
|
|
212
|
+
Write a SINGLE fix that addresses the ROOT CAUSE identified in Phase 3. Not a workaround. Not a symptom suppression. The root cause.
|
|
213
|
+
|
|
214
|
+
Characteristics of a good fix:
|
|
215
|
+
|
|
216
|
+
- Changes as little code as possible
|
|
217
|
+
- Addresses why the bug happened, not just what the bug did
|
|
218
|
+
- Does not introduce new complexity
|
|
219
|
+
- Would be obvious to someone reading the code later
|
|
220
|
+
|
|
221
|
+
Characteristics of a bad fix (revert immediately):
|
|
222
|
+
|
|
223
|
+
- Adds a special case or `if` branch for the specific failing input
|
|
224
|
+
- Wraps the failure in a try-catch that swallows the error
|
|
225
|
+
- Adds a retry loop or delay to "work around" a timing issue
|
|
226
|
+
- Changes a type to `any` or removes a type check
|
|
227
|
+
|
|
228
|
+
#### Step 3: Verify the Fix
|
|
229
|
+
|
|
230
|
+
1. Run the regression test — must PASS
|
|
231
|
+
2. Run the full test suite — all tests must PASS
|
|
232
|
+
3. Run `harness validate` — must PASS
|
|
233
|
+
4. Run `harness check-deps` — must PASS
|
|
234
|
+
5. Manually verify the original failing scenario works
|
|
235
|
+
|
|
236
|
+
### Graph Refresh
|
|
237
|
+
|
|
238
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
harness scan [path]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
245
|
+
|
|
246
|
+
#### Step 4: Verify the Test Catches the Bug
|
|
247
|
+
|
|
248
|
+
Apply the regression test verification protocol:
|
|
249
|
+
|
|
250
|
+
1. Temporarily revert the fix
|
|
251
|
+
2. Run the regression test — must FAIL
|
|
252
|
+
3. Restore the fix
|
|
253
|
+
4. Run the regression test — must PASS
|
|
254
|
+
|
|
255
|
+
If the test passes without the fix, the test does not catch the bug. Rewrite the test.
|
|
256
|
+
|
|
257
|
+
#### Step 5: Close the Session
|
|
258
|
+
|
|
259
|
+
Update the debug session:
|
|
260
|
+
|
|
261
|
+
```markdown
|
|
262
|
+
Status: resolved
|
|
263
|
+
Resolved: <timestamp>
|
|
264
|
+
|
|
265
|
+
## Resolution
|
|
266
|
+
|
|
267
|
+
Root cause: <what actually caused the bug>
|
|
268
|
+
Fix: <what was changed and why>
|
|
269
|
+
Regression test: <path to test file>
|
|
270
|
+
Learnings: <what to remember for next time>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Move the session file:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
mv .harness/debug/active/<session-id>.md .harness/debug/resolved/
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Append learnings to `.harness/learnings.md` if the bug revealed a pattern that should be remembered.
|
|
280
|
+
|
|
281
|
+
Update the session status to `resolved`.
|
|
282
|
+
|
|
283
|
+
## Harness Integration
|
|
284
|
+
|
|
285
|
+
- **`harness cleanup`** — Run in Phase 1 INVESTIGATE for entropy analysis. Reveals dead code, pattern violations, and drift near the failure site.
|
|
286
|
+
- **`harness validate`** — Run in Phase 4 VERIFY after applying the fix. Confirms the fix does not break project-wide constraints.
|
|
287
|
+
- **`harness check-deps`** — Run in Phase 4 VERIFY. Confirms the fix does not introduce dependency violations.
|
|
288
|
+
- **`harness state learn`** — Run after resolution to capture learnings for future sessions.
|
|
289
|
+
- **Debug session files** — Stored in `.harness/debug/active/` (in progress) and `.harness/debug/resolved/` (completed). These persist across context resets.
|
|
290
|
+
|
|
291
|
+
## Success Criteria
|
|
292
|
+
|
|
293
|
+
- Phase 1 INVESTIGATE was completed before any fix was attempted
|
|
294
|
+
- Root cause was identified and documented (not just the symptom)
|
|
295
|
+
- A regression test exists that fails without the fix and passes with it
|
|
296
|
+
- The fix addresses the root cause, not a symptom
|
|
297
|
+
- All harness checks pass after the fix
|
|
298
|
+
- Debug session file is complete with investigation log, hypotheses, and resolution
|
|
299
|
+
- Learnings were captured for future reference
|
|
300
|
+
|
|
301
|
+
## Examples
|
|
302
|
+
|
|
303
|
+
### Example: API Endpoint Returns 500 Instead of 400
|
|
304
|
+
|
|
305
|
+
**Phase 1 — INVESTIGATE:**
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
harness cleanup: No entropy issues near api/routes/users.ts
|
|
309
|
+
Error: "Cannot read properties of undefined (reading 'email')"
|
|
310
|
+
Stack trace points to: src/services/user-service.ts:34
|
|
311
|
+
Reproduces consistently with POST /users and empty body {}
|
|
312
|
+
Recent changes: Added input validation middleware (2 commits ago)
|
|
313
|
+
Data flow: request.body -> validate() -> createUser(body.email)
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Phase 2 — ANALYZE:**
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
Working example: POST /orders handles empty body correctly
|
|
320
|
+
Difference: /orders validates BEFORE destructuring; /users destructures BEFORE validating
|
|
321
|
+
The validation middleware runs but its result is not checked
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Phase 3 — HYPOTHESIZE:**
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
Hypothesis: The validation middleware sets req.validationErrors but the route
|
|
328
|
+
handler does not check it before accessing req.body.email.
|
|
329
|
+
Test: Add a log before line 34 to check req.validationErrors.
|
|
330
|
+
Result: Confirmed — validationErrors contains "email is required" but handler proceeds.
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Phase 4 — FIX:**
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
// Regression test
|
|
337
|
+
it('returns 400 when request body is empty', async () => {
|
|
338
|
+
const res = await request(app).post('/users').send({});
|
|
339
|
+
expect(res.status).toBe(400);
|
|
340
|
+
expect(res.body.errors).toContain('email is required');
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Fix: Check validation result before processing
|
|
344
|
+
if (req.validationErrors?.length) {
|
|
345
|
+
return res.status(400).json({ errors: req.validationErrors });
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Revert test: Commenting out the validation check causes the test to fail with 500. Confirmed.
|
|
350
|
+
|
|
351
|
+
## Gates
|
|
352
|
+
|
|
353
|
+
- **Phase 1 before ANY fix.** You must complete investigation before writing fix code. Skipping investigation leads to symptom-chasing, which leads to more bugs.
|
|
354
|
+
- **One variable at a time.** Changing multiple things simultaneously is forbidden. If you changed two things and the bug is fixed, you do not know which change fixed it (or if the other change introduced a new bug).
|
|
355
|
+
- **After 3 failed fix attempts, question the architecture.** If three consecutive hypotheses were wrong or three fixes did not resolve the issue, the problem is likely not where you think it is. Step back. Re-read the investigation log. Consider that the bug might be in a different layer entirely.
|
|
356
|
+
- **Never "quick fix now, investigate later."** There is no later. The quick fix becomes permanent. The investigation never happens. The root cause festers. Fix it right or do not fix it.
|
|
357
|
+
- **Regression test must fail without fix.** A test that passes whether or not the fix is present is not a regression test. It provides no protection.
|
|
358
|
+
|
|
359
|
+
## Escalation
|
|
360
|
+
|
|
361
|
+
- **Red flag: "It's probably X, let me fix that."** STOP. This is guessing, not debugging. You skipped Phase 1. Go back to investigation.
|
|
362
|
+
- **Red flag: "One more fix attempt" after 2 failed attempts.** STOP. You are about to hit the 3-attempt wall. Step back and question your mental model of the system. Re-read the code from scratch. Consider that your understanding of how the system works may be wrong.
|
|
363
|
+
- **Cannot reproduce the bug:** If you cannot make the bug happen consistently, you cannot debug it scientifically. Document exactly what you tried, what environment you tested in, and escalate. Do not guess at a fix for a bug you cannot reproduce.
|
|
364
|
+
- **Bug is in a dependency you do not control:** Document the bug, write a test that demonstrates it, and escalate. If a workaround is needed, clearly mark it as a workaround with a reference to the upstream issue.
|
|
365
|
+
- **Investigation reveals a systemic issue:** If the bug is a symptom of a larger architectural problem (e.g., widespread race conditions, fundamental type unsafety), escalate to the human. A local fix will not solve a systemic problem.
|
|
366
|
+
- **Debug session exceeds 60 minutes without progress:** Something is wrong with the approach. Stop. Summarize what you know in the session file. Take a break (context reset). Return with fresh eyes and re-read the session file from the beginning.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: harness-debugging
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
description: Systematic debugging with harness validation and state tracking
|
|
4
|
+
cognitive_mode: diagnostic-investigator
|
|
5
|
+
triggers:
|
|
6
|
+
- manual
|
|
7
|
+
- on_bug_fix
|
|
8
|
+
platforms:
|
|
9
|
+
- claude-code
|
|
10
|
+
- gemini-cli
|
|
11
|
+
tools:
|
|
12
|
+
- Bash
|
|
13
|
+
- Read
|
|
14
|
+
- Write
|
|
15
|
+
- Edit
|
|
16
|
+
- Glob
|
|
17
|
+
- Grep
|
|
18
|
+
cli:
|
|
19
|
+
command: harness skill run harness-debugging
|
|
20
|
+
args:
|
|
21
|
+
- name: path
|
|
22
|
+
description: Project root path
|
|
23
|
+
required: false
|
|
24
|
+
mcp:
|
|
25
|
+
tool: run_skill
|
|
26
|
+
input:
|
|
27
|
+
skill: harness-debugging
|
|
28
|
+
path: string
|
|
29
|
+
type: rigid
|
|
30
|
+
phases:
|
|
31
|
+
- name: investigate
|
|
32
|
+
description: Entropy analysis and root cause search
|
|
33
|
+
required: true
|
|
34
|
+
- name: analyze
|
|
35
|
+
description: Pattern matching against codebase
|
|
36
|
+
required: true
|
|
37
|
+
- name: hypothesize
|
|
38
|
+
description: Form and test single hypothesis
|
|
39
|
+
required: false
|
|
40
|
+
- name: fix
|
|
41
|
+
description: TDD-style regression test and fix
|
|
42
|
+
required: true
|
|
43
|
+
state:
|
|
44
|
+
persistent: true
|
|
45
|
+
files:
|
|
46
|
+
- .harness/debug/
|
|
47
|
+
depends_on: []
|