@harness-engineering/cli 1.7.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/personas/documentation-maintainer.yaml +3 -1
- package/dist/agents/personas/performance-guardian.yaml +23 -0
- package/dist/agents/skills/claude-code/align-documentation/SKILL.md +13 -0
- package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +25 -1
- package/dist/agents/skills/claude-code/cleanup-dead-code/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +12 -0
- package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +48 -1
- package/dist/agents/skills/claude-code/enforce-architecture/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/harness-accessibility/SKILL.md +7 -0
- package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +11 -3
- package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +81 -11
- package/dist/agents/skills/claude-code/harness-brainstorming/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +487 -234
- package/dist/agents/skills/claude-code/harness-code-review/skill.yaml +15 -2
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/skill.yaml +64 -0
- package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/claude-code/harness-docs-pipeline/skill.yaml +69 -0
- package/dist/agents/skills/claude-code/harness-execution/SKILL.md +73 -8
- package/dist/agents/skills/claude-code/harness-execution/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/claude-code/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/claude-code/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +17 -1
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +46 -5
- package/dist/agents/skills/claude-code/harness-perf/SKILL.md +37 -8
- package/dist/agents/skills/claude-code/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +17 -4
- package/dist/agents/skills/claude-code/harness-planning/SKILL.md +59 -5
- package/dist/agents/skills/claude-code/harness-planning/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +16 -0
- package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +561 -0
- package/dist/agents/skills/claude-code/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +36 -2
- package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +8 -6
- package/dist/agents/skills/claude-code/harness-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/claude-code/harness-soundness-review/skill.yaml +48 -0
- package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-verification/SKILL.md +66 -0
- package/dist/agents/skills/claude-code/harness-verification/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-verify/SKILL.md +11 -0
- package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +15 -1
- package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +12 -0
- 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-accessibility/SKILL.md +7 -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 +11 -3
- 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-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/skill.yaml +64 -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-dependency-health/SKILL.md +35 -6
- 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-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/gemini-cli/harness-docs-pipeline/skill.yaml +69 -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-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/gemini-cli/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/gemini-cli/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +35 -6
- 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-knowledge-mapper/SKILL.md +46 -5
- 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-perf/SKILL.md +37 -8
- package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +17 -4
- 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-release-readiness/SKILL.md +16 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +561 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +8 -6
- 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-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/gemini-cli/harness-soundness-review/skill.yaml +48 -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-test-advisor/SKILL.md +35 -6
- 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/agents/skills/shared/i18n-knowledge/accessibility/intersection.yaml +142 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/encoding.yaml +67 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/formatting.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/layout.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/pluralization.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/string-handling.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/android-resources.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/apple-strings.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/backend-patterns.yaml +50 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/flutter-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/i18next.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/react-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/vue-i18n.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/ecommerce.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/fintech.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/gaming.yaml +69 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/healthcare.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/legal.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ar.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/de.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/en.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/es.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/he.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/hi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/it.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ja.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ko.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/nl.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pl.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pt.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ru.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/sv.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/th.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/tr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hans.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hant.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/i18next-mcp.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lingo-dev.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lokalise.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/tolgee.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/locale-testing.yaml +107 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/pseudo-localization.yaml +86 -0
- package/dist/bin/harness.js +64 -4
- package/dist/{chunk-GA6GN5J2.js → chunk-E2RTDBMG.js} +2263 -41
- package/dist/{chunk-FFIX3QVG.js → chunk-KJANDVVC.js} +141 -49
- package/dist/{chunk-4WUGOJQ7.js → chunk-RT2LYQHF.js} +1 -1
- package/dist/{dist-C4J67MPP.js → dist-CCM3L3UE.js} +95 -1
- package/dist/{dist-N4D4QWFV.js → dist-K6KTTN3I.js} +4 -4
- package/dist/index.d.ts +187 -7
- package/dist/index.js +7 -3
- package/dist/validate-cross-check-ZGKFQY57.js +7 -0
- package/package.json +9 -9
- 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-WGXQ7K62.js +0 -7
|
@@ -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: []
|
|
@@ -12,8 +12,23 @@
|
|
|
12
12
|
|
|
13
13
|
## Prerequisites
|
|
14
14
|
|
|
15
|
-
A knowledge graph
|
|
16
|
-
|
|
15
|
+
A knowledge graph at `.harness/graph/` enables full analysis. If no graph exists,
|
|
16
|
+
the skill uses static analysis fallbacks (see Graph Availability section).
|
|
17
|
+
Run `harness scan` to enable graph-enhanced analysis.
|
|
18
|
+
|
|
19
|
+
### Graph Availability
|
|
20
|
+
|
|
21
|
+
Before starting, check if `.harness/graph/graph.json` exists.
|
|
22
|
+
|
|
23
|
+
**If graph exists:** Check staleness — compare `.harness/graph/metadata.json`
|
|
24
|
+
scanTimestamp against `git log -1 --format=%ct` (latest commit timestamp).
|
|
25
|
+
If graph is more than 2 commits behind (`git log --oneline <scanTimestamp>..HEAD | wc -l`),
|
|
26
|
+
run `harness scan` to refresh before proceeding. (Staleness sensitivity: **High**)
|
|
27
|
+
|
|
28
|
+
**If graph exists and is fresh (or refreshed):** Use graph tools as primary strategy.
|
|
29
|
+
|
|
30
|
+
**If no graph exists:** Output "Running without graph (run `harness scan` to
|
|
31
|
+
enable full analysis)" and use fallback strategies for all subsequent steps.
|
|
17
32
|
|
|
18
33
|
## Process
|
|
19
34
|
|
|
@@ -50,6 +65,20 @@ Query the graph for five key structural indicators:
|
|
|
50
65
|
|
|
51
66
|
5. **Module cohesion**: For each module (directory), count internal vs external edges. Low internal cohesion (many external edges, few internal) suggests misplaced code.
|
|
52
67
|
|
|
68
|
+
#### Fallback (without graph)
|
|
69
|
+
|
|
70
|
+
When no graph is available, use static analysis to approximate structural metrics:
|
|
71
|
+
|
|
72
|
+
1. **Build adjacency list**: Grep all source files for `import`/`require` statements. Parse each to extract the imported path. Build an adjacency list mapping each file to its imports.
|
|
73
|
+
2. **Hub detection**: From the adjacency list, count inbound edges per file. Files with >10 importers are hubs.
|
|
74
|
+
3. **Orphan detection**: Files with zero inbound edges that are not entry points (not `index.*`, not in `package.json` main/exports). Use glob to find all source files, then subtract those that appear as import targets.
|
|
75
|
+
4. **Cycle detection**: Run DFS on the adjacency list. When a back-edge is found, report the cycle path.
|
|
76
|
+
5. **Deep chain detection**: From entry points, DFS to find the longest import chain. Report chains exceeding 7 hops.
|
|
77
|
+
6. **Module cohesion (approximate)**: For each directory, count imports that stay within the directory (internal) vs imports that leave it (external). Cohesion = internal / (internal + external).
|
|
78
|
+
7. **Run `check_dependencies` CLI** — this works without a graph and can detect layer violations.
|
|
79
|
+
|
|
80
|
+
> Fallback completeness: ~60% — cannot compute transitive depth beyond what import parsing reveals; coupling metrics are approximate.
|
|
81
|
+
|
|
53
82
|
### Phase 2: SCORE — Calculate Health Score
|
|
54
83
|
|
|
55
84
|
Compute a weighted health score (0-100):
|
|
@@ -104,7 +133,7 @@ For each problem found, generate a specific, actionable recommendation:
|
|
|
104
133
|
|
|
105
134
|
## Harness Integration
|
|
106
135
|
|
|
107
|
-
- **`harness scan`** —
|
|
136
|
+
- **`harness scan`** — Recommended before this skill for full graph-enhanced analysis. If graph is missing, skill uses static analysis fallbacks.
|
|
108
137
|
- **`harness validate`** — Run after acting on findings to verify project health.
|
|
109
138
|
- **Graph tools** — This skill uses `query_graph`, `get_relationships`, and `check_dependencies` MCP tools.
|
|
110
139
|
|
|
@@ -114,7 +143,7 @@ For each problem found, generate a specific, actionable recommendation:
|
|
|
114
143
|
- All five structural metrics gathered (hubs, orphans, cycles, deep chains, cohesion)
|
|
115
144
|
- Recommendations are specific and actionable (name files, suggest concrete fixes)
|
|
116
145
|
- Report follows the structured output format
|
|
117
|
-
- All findings are backed by graph query evidence
|
|
146
|
+
- All findings are backed by graph query evidence (with graph) or systematic static analysis (without graph)
|
|
118
147
|
|
|
119
148
|
## Examples
|
|
120
149
|
|
|
@@ -141,8 +170,8 @@ Output:
|
|
|
141
170
|
|
|
142
171
|
## Gates
|
|
143
172
|
|
|
144
|
-
- **
|
|
145
|
-
- **
|
|
173
|
+
- **Graph preferred, fallback available.** If no graph exists, use fallback strategies (import parsing, DFS cycle detection, hub/orphan identification). Do not stop — produce the best analysis possible.
|
|
174
|
+
- **Systematic analysis required.** All metrics must come from graph queries (with graph) or systematic import parsing (without graph). Do not guess — parse actual import statements.
|
|
146
175
|
|
|
147
176
|
## Escalation
|
|
148
177
|
|