@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.
Files changed (187) hide show
  1. package/dist/agents/personas/documentation-maintainer.yaml +3 -1
  2. package/dist/agents/personas/performance-guardian.yaml +23 -0
  3. package/dist/agents/skills/claude-code/align-documentation/SKILL.md +13 -0
  4. package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +25 -1
  5. package/dist/agents/skills/claude-code/cleanup-dead-code/skill.yaml +5 -2
  6. package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +12 -0
  7. package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +48 -1
  8. package/dist/agents/skills/claude-code/enforce-architecture/skill.yaml +5 -2
  9. package/dist/agents/skills/claude-code/harness-accessibility/SKILL.md +7 -0
  10. package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +11 -3
  11. package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +81 -11
  12. package/dist/agents/skills/claude-code/harness-brainstorming/skill.yaml +2 -0
  13. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +487 -234
  14. package/dist/agents/skills/claude-code/harness-code-review/skill.yaml +15 -2
  15. package/dist/agents/skills/claude-code/harness-codebase-cleanup/SKILL.md +226 -0
  16. package/dist/agents/skills/claude-code/harness-codebase-cleanup/skill.yaml +64 -0
  17. package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +35 -6
  18. package/dist/agents/skills/claude-code/harness-docs-pipeline/SKILL.md +460 -0
  19. package/dist/agents/skills/claude-code/harness-docs-pipeline/skill.yaml +69 -0
  20. package/dist/agents/skills/claude-code/harness-execution/SKILL.md +73 -8
  21. package/dist/agents/skills/claude-code/harness-execution/skill.yaml +1 -0
  22. package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +32 -6
  23. package/dist/agents/skills/claude-code/harness-i18n/SKILL.md +484 -0
  24. package/dist/agents/skills/claude-code/harness-i18n/skill.yaml +54 -0
  25. package/dist/agents/skills/claude-code/harness-i18n-process/SKILL.md +388 -0
  26. package/dist/agents/skills/claude-code/harness-i18n-process/skill.yaml +43 -0
  27. package/dist/agents/skills/claude-code/harness-i18n-workflow/SKILL.md +512 -0
  28. package/dist/agents/skills/claude-code/harness-i18n-workflow/skill.yaml +53 -0
  29. package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +35 -6
  30. package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +17 -1
  31. package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +46 -5
  32. package/dist/agents/skills/claude-code/harness-perf/SKILL.md +37 -8
  33. package/dist/agents/skills/claude-code/harness-perf/skill.yaml +3 -0
  34. package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +17 -4
  35. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +59 -5
  36. package/dist/agents/skills/claude-code/harness-planning/skill.yaml +2 -0
  37. package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +16 -0
  38. package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +561 -0
  39. package/dist/agents/skills/claude-code/harness-roadmap/skill.yaml +43 -0
  40. package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +36 -2
  41. package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +8 -6
  42. package/dist/agents/skills/claude-code/harness-soundness-review/SKILL.md +1267 -0
  43. package/dist/agents/skills/claude-code/harness-soundness-review/skill.yaml +48 -0
  44. package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +35 -6
  45. package/dist/agents/skills/claude-code/harness-verification/SKILL.md +66 -0
  46. package/dist/agents/skills/claude-code/harness-verification/skill.yaml +1 -0
  47. package/dist/agents/skills/claude-code/harness-verify/SKILL.md +11 -0
  48. package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +15 -1
  49. package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +12 -0
  50. package/dist/agents/skills/gemini-cli/add-harness-component/SKILL.md +192 -0
  51. package/dist/agents/skills/gemini-cli/add-harness-component/skill.yaml +32 -0
  52. package/dist/agents/skills/gemini-cli/align-documentation/SKILL.md +213 -0
  53. package/dist/agents/skills/gemini-cli/align-documentation/skill.yaml +31 -0
  54. package/dist/agents/skills/gemini-cli/check-mechanical-constraints/SKILL.md +191 -0
  55. package/dist/agents/skills/gemini-cli/check-mechanical-constraints/skill.yaml +32 -0
  56. package/dist/agents/skills/gemini-cli/cleanup-dead-code/SKILL.md +245 -0
  57. package/dist/agents/skills/gemini-cli/cleanup-dead-code/skill.yaml +33 -0
  58. package/dist/agents/skills/gemini-cli/detect-doc-drift/SKILL.md +179 -0
  59. package/dist/agents/skills/gemini-cli/detect-doc-drift/skill.yaml +30 -0
  60. package/dist/agents/skills/gemini-cli/enforce-architecture/SKILL.md +240 -0
  61. package/dist/agents/skills/gemini-cli/enforce-architecture/skill.yaml +34 -0
  62. package/dist/agents/skills/gemini-cli/harness-accessibility/SKILL.md +7 -0
  63. package/dist/agents/skills/gemini-cli/harness-architecture-advisor/SKILL.md +397 -0
  64. package/dist/agents/skills/gemini-cli/harness-architecture-advisor/skill.yaml +48 -0
  65. package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +11 -3
  66. package/dist/agents/skills/gemini-cli/harness-brainstorming/SKILL.md +317 -0
  67. package/dist/agents/skills/gemini-cli/harness-brainstorming/skill.yaml +49 -0
  68. package/dist/agents/skills/gemini-cli/harness-code-review/SKILL.md +681 -0
  69. package/dist/agents/skills/gemini-cli/harness-code-review/skill.yaml +45 -0
  70. package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/SKILL.md +226 -0
  71. package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/skill.yaml +64 -0
  72. package/dist/agents/skills/gemini-cli/harness-debugging/SKILL.md +366 -0
  73. package/dist/agents/skills/gemini-cli/harness-debugging/skill.yaml +47 -0
  74. package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +35 -6
  75. package/dist/agents/skills/gemini-cli/harness-diagnostics/SKILL.md +318 -0
  76. package/dist/agents/skills/gemini-cli/harness-diagnostics/skill.yaml +50 -0
  77. package/dist/agents/skills/gemini-cli/harness-docs-pipeline/SKILL.md +460 -0
  78. package/dist/agents/skills/gemini-cli/harness-docs-pipeline/skill.yaml +69 -0
  79. package/dist/agents/skills/gemini-cli/harness-execution/SKILL.md +382 -0
  80. package/dist/agents/skills/gemini-cli/harness-execution/skill.yaml +51 -0
  81. package/dist/agents/skills/gemini-cli/harness-git-workflow/SKILL.md +268 -0
  82. package/dist/agents/skills/gemini-cli/harness-git-workflow/skill.yaml +31 -0
  83. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +32 -6
  84. package/dist/agents/skills/gemini-cli/harness-i18n/SKILL.md +484 -0
  85. package/dist/agents/skills/gemini-cli/harness-i18n/skill.yaml +54 -0
  86. package/dist/agents/skills/gemini-cli/harness-i18n-process/SKILL.md +388 -0
  87. package/dist/agents/skills/gemini-cli/harness-i18n-process/skill.yaml +43 -0
  88. package/dist/agents/skills/gemini-cli/harness-i18n-workflow/SKILL.md +512 -0
  89. package/dist/agents/skills/gemini-cli/harness-i18n-workflow/skill.yaml +53 -0
  90. package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +35 -6
  91. package/dist/agents/skills/gemini-cli/harness-integrity/SKILL.md +167 -0
  92. package/dist/agents/skills/gemini-cli/harness-integrity/skill.yaml +47 -0
  93. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +46 -5
  94. package/dist/agents/skills/gemini-cli/harness-onboarding/SKILL.md +288 -0
  95. package/dist/agents/skills/gemini-cli/harness-onboarding/skill.yaml +30 -0
  96. package/dist/agents/skills/gemini-cli/harness-parallel-agents/SKILL.md +171 -0
  97. package/dist/agents/skills/gemini-cli/harness-parallel-agents/skill.yaml +33 -0
  98. package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +37 -8
  99. package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +3 -0
  100. package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +17 -4
  101. package/dist/agents/skills/gemini-cli/harness-planning/SKILL.md +389 -0
  102. package/dist/agents/skills/gemini-cli/harness-planning/skill.yaml +49 -0
  103. package/dist/agents/skills/gemini-cli/harness-pre-commit-review/SKILL.md +262 -0
  104. package/dist/agents/skills/gemini-cli/harness-pre-commit-review/skill.yaml +33 -0
  105. package/dist/agents/skills/gemini-cli/harness-refactoring/SKILL.md +169 -0
  106. package/dist/agents/skills/gemini-cli/harness-refactoring/skill.yaml +33 -0
  107. package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +16 -0
  108. package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +561 -0
  109. package/dist/agents/skills/gemini-cli/harness-roadmap/skill.yaml +43 -0
  110. package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +8 -6
  111. package/dist/agents/skills/gemini-cli/harness-skill-authoring/SKILL.md +292 -0
  112. package/dist/agents/skills/gemini-cli/harness-skill-authoring/skill.yaml +32 -0
  113. package/dist/agents/skills/gemini-cli/harness-soundness-review/SKILL.md +1267 -0
  114. package/dist/agents/skills/gemini-cli/harness-soundness-review/skill.yaml +48 -0
  115. package/dist/agents/skills/gemini-cli/harness-state-management/SKILL.md +309 -0
  116. package/dist/agents/skills/gemini-cli/harness-state-management/skill.yaml +32 -0
  117. package/dist/agents/skills/gemini-cli/harness-tdd/SKILL.md +177 -0
  118. package/dist/agents/skills/gemini-cli/harness-tdd/skill.yaml +48 -0
  119. package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +35 -6
  120. package/dist/agents/skills/gemini-cli/harness-verification/SKILL.md +328 -0
  121. package/dist/agents/skills/gemini-cli/harness-verification/skill.yaml +42 -0
  122. package/dist/agents/skills/gemini-cli/harness-verify/SKILL.md +159 -0
  123. package/dist/agents/skills/gemini-cli/harness-verify/skill.yaml +40 -0
  124. package/dist/agents/skills/gemini-cli/initialize-harness-project/SKILL.md +224 -0
  125. package/dist/agents/skills/gemini-cli/initialize-harness-project/skill.yaml +31 -0
  126. package/dist/agents/skills/gemini-cli/validate-context-engineering/SKILL.md +150 -0
  127. package/dist/agents/skills/gemini-cli/validate-context-engineering/skill.yaml +31 -0
  128. package/dist/agents/skills/shared/i18n-knowledge/accessibility/intersection.yaml +142 -0
  129. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/encoding.yaml +67 -0
  130. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/formatting.yaml +106 -0
  131. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/layout.yaml +80 -0
  132. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/pluralization.yaml +80 -0
  133. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/string-handling.yaml +106 -0
  134. package/dist/agents/skills/shared/i18n-knowledge/frameworks/android-resources.yaml +47 -0
  135. package/dist/agents/skills/shared/i18n-knowledge/frameworks/apple-strings.yaml +47 -0
  136. package/dist/agents/skills/shared/i18n-knowledge/frameworks/backend-patterns.yaml +50 -0
  137. package/dist/agents/skills/shared/i18n-knowledge/frameworks/flutter-intl.yaml +47 -0
  138. package/dist/agents/skills/shared/i18n-knowledge/frameworks/i18next.yaml +47 -0
  139. package/dist/agents/skills/shared/i18n-knowledge/frameworks/react-intl.yaml +47 -0
  140. package/dist/agents/skills/shared/i18n-knowledge/frameworks/vue-i18n.yaml +47 -0
  141. package/dist/agents/skills/shared/i18n-knowledge/industries/ecommerce.yaml +66 -0
  142. package/dist/agents/skills/shared/i18n-knowledge/industries/fintech.yaml +66 -0
  143. package/dist/agents/skills/shared/i18n-knowledge/industries/gaming.yaml +69 -0
  144. package/dist/agents/skills/shared/i18n-knowledge/industries/healthcare.yaml +66 -0
  145. package/dist/agents/skills/shared/i18n-knowledge/industries/legal.yaml +66 -0
  146. package/dist/agents/skills/shared/i18n-knowledge/locales/ar.yaml +41 -0
  147. package/dist/agents/skills/shared/i18n-knowledge/locales/de.yaml +35 -0
  148. package/dist/agents/skills/shared/i18n-knowledge/locales/en.yaml +32 -0
  149. package/dist/agents/skills/shared/i18n-knowledge/locales/es.yaml +35 -0
  150. package/dist/agents/skills/shared/i18n-knowledge/locales/fi.yaml +35 -0
  151. package/dist/agents/skills/shared/i18n-knowledge/locales/fr.yaml +35 -0
  152. package/dist/agents/skills/shared/i18n-knowledge/locales/he.yaml +41 -0
  153. package/dist/agents/skills/shared/i18n-knowledge/locales/hi.yaml +35 -0
  154. package/dist/agents/skills/shared/i18n-knowledge/locales/it.yaml +32 -0
  155. package/dist/agents/skills/shared/i18n-knowledge/locales/ja.yaml +38 -0
  156. package/dist/agents/skills/shared/i18n-knowledge/locales/ko.yaml +38 -0
  157. package/dist/agents/skills/shared/i18n-knowledge/locales/nl.yaml +32 -0
  158. package/dist/agents/skills/shared/i18n-knowledge/locales/pl.yaml +35 -0
  159. package/dist/agents/skills/shared/i18n-knowledge/locales/pt.yaml +32 -0
  160. package/dist/agents/skills/shared/i18n-knowledge/locales/ru.yaml +35 -0
  161. package/dist/agents/skills/shared/i18n-knowledge/locales/sv.yaml +32 -0
  162. package/dist/agents/skills/shared/i18n-knowledge/locales/th.yaml +35 -0
  163. package/dist/agents/skills/shared/i18n-knowledge/locales/tr.yaml +35 -0
  164. package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hans.yaml +38 -0
  165. package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hant.yaml +35 -0
  166. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/i18next-mcp.yaml +56 -0
  167. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lingo-dev.yaml +56 -0
  168. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lokalise.yaml +60 -0
  169. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/tolgee.yaml +60 -0
  170. package/dist/agents/skills/shared/i18n-knowledge/testing/locale-testing.yaml +107 -0
  171. package/dist/agents/skills/shared/i18n-knowledge/testing/pseudo-localization.yaml +86 -0
  172. package/dist/bin/harness.js +64 -4
  173. package/dist/{chunk-GA6GN5J2.js → chunk-E2RTDBMG.js} +2263 -41
  174. package/dist/{chunk-FFIX3QVG.js → chunk-KJANDVVC.js} +141 -49
  175. package/dist/{chunk-4WUGOJQ7.js → chunk-RT2LYQHF.js} +1 -1
  176. package/dist/{dist-C4J67MPP.js → dist-CCM3L3UE.js} +95 -1
  177. package/dist/{dist-N4D4QWFV.js → dist-K6KTTN3I.js} +4 -4
  178. package/dist/index.d.ts +187 -7
  179. package/dist/index.js +7 -3
  180. package/dist/validate-cross-check-ZGKFQY57.js +7 -0
  181. package/package.json +9 -9
  182. package/dist/agents/skills/node_modules/.bin/glob +0 -17
  183. package/dist/agents/skills/node_modules/.bin/vitest +0 -17
  184. package/dist/agents/skills/node_modules/.bin/yaml +0 -17
  185. package/dist/templates/advanced/docs/specs/.gitkeep +0 -0
  186. package/dist/templates/intermediate/docs/specs/.gitkeep +0 -0
  187. package/dist/validate-cross-check-WGXQ7K62.js +0 -7
@@ -1,6 +1,6 @@
1
1
  name: harness-code-review
2
- version: "1.0.0"
3
- description: Structured code review with automated harness checks
2
+ version: "2.0.0"
3
+ description: Multi-phase code review pipeline with mechanical checks, graph-scoped context, and parallel review agents
4
4
  cognitive_mode: adversarial-reviewer
5
5
  triggers:
6
6
  - manual
@@ -14,12 +14,25 @@ tools:
14
14
  - Read
15
15
  - Glob
16
16
  - Grep
17
+ - emit_interaction
17
18
  cli:
18
19
  command: harness skill run harness-code-review
19
20
  args:
20
21
  - name: path
21
22
  description: Project root path
22
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
23
36
  mcp:
24
37
  tool: run_skill
25
38
  input:
@@ -0,0 +1,226 @@
1
+ # Harness Codebase Cleanup
2
+
3
+ > Orchestrate dead code removal and architecture violation fixes with a shared convergence loop. Catches cross-concern cascades that individual skills miss.
4
+
5
+ ## When to Use
6
+
7
+ - After a major refactoring or feature removal when both dead code and architecture violations are likely
8
+ - As a periodic comprehensive codebase hygiene task
9
+ - When `cleanup-dead-code` or `enforce-architecture` individually are not catching cascading issues
10
+ - When you want hotspot-aware safety classification
11
+ - NOT for quick single-concern checks -- use `cleanup-dead-code` or `enforce-architecture` directly
12
+ - NOT when tests are failing -- fix tests first
13
+ - NOT during active feature development
14
+
15
+ ## Flags
16
+
17
+ | Flag | Effect |
18
+ | --------------------- | ----------------------------------------------------------------- |
19
+ | `--fix` | Enable convergence-based auto-fix (default: detect + report only) |
20
+ | `--dead-code-only` | Skip architecture checks |
21
+ | `--architecture-only` | Skip dead code checks |
22
+ | `--dry-run` | Show what would be fixed without applying |
23
+ | `--ci` | Non-interactive: apply safe fixes only, report everything else |
24
+
25
+ ## Process
26
+
27
+ ### Phase 1: CONTEXT -- Build Hotspot Map
28
+
29
+ 1. **Run hotspot detection** via `harness skill run harness-hotspot-detector` or equivalent git log analysis:
30
+ ```bash
31
+ git log --format=format: --name-only --since="6 months ago" | sort | uniq -c | sort -rn | head -50
32
+ ```
33
+ 2. **Build churn map.** Parse output into a `file -> commit count` mapping.
34
+ 3. **Compute top 10% threshold.** Sort all files by commit count. The file at the 90th percentile defines the threshold. Files above this threshold are "high churn."
35
+ 4. **Store as HotspotContext** for use in Phase 3 (CLASSIFY).
36
+
37
+ ### Phase 2: DETECT -- Run Both Concerns in Parallel
38
+
39
+ 1. **Dead code detection** (skip if `--architecture-only`):
40
+ - Run `harness cleanup --type dead-code --json`
41
+ - Or use the `detect_entropy` MCP tool with `type: 'dead-code'`
42
+ - Captures: dead files, dead exports, unused imports, dead internals, commented-out code blocks, orphaned dependencies
43
+
44
+ 2. **Architecture detection** (skip if `--dead-code-only`):
45
+ - Run `harness check-deps --json`
46
+ - Captures: layer violations, forbidden imports, circular dependencies, import ordering issues
47
+
48
+ 3. **Merge findings.** Convert all raw findings into `CleanupFinding` objects using `classifyFinding()`. This normalizes both concerns into a shared schema.
49
+
50
+ ### Phase 3: CLASSIFY -- Safety Classification and Dedup
51
+
52
+ 1. **Apply safety classification.** Each `CleanupFinding` already has a safety level from `classifyFinding()`. Review the classification rules:
53
+
54
+ **Dead code safety:**
55
+
56
+ | Finding | Safety | Condition |
57
+ | ------------------------- | ------------- | ------------------------------------------- |
58
+ | Dead files | Safe | Not entry point, no side effects |
59
+ | Unused imports | Safe | Zero references |
60
+ | Dead exports (non-public) | Safe | Zero importers, not in package entry point |
61
+ | Dead exports (public API) | Unsafe | In package entry point or published package |
62
+ | Commented-out code | Safe | Always (code is in git history) |
63
+ | Orphaned npm deps | Probably safe | Needs install + test verification |
64
+ | Dead internals | Unsafe | Cannot reliably determine all callers |
65
+
66
+ **Architecture safety:**
67
+
68
+ | Violation | Safety | Condition |
69
+ | ----------------------------------- | ------------- | -------------------------- |
70
+ | Import ordering | Safe | Mechanical reorder |
71
+ | Forbidden import (with alternative) | Probably safe | 1:1 replacement configured |
72
+ | Forbidden import (no alternative) | Unsafe | Requires restructuring |
73
+ | Design token (unambiguous) | Probably safe | Single token match |
74
+ | Design token (ambiguous) | Unsafe | Multiple candidates |
75
+ | Upward dependency | Unsafe | Always |
76
+ | Skip-layer dependency | Unsafe | Always |
77
+ | Circular dependency | Unsafe | Always |
78
+
79
+ 2. **Apply hotspot downgrade.** For each finding, check if the file is in the top 10% by churn (from Phase 1 HotspotContext). If so, downgrade `safe` to `probably-safe`. Do not downgrade `unsafe` findings.
80
+
81
+ 3. **Cross-concern dedup.** Call `deduplicateFindings()` to merge overlapping findings:
82
+ - A dead import from a forbidden layer = one finding (dead-code concern, noting architecture overlap)
83
+ - A dead file that has architecture violations = one finding (dead-code, noting violations resolved by deletion)
84
+
85
+ ### Phase 4: FIX -- Convergence Loop
86
+
87
+ **Only runs when `--fix` flag is set.** Without `--fix`, skip to Phase 5 (REPORT).
88
+
89
+ ```
90
+ findings = classified findings from Phase 3
91
+ previousCount = findings.length
92
+ iteration = 0
93
+
94
+ while iteration < 5:
95
+ iteration++
96
+
97
+ # Batch 1: Apply safe fixes silently
98
+ safeFixes = findings.filter(f => f.safety === 'safe')
99
+ apply(safeFixes)
100
+
101
+ # Batch 2: Present probably-safe fixes
102
+ if --ci mode:
103
+ skip probably-safe fixes (report only)
104
+ else:
105
+ probablySafeFixes = findings.filter(f => f.safety === 'probably-safe')
106
+ presentAsDiffs(probablySafeFixes)
107
+ apply(approved fixes)
108
+
109
+ # Verify: lint + typecheck + test
110
+ verifyResult = run("pnpm lint && pnpm tsc --noEmit && pnpm test")
111
+
112
+ if verifyResult.failed:
113
+ revertBatch()
114
+ reclassify failed fixes as unsafe
115
+ continue
116
+
117
+ # Re-detect both concerns
118
+ newFindings = runDetection() # Phase 2 again
119
+ newFindings = classify(newFindings) # Phase 3 again
120
+
121
+ if newFindings.length >= previousCount:
122
+ break # No progress, stop
123
+
124
+ previousCount = newFindings.length
125
+ findings = newFindings
126
+ ```
127
+
128
+ **Verification gate:** Every fix batch must pass lint + typecheck + test. If verification fails:
129
+
130
+ 1. Revert the entire batch (use git: `git checkout -- .`)
131
+ 2. Reclassify all findings in the batch as `unsafe`
132
+ 3. Continue the loop with remaining findings
133
+
134
+ **Cross-concern cascade examples:**
135
+
136
+ - Dead import from forbidden layer: removing the dead import also resolves the architecture violation. Single fix, both resolved.
137
+ - Architecture fix creates dead code: replacing a forbidden import makes the old module's export dead. Next detect cycle catches it.
138
+ - Dead file resolves multiple violations: deleting a dead file that imports from wrong layers resolves those violations too.
139
+
140
+ ### Phase 5: REPORT -- Actionable Output
141
+
142
+ Generate a structured report with two sections:
143
+
144
+ **1. Fixes Applied:**
145
+ For each fix that was applied:
146
+
147
+ - File and line
148
+ - What was fixed (finding type and description)
149
+ - What action was taken (delete, replace, reorder)
150
+ - Verification status (pass/fail)
151
+
152
+ **2. Remaining Findings (requires human action):**
153
+ For each unsafe finding that was not auto-fixed:
154
+
155
+ - **What is wrong:** The finding type, file, line, and description
156
+ - **Why it cannot be auto-fixed:** The safety reason and classification logic
157
+ - **Suggested approach:** Concrete next steps for manual resolution
158
+
159
+ Example report output:
160
+
161
+ ```
162
+ === HARNESS CODEBASE CLEANUP REPORT ===
163
+
164
+ Fixes applied: 12
165
+ - 5 unused imports removed (safe)
166
+ - 3 dead exports de-exported (safe)
167
+ - 2 commented-out code blocks deleted (safe)
168
+ - 1 forbidden import replaced (probably-safe, approved)
169
+ - 1 orphaned dependency removed (probably-safe, approved)
170
+
171
+ Convergence: 3 iterations, 12 → 8 → 3 → 3 (stopped)
172
+
173
+ Remaining findings: 3 (require human action)
174
+
175
+ 1. UNSAFE: Circular dependency
176
+ File: src/services/order-service.ts <-> src/services/inventory-service.ts
177
+ Why: Circular dependencies require structural refactoring
178
+ Suggested: Extract shared logic into src/services/stock-calculator.ts
179
+
180
+ 2. UNSAFE: Dead internal function
181
+ File: src/utils/legacy.ts:45 — processLegacyFormat()
182
+ Why: Cannot reliably determine all callers (possible dynamic usage)
183
+ Suggested: Search for string references, check config files, then delete if confirmed unused
184
+
185
+ 3. UNSAFE: Public API dead export
186
+ File: packages/core/src/index.ts — legacyHelper
187
+ Why: Export is in package entry point; external consumers may depend on it
188
+ Suggested: Deprecate with @deprecated JSDoc tag, remove in next major version
189
+ ```
190
+
191
+ ## Examples
192
+
193
+ ### Example: Post-Refactoring Cleanup
194
+
195
+ After removing the `legacy-auth` module:
196
+
197
+ 1. **Phase 1 (CONTEXT):** Hotspot analysis shows `src/services/auth.ts` has 42 commits (top 5%).
198
+ 2. **Phase 2 (DETECT):** Dead code detects 3 dead exports in `src/utils/token.ts` (were only used by legacy-auth). Architecture detects 1 forbidden import in `src/services/session.ts` (still importing from removed module's location).
199
+ 3. **Phase 3 (CLASSIFY):** Dead exports classified as `safe` but downgraded to `probably-safe` because `token.ts` is in a high-churn file. Forbidden import classified as `unsafe` (no alternative configured).
200
+ 4. **Phase 4 (FIX):** First iteration removes 3 dead exports (approved as probably-safe). Re-detect finds `token.ts` now has zero exports and becomes a dead file. Second iteration deletes the dead file. Convergence stops -- the forbidden import requires manual restructuring.
201
+ 5. **Phase 5 (REPORT):** 4 fixes applied (3 dead exports + 1 dead file), 1 remaining finding (forbidden import requiring restructuring).
202
+
203
+ ## Harness Integration
204
+
205
+ - **`harness cleanup --type dead-code --json`** -- Dead code detection input
206
+ - **`harness check-deps --json`** -- Architecture violation detection input
207
+ - **`harness skill run harness-hotspot-detector`** -- Hotspot context for safety classification
208
+ - **`apply_fixes` MCP tool** -- Applies safe fixes via the MCP server
209
+ - **`harness validate`** -- Final validation after all fixes
210
+ - **`harness check-deps`** -- Final architecture check after all fixes
211
+
212
+ ## Success Criteria
213
+
214
+ - All safe fixes are applied without test failures
215
+ - Probably-safe fixes are presented as diffs for approval (or skipped in CI mode)
216
+ - Unsafe findings are never auto-fixed
217
+ - Convergence loop catches cross-concern cascades
218
+ - Report includes actionable guidance for every remaining finding
219
+ - `harness validate` passes after cleanup
220
+
221
+ ## Escalation
222
+
223
+ - **When convergence loop does not converge after 5 iterations:** The codebase has deeply tangled issues. Stop and report all remaining findings. Consider breaking the cleanup into focused sessions.
224
+ - **When a safe fix causes test failures:** The classification was wrong. Revert, reclassify as unsafe, and investigate the hidden dependency. Document the false positive for future improvement.
225
+ - **When the hotspot detector is unavailable:** Skip the hotspot downgrade. All safety classifications use their base level without churn context.
226
+ - **When dead code and architecture fixes conflict:** The convergence loop handles this naturally. If removing dead code creates an architecture issue (rare), the next detection cycle catches it.
@@ -0,0 +1,64 @@
1
+ name: harness-codebase-cleanup
2
+ version: "1.0.0"
3
+ description: Orchestrate dead code removal and architecture violation fixes with shared convergence loop
4
+ cognitive_mode: systematic-orchestrator
5
+ triggers:
6
+ - manual
7
+ platforms:
8
+ - claude-code
9
+ - gemini-cli
10
+ tools:
11
+ - Bash
12
+ - Read
13
+ - Glob
14
+ - Grep
15
+ cli:
16
+ command: harness skill run harness-codebase-cleanup
17
+ args:
18
+ - name: path
19
+ description: Project root path
20
+ required: false
21
+ - name: fix
22
+ description: Enable convergence-based auto-fix (default detect+report only)
23
+ required: false
24
+ - name: dead-code-only
25
+ description: Skip architecture checks
26
+ required: false
27
+ - name: architecture-only
28
+ description: Skip dead code checks
29
+ required: false
30
+ - name: dry-run
31
+ description: Show what would be fixed without applying
32
+ required: false
33
+ - name: ci
34
+ description: Non-interactive mode (safe fixes only, report everything else)
35
+ required: false
36
+ mcp:
37
+ tool: run_skill
38
+ input:
39
+ skill: harness-codebase-cleanup
40
+ path: string
41
+ type: flexible
42
+ phases:
43
+ - name: context
44
+ description: Run hotspot detection, build churn map
45
+ required: true
46
+ - name: detect
47
+ description: Run dead code and architecture detection in parallel
48
+ required: true
49
+ - name: classify
50
+ description: Classify findings, apply hotspot downgrade, cross-concern dedup
51
+ required: true
52
+ - name: fix
53
+ description: Convergence loop - apply safe fixes, verify, re-detect
54
+ required: false
55
+ - name: report
56
+ description: Generate actionable report of fixes applied and remaining findings
57
+ required: true
58
+ state:
59
+ persistent: false
60
+ files: []
61
+ depends_on:
62
+ - cleanup-dead-code
63
+ - enforce-architecture
64
+ - harness-hotspot-detector
@@ -12,8 +12,23 @@
12
12
 
13
13
  ## Prerequisites
14
14
 
15
- A knowledge graph must exist at `.harness/graph/`. Run `harness scan` if no graph is available.
16
- If the graph exists but code has changed since the last scan, re-run `harness scan` first — stale graph data leads to inaccurate results.
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`** — Must run before this skill to ensure graph is current.
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, not heuristics
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
- - **No analysis without graph.** If no graph exists, stop and instruct to run `harness scan`.
145
- - **No guessing.** All metrics must come from graph queries, not heuristics.
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