@harness-engineering/cli 1.4.0 → 1.6.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 (82) hide show
  1. package/dist/agents/personas/architecture-enforcer.yaml +1 -0
  2. package/dist/agents/personas/code-reviewer.yaml +43 -0
  3. package/dist/agents/personas/codebase-health-analyst.yaml +32 -0
  4. package/dist/agents/personas/documentation-maintainer.yaml +2 -0
  5. package/dist/agents/personas/entropy-cleaner.yaml +3 -0
  6. package/dist/agents/personas/graph-maintainer.yaml +27 -0
  7. package/dist/agents/personas/parallel-coordinator.yaml +29 -0
  8. package/dist/agents/personas/performance-guardian.yaml +26 -0
  9. package/dist/agents/personas/security-reviewer.yaml +35 -0
  10. package/dist/agents/personas/task-executor.yaml +41 -0
  11. package/dist/agents/skills/README.md +8 -0
  12. package/dist/agents/skills/claude-code/add-harness-component/SKILL.md +10 -0
  13. package/dist/agents/skills/claude-code/align-documentation/SKILL.md +19 -0
  14. package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +19 -0
  15. package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +8 -0
  16. package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +9 -0
  17. package/dist/agents/skills/claude-code/harness-architecture-advisor/SKILL.md +9 -0
  18. package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +494 -0
  19. package/dist/agents/skills/claude-code/harness-autopilot/skill.yaml +52 -0
  20. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +25 -0
  21. package/dist/agents/skills/claude-code/harness-debugging/SKILL.md +10 -0
  22. package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +150 -0
  23. package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +41 -0
  24. package/dist/agents/skills/claude-code/harness-execution/SKILL.md +19 -0
  25. package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +135 -0
  26. package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +44 -0
  27. package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +139 -0
  28. package/dist/agents/skills/claude-code/harness-impact-analysis/skill.yaml +44 -0
  29. package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +20 -6
  30. package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +154 -0
  31. package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +49 -0
  32. package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +10 -0
  33. package/dist/agents/skills/claude-code/harness-parallel-agents/SKILL.md +9 -0
  34. package/dist/agents/skills/claude-code/harness-perf/SKILL.md +231 -0
  35. package/dist/agents/skills/claude-code/harness-perf/skill.yaml +47 -0
  36. package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +236 -0
  37. package/dist/agents/skills/claude-code/harness-perf-tdd/skill.yaml +47 -0
  38. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +9 -0
  39. package/dist/agents/skills/claude-code/harness-pre-commit-review/SKILL.md +33 -2
  40. package/dist/agents/skills/claude-code/harness-refactoring/SKILL.md +19 -0
  41. package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +657 -0
  42. package/dist/agents/skills/claude-code/harness-release-readiness/skill.yaml +57 -0
  43. package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +206 -0
  44. package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +50 -0
  45. package/dist/agents/skills/claude-code/harness-security-scan/SKILL.md +102 -0
  46. package/dist/agents/skills/claude-code/harness-security-scan/skill.yaml +41 -0
  47. package/dist/agents/skills/claude-code/harness-state-management/SKILL.md +22 -8
  48. package/dist/agents/skills/claude-code/harness-tdd/SKILL.md +10 -0
  49. package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +131 -0
  50. package/dist/agents/skills/claude-code/harness-test-advisor/skill.yaml +44 -0
  51. package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +10 -0
  52. package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +9 -0
  53. package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +494 -0
  54. package/dist/agents/skills/gemini-cli/harness-autopilot/skill.yaml +52 -0
  55. package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +150 -0
  56. package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +41 -0
  57. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +135 -0
  58. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +44 -0
  59. package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +139 -0
  60. package/dist/agents/skills/gemini-cli/harness-impact-analysis/skill.yaml +44 -0
  61. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +154 -0
  62. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +49 -0
  63. package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +231 -0
  64. package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +47 -0
  65. package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +236 -0
  66. package/dist/agents/skills/gemini-cli/harness-perf-tdd/skill.yaml +47 -0
  67. package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +657 -0
  68. package/dist/agents/skills/gemini-cli/harness-release-readiness/skill.yaml +57 -0
  69. package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +50 -0
  70. package/dist/agents/skills/gemini-cli/harness-security-scan/SKILL.md +102 -0
  71. package/dist/agents/skills/gemini-cli/harness-security-scan/skill.yaml +41 -0
  72. package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +131 -0
  73. package/dist/agents/skills/gemini-cli/harness-test-advisor/skill.yaml +44 -0
  74. package/dist/agents/skills/tests/platform-parity.test.ts +131 -0
  75. package/dist/agents/skills/tests/schema.ts +2 -0
  76. package/dist/bin/harness.js +2 -2
  77. package/dist/{chunk-EFZOLZFB.js → chunk-ACMDUQJG.js} +4 -2
  78. package/dist/{chunk-C3J2HW4Y.js → chunk-O6NEKDYP.js} +2002 -487
  79. package/dist/{create-skill-4GKJZB5R.js → create-skill-NZDLMMR6.js} +1 -1
  80. package/dist/index.d.ts +265 -143
  81. package/dist/index.js +30 -4
  82. package/package.json +3 -2
@@ -0,0 +1,150 @@
1
+ # Harness Dependency Health
2
+
3
+ > Analyze structural health of the codebase and surface problems before they become incidents.
4
+
5
+ ## When to Use
6
+
7
+ - Weekly scheduled health check on the codebase
8
+ - Before major refactoring — understand current structural health
9
+ - When onboarding to a new project — assess codebase quality
10
+ - NOT for checking layer violations (use enforce-architecture)
11
+ - NOT for finding dead code (use cleanup-dead-code)
12
+
13
+ ## Prerequisites
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.
17
+
18
+ ## Process
19
+
20
+ ### Phase 1: METRICS — Compute Graph Structural Metrics
21
+
22
+ Query the graph for five key structural indicators:
23
+
24
+ 1. **Hub detection**: Find nodes with high fan-in (>10 inbound `imports` edges).
25
+
26
+ ```
27
+ query_graph(rootNodeIds=[all file nodes], includeEdges=["imports"])
28
+ ```
29
+
30
+ Hubs are single points of failure — changes to them have outsized blast radius.
31
+
32
+ 2. **Orphan detection**: Find file nodes with zero inbound `imports` edges that are not entry points.
33
+
34
+ ```
35
+ get_relationships(nodeId=<file>, direction="inbound")
36
+ ```
37
+
38
+ Orphans may be dead code or missing from the module system.
39
+
40
+ 3. **Cycle detection**: Use `check_dependencies` to find circular import chains.
41
+ Cycles create fragile coupling — any change in the cycle affects all members.
42
+
43
+ 4. **Deep chain detection**: Find import chains longer than N hops (default: 7).
44
+
45
+ ```
46
+ query_graph(rootNodeIds=[entry points], maxDepth=10, includeEdges=["imports"])
47
+ ```
48
+
49
+ Deep chains are fragile — a change at the bottom propagates unpredictably.
50
+
51
+ 5. **Module cohesion**: For each module (directory), count internal vs external edges. Low internal cohesion (many external edges, few internal) suggests misplaced code.
52
+
53
+ ### Phase 2: SCORE — Calculate Health Score
54
+
55
+ Compute a weighted health score (0-100):
56
+
57
+ | Metric | Weight | Scoring |
58
+ | ----------------- | ------ | ----------------------------------------- |
59
+ | Hubs (>10 fan-in) | 25% | 0 hubs = 100, 1-3 = 70, 4-6 = 40, >6 = 10 |
60
+ | Orphans | 20% | 0 = 100, 1-5 = 80, 6-15 = 50, >15 = 20 |
61
+ | Cycles | 25% | 0 = 100, 1 = 60, 2-3 = 30, >3 = 0 |
62
+ | Deep chains (>7) | 15% | 0 = 100, 1-3 = 70, >3 = 30 |
63
+ | Cohesion (avg) | 15% | >0.7 = 100, 0.5-0.7 = 70, <0.5 = 30 |
64
+
65
+ **Grades**: A (90-100), B (75-89), C (60-74), D (40-59), F (<40)
66
+
67
+ ### Phase 3: RECOMMEND — Generate Recommendations
68
+
69
+ For each problem found, generate a specific, actionable recommendation:
70
+
71
+ - **Hubs**: "Split `src/utils/helpers.ts` (14 importers) into domain-specific utilities"
72
+ - **Orphans**: "Remove `src/legacy/old-parser.ts` (0 importers, not an entry point)"
73
+ - **Cycles**: "Break cycle A→B→C→A by extracting shared types to `src/types/shared.ts`"
74
+ - **Deep chains**: "Consider flattening chain: entry→A→B→C→D→E→F→G (8 hops)"
75
+ - **Low cohesion**: "Module `src/services/` has 80% external edges — consider splitting"
76
+
77
+ ### Output
78
+
79
+ ```
80
+ ## Dependency Health Report
81
+
82
+ ### Score: B (78/100)
83
+
84
+ ### Metrics
85
+ | Metric | Count | Score |
86
+ |--------|-------|-------|
87
+ | Hubs (>10 fan-in) | 2 | 70/100 |
88
+ | Orphans | 3 | 80/100 |
89
+ | Cycles | 0 | 100/100 |
90
+ | Deep chains (>7) | 1 | 70/100 |
91
+ | Module cohesion | 0.62 avg | 70/100 |
92
+
93
+ ### Top Issues
94
+ 1. **Hub**: src/utils/helpers.ts — 14 importers (split recommended)
95
+ 2. **Hub**: src/types/index.ts — 12 importers (acceptable for type barrel)
96
+ 3. **Orphan**: src/legacy/old-parser.ts — 0 importers
97
+ 4. **Deep chain**: entry→auth→user→db→pool→config→env→loader (8 hops)
98
+
99
+ ### Recommendations
100
+ 1. Split src/utils/helpers.ts into domain-specific modules
101
+ 2. Investigate src/legacy/old-parser.ts for removal
102
+ 3. Flatten auth chain by having auth import db directly
103
+ ```
104
+
105
+ ## Harness Integration
106
+
107
+ - **`harness scan`** — Must run before this skill to ensure graph is current.
108
+ - **`harness validate`** — Run after acting on findings to verify project health.
109
+ - **Graph tools** — This skill uses `query_graph`, `get_relationships`, and `check_dependencies` MCP tools.
110
+
111
+ ## Success Criteria
112
+
113
+ - Health score computed on 0-100 scale with letter grade (A-F)
114
+ - All five structural metrics gathered (hubs, orphans, cycles, deep chains, cohesion)
115
+ - Recommendations are specific and actionable (name files, suggest concrete fixes)
116
+ - Report follows the structured output format
117
+ - All findings are backed by graph query evidence, not heuristics
118
+
119
+ ## Examples
120
+
121
+ ### Example: Weekly Health Check on Monorepo
122
+
123
+ ```
124
+ Input: Scheduled weekly run on project root
125
+
126
+ 1. METRICS — query_graph for hubs: 2 found (helpers.ts, index.ts)
127
+ get_relationships for orphans: 3 found
128
+ check_dependencies for cycles: 0 found
129
+ query_graph for deep chains: 1 found (8 hops)
130
+ Module cohesion average: 0.62
131
+ 2. SCORE — Weighted score: 78/100 (Grade: B)
132
+ 3. RECOMMEND — "Split helpers.ts (14 importers) into domain modules"
133
+ "Investigate old-parser.ts for removal (0 importers)"
134
+ "Flatten auth chain — 8 hops exceeds threshold"
135
+
136
+ Output:
137
+ Score: B (78/100)
138
+ Top issues: 2 hubs, 3 orphans, 1 deep chain
139
+ 3 actionable recommendations generated
140
+ ```
141
+
142
+ ## Gates
143
+
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.
146
+
147
+ ## Escalation
148
+
149
+ - **When score is F (<40)**: Flag as critical and recommend immediate architectural review.
150
+ - **When graph is stale**: Warn and suggest re-scanning before trusting results.
@@ -0,0 +1,41 @@
1
+ name: harness-dependency-health
2
+ version: "1.0.0"
3
+ description: Analyze structural health of the codebase using graph metrics
4
+ cognitive_mode: analytical-reporter
5
+ triggers:
6
+ - manual
7
+ - scheduled
8
+ platforms:
9
+ - claude-code
10
+ - gemini-cli
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Glob
15
+ - Grep
16
+ cli:
17
+ command: harness skill run harness-dependency-health
18
+ args:
19
+ - name: path
20
+ description: Project root path
21
+ required: false
22
+ mcp:
23
+ tool: run_skill
24
+ input:
25
+ skill: harness-dependency-health
26
+ path: string
27
+ type: rigid
28
+ phases:
29
+ - name: metrics
30
+ description: Compute graph structural metrics
31
+ required: true
32
+ - name: score
33
+ description: Calculate health score and identify problems
34
+ required: true
35
+ - name: recommend
36
+ description: Generate specific remediation recommendations
37
+ required: true
38
+ state:
39
+ persistent: false
40
+ files: []
41
+ depends_on: []
@@ -41,6 +41,15 @@ Deviating from the plan mid-execution introduces untested assumptions, breaks ta
41
41
 
42
42
  7. **If prerequisites fail,** do not proceed. Report what is missing and which task is blocked.
43
43
 
44
+ ### Graph-Enhanced Context (when available)
45
+
46
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
47
+
48
+ - `query_graph` — check file overlap between current and next task for conflict detection
49
+ - `get_impact` — understand blast radius before executing a task
50
+
51
+ Enables smarter execution ordering and blockage detection. Fall back to file-based commands if no graph is available.
52
+
44
53
  ---
45
54
 
46
55
  ### Phase 2: EXECUTE — Implement Tasks Atomically
@@ -137,6 +146,16 @@ Between tasks (especially between sessions):
137
146
  }
138
147
  ```
139
148
 
149
+ ### Graph Refresh
150
+
151
+ If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
152
+
153
+ ```
154
+ harness scan [path]
155
+ ```
156
+
157
+ Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
158
+
140
159
  2. **Append tagged learnings to `.harness/learnings.md`.** Tag every entry with skill and outcome:
141
160
 
142
161
  ```markdown
@@ -0,0 +1,135 @@
1
+ # Harness Hotspot Detector
2
+
3
+ > Identify modules that represent structural risk via co-change and churn analysis.
4
+
5
+ ## When to Use
6
+
7
+ - Weekly scheduled analysis to track codebase risk
8
+ - Before major refactoring — find the riskiest areas
9
+ - When investigating why changes keep breaking unrelated features
10
+ - NOT for finding dead code (use cleanup-dead-code)
11
+ - NOT for checking architecture rules (use enforce-architecture)
12
+
13
+ ## Prerequisites
14
+
15
+ A knowledge graph must exist at `.harness/graph/` with git history ingested. 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.
17
+
18
+ ## Process
19
+
20
+ ### Phase 1: CO-CHANGE — Analyze Co-Change Patterns
21
+
22
+ Query the graph for `co_changes_with` edges (created by GitIngestor):
23
+
24
+ ```
25
+ query_graph(rootNodeIds=[all file nodes], includeEdges=["co_changes_with"])
26
+ ```
27
+
28
+ Identify file pairs that frequently change together:
29
+
30
+ - **Co-located pairs** (same directory): Normal — they share a concern.
31
+ - **Distant pairs** (different modules): Suspicious — may indicate hidden coupling.
32
+
33
+ Flag distant co-change pairs as potential hotspots.
34
+
35
+ ### Phase 2: CHURN — Identify High-Churn Files
36
+
37
+ Query commit nodes to find files with the highest change frequency:
38
+
39
+ ```
40
+ query_graph(rootNodeIds=[commit nodes], includeTypes=["commit", "file"], includeEdges=["co_changes_with"])
41
+ ```
42
+
43
+ Rank files by:
44
+
45
+ - Total commit count touching the file
46
+ - Recent velocity (commits in last 30 days vs prior 30 days)
47
+ - Change size (total lines added + deleted)
48
+
49
+ High churn in shared utilities or core modules = high risk.
50
+
51
+ ### Phase 3: COUPLING — Detect Hidden Dependencies
52
+
53
+ Cross-reference co-change data with structural data:
54
+
55
+ 1. **High logical coupling, low structural coupling**: Files that always change together but have no `imports` edge between them. This indicates a hidden dependency — changing one requires changing the other, but the code doesn't express this relationship.
56
+
57
+ 2. **High structural coupling, low logical coupling**: Files with `imports` edges but that rarely change together. This may indicate over-coupling — the import exists but the relationship is weak.
58
+
59
+ Use `get_relationships` to check structural edges between co-change pairs.
60
+
61
+ ### Phase 4: REPORT — Generate Ranked Hotspot Report
62
+
63
+ ```
64
+ ## Hotspot Analysis Report
65
+
66
+ ### Risk Hotspots (ranked by risk score)
67
+
68
+ 1. **src/services/billing.ts** — Risk: HIGH
69
+ - Churn: 23 commits (last 30 days: 8)
70
+ - Co-changes with: src/types/invoice.ts (distant, 15 co-changes)
71
+ - Hidden dependency: no imports edge to invoice.ts
72
+ - Recommendation: Extract shared billing types or add explicit dependency
73
+
74
+ 2. **src/utils/helpers.ts** — Risk: HIGH
75
+ - Churn: 45 commits (highest in codebase)
76
+ - Co-changes with: 12 different files across 4 modules
77
+ - Recommendation: Split into domain-specific utilities to reduce blast radius
78
+
79
+ 3. **src/middleware/auth.ts** — Risk: MEDIUM
80
+ - Churn: 15 commits
81
+ - Co-changes with: src/routes/login.ts (co-located, expected)
82
+ - No hidden dependencies detected
83
+
84
+ ### Summary
85
+ - Total hotspots detected: 5
86
+ - High risk: 2
87
+ - Medium risk: 3
88
+ - Hidden dependencies: 1
89
+ ```
90
+
91
+ ## Harness Integration
92
+
93
+ - **`harness scan`** — Must run before this skill to ensure graph is current.
94
+ - **`harness validate`** — Run after acting on findings to verify project health.
95
+ - **Graph tools** — This skill uses `query_graph`, `get_impact`, and `get_relationships` MCP tools.
96
+
97
+ ## Success Criteria
98
+
99
+ - Hotspots ranked by composite risk score (churn + coupling)
100
+ - Hidden dependencies identified (high co-change, no structural edge)
101
+ - Co-change patterns detected and classified (co-located vs distant)
102
+ - Report follows the structured output format
103
+ - All findings are backed by graph query evidence, not heuristics
104
+
105
+ ## Examples
106
+
107
+ ### Example: Detecting Hotspots in a Growing Codebase
108
+
109
+ ```
110
+ Input: Scheduled weekly analysis on project root
111
+
112
+ 1. CO-CHANGE — query_graph for co_changes_with edges
113
+ Found 4 distant co-change pairs
114
+ 2. CHURN — Ranked files by commit frequency
115
+ billing.ts: 23 commits, helpers.ts: 45 commits
116
+ 3. COUPLING — Cross-referenced co-change vs imports edges
117
+ billing.ts <-> invoice.ts: 15 co-changes, no imports edge
118
+ (hidden dependency detected)
119
+ 4. REPORT — Ranked hotspots by risk score
120
+
121
+ Output:
122
+ Hotspots: 5 total (2 high, 3 medium)
123
+ Hidden dependencies: 1 (billing.ts <-> invoice.ts)
124
+ Top recommendation: Extract shared billing types
125
+ ```
126
+
127
+ ## Gates
128
+
129
+ - **No analysis without graph + git data.** Both code structure and git history must be ingested.
130
+ - **No guessing at co-change patterns.** Use graph `co_changes_with` edges, not manual git log parsing.
131
+
132
+ ## Escalation
133
+
134
+ - **When hidden dependencies found**: Recommend making the dependency explicit (add import) or extracting shared code.
135
+ - **When a single file has >30 commits**: Flag as critical hotspot requiring architectural attention.
@@ -0,0 +1,44 @@
1
+ name: harness-hotspot-detector
2
+ version: "1.0.0"
3
+ description: Identify structural risk hotspots via co-change and churn analysis
4
+ cognitive_mode: analytical-reporter
5
+ triggers:
6
+ - manual
7
+ - scheduled
8
+ platforms:
9
+ - claude-code
10
+ - gemini-cli
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Glob
15
+ - Grep
16
+ cli:
17
+ command: harness skill run harness-hotspot-detector
18
+ args:
19
+ - name: path
20
+ description: Project root path
21
+ required: false
22
+ mcp:
23
+ tool: run_skill
24
+ input:
25
+ skill: harness-hotspot-detector
26
+ path: string
27
+ type: rigid
28
+ phases:
29
+ - name: co-change
30
+ description: Analyze co-change patterns from git history
31
+ required: true
32
+ - name: churn
33
+ description: Identify high-churn files and modules
34
+ required: true
35
+ - name: coupling
36
+ description: Detect hidden dependencies via logical coupling
37
+ required: true
38
+ - name: report
39
+ description: Generate ranked hotspot report
40
+ required: true
41
+ state:
42
+ persistent: false
43
+ files: []
44
+ depends_on: []
@@ -0,0 +1,139 @@
1
+ # Harness Impact Analysis
2
+
3
+ > Graph-based impact analysis. Answers: "if I change X, what breaks?"
4
+
5
+ ## When to Use
6
+
7
+ - Before merging a PR — understand the blast radius of changes
8
+ - When planning a refactoring — know what will be affected
9
+ - When a test fails — trace backwards to find what change caused it
10
+ - When `on_pr` triggers fire
11
+ - NOT for understanding code (use harness-onboarding or harness-code-review)
12
+ - NOT for finding dead code (use cleanup-dead-code)
13
+
14
+ ## Prerequisites
15
+
16
+ A knowledge graph must exist at `.harness/graph/`. Run `harness scan` if no graph is available.
17
+ If the graph exists but code has changed since the last scan, re-run `harness scan` first — stale graph data leads to inaccurate results.
18
+
19
+ ## Process
20
+
21
+ ### Phase 1: IDENTIFY — Determine Changed Files
22
+
23
+ 1. **From diff**: If a git diff is available, parse it to extract changed file paths.
24
+ 2. **From input**: If file paths are provided directly, use those.
25
+ 3. **From git**: If neither, use `git diff --name-only HEAD~1` to get recent changes.
26
+
27
+ ### Phase 2: ANALYZE — Query Graph for Impact
28
+
29
+ For each changed file:
30
+
31
+ 1. **Direct dependents**: Use `get_impact` MCP tool to find all files that import or call the changed file.
32
+
33
+ ```
34
+ get_impact(filePath="src/services/auth.ts")
35
+ → tests: [auth.test.ts, integration.test.ts]
36
+ → docs: [auth-guide.md]
37
+ → code: [routes/login.ts, middleware/verify.ts, ...]
38
+ ```
39
+
40
+ 2. **Transitive dependents**: Use `query_graph` with depth 3 to find indirect consumers.
41
+
42
+ ```
43
+ query_graph(rootNodeIds=["file:src/services/auth.ts"], maxDepth=3, includeEdges=["imports", "calls"])
44
+ ```
45
+
46
+ 3. **Documentation impact**: Use `get_relationships` to find `documents` edges pointing to changed nodes.
47
+
48
+ 4. **Test coverage**: Identify test files connected via `imports` edges. Flag changed files with no test coverage.
49
+
50
+ ### Phase 3: ASSESS — Risk Assessment and Report
51
+
52
+ 1. **Impact score**: Calculate based on:
53
+ - Number of direct dependents (weight: 3x)
54
+ - Number of transitive dependents (weight: 1x)
55
+ - Whether affected code includes entry points (weight: 5x)
56
+ - Whether tests exist for the changed code (no tests = higher risk)
57
+
58
+ 2. **Risk tiers**:
59
+ - **Critical** (score > 50): Changes affect entry points or >20 downstream files
60
+ - **High** (score 20-50): Changes affect multiple modules or shared utilities
61
+ - **Medium** (score 5-20): Changes affect a few files within the same module
62
+ - **Low** (score < 5): Changes are isolated with minimal downstream impact
63
+
64
+ 3. **Output report**:
65
+
66
+ ```
67
+ ## Impact Analysis Report
68
+
69
+ ### Changed Files
70
+ - src/services/auth.ts (modified)
71
+ - src/types/user.ts (modified)
72
+
73
+ ### Impact Summary
74
+ - Direct dependents: 8 files
75
+ - Transitive dependents: 23 files
76
+ - Affected tests: 5 files
77
+ - Affected docs: 2 files
78
+ - Risk tier: HIGH
79
+
80
+ ### Affected Tests (must run)
81
+ 1. tests/services/auth.test.ts (direct)
82
+ 2. tests/routes/login.test.ts (transitive)
83
+ 3. tests/integration/auth-flow.test.ts (transitive)
84
+
85
+ ### Affected Documentation (may need update)
86
+ 1. docs/auth-guide.md → documents src/services/auth.ts
87
+ 2. docs/api-reference.md → documents src/types/user.ts
88
+
89
+ ### Downstream Consumers
90
+ 1. src/routes/login.ts — imports auth.ts
91
+ 2. src/middleware/verify.ts — imports auth.ts
92
+ 3. src/routes/signup.ts — imports user.ts (transitive via auth.ts)
93
+ ```
94
+
95
+ ## Harness Integration
96
+
97
+ - **`harness scan`** — Must run before this skill to ensure graph is current.
98
+ - **`harness validate`** — Run after acting on findings to verify project health.
99
+ - **Graph tools** — This skill uses `query_graph`, `get_impact`, and `get_relationships` MCP tools.
100
+
101
+ ## Success Criteria
102
+
103
+ - Impact report generated with a risk tier (Critical / High / Medium / Low)
104
+ - All affected test files listed with direct vs transitive classification
105
+ - All affected documentation files listed with relationship context
106
+ - Report follows the structured output format
107
+ - All findings are backed by graph query evidence, not heuristics
108
+
109
+ ## Examples
110
+
111
+ ### Example: Analyzing a Change to auth.ts
112
+
113
+ ```
114
+ Input: git diff shows src/services/auth.ts modified
115
+
116
+ 1. IDENTIFY — Extract changed file: src/services/auth.ts
117
+ 2. ANALYZE — get_impact(filePath="src/services/auth.ts")
118
+ query_graph(rootNodeIds=["file:src/services/auth.ts"], maxDepth=3)
119
+ Results: 8 direct dependents, 23 transitive, 5 tests, 2 docs
120
+ 3. ASSESS — Impact score: 34 (High tier)
121
+ - Entry points affected: no
122
+ - Tests exist: yes (5 files)
123
+
124
+ Output:
125
+ Risk tier: HIGH
126
+ Must-run tests: auth.test.ts, login.test.ts, auth-flow.test.ts
127
+ Docs to update: auth-guide.md, api-reference.md
128
+ Downstream consumers: 8 files across 3 modules
129
+ ```
130
+
131
+ ## Gates
132
+
133
+ - **No analysis without graph.** If no graph exists at `.harness/graph/`, stop and instruct the user to run `harness scan`.
134
+ - **No risk assessment without data.** Do not guess at impact — use graph queries. If graph data is incomplete, state what is missing.
135
+
136
+ ## Escalation
137
+
138
+ - **When graph is stale**: If the graph's last scan timestamp is older than the most recent commit, warn that results may be incomplete and suggest re-scanning.
139
+ - **When impact is critical**: If risk tier is Critical, recommend a thorough code review and full test suite run before merging.
@@ -0,0 +1,44 @@
1
+ name: harness-impact-analysis
2
+ version: "1.0.0"
3
+ description: Graph-based impact analysis — answers "if I change X, what breaks?"
4
+ cognitive_mode: analytical-reporter
5
+ triggers:
6
+ - manual
7
+ - on_pr
8
+ platforms:
9
+ - claude-code
10
+ - gemini-cli
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Glob
15
+ - Grep
16
+ cli:
17
+ command: harness skill run harness-impact-analysis
18
+ args:
19
+ - name: path
20
+ description: Project root path
21
+ required: false
22
+ - name: files
23
+ description: Comma-separated list of changed files
24
+ required: false
25
+ mcp:
26
+ tool: run_skill
27
+ input:
28
+ skill: harness-impact-analysis
29
+ path: string
30
+ type: rigid
31
+ phases:
32
+ - name: identify
33
+ description: Identify changed files from diff or input
34
+ required: true
35
+ - name: analyze
36
+ description: Query graph for impact of each changed file
37
+ required: true
38
+ - name: assess
39
+ description: Rank findings by risk and generate report
40
+ required: true
41
+ state:
42
+ persistent: false
43
+ files: []
44
+ depends_on: []
@@ -32,6 +32,15 @@ Invoke `harness-verify` to run the mechanical quick gate.
32
32
  3. **If ALL three checks FAIL**, stop here. Do not proceed to Phase 2. The code is not in a reviewable state.
33
33
  4. If at least one check passes (or some are skipped), proceed to Phase 2.
34
34
 
35
+ ### Phase 1.5: SECURITY SCAN
36
+
37
+ Run the built-in security scanner as a mechanical check between verification and AI review.
38
+
39
+ 1. Use `run_security_scan` MCP tool against the project root (or changed files if available).
40
+ 2. Capture findings by severity: errors, warnings, info.
41
+ 3. **Error-severity security findings are blocking** — they cause the overall integrity check to FAIL, same as a test failure.
42
+ 4. Warning/info findings are included in the report but do not block.
43
+
35
44
  ### Phase 2: REVIEW
36
45
 
37
46
  Run change-type-aware AI review using `harness-code-review`.
@@ -40,6 +49,7 @@ Run change-type-aware AI review using `harness-code-review`.
40
49
  2. Invoke `harness-code-review` with the detected change type.
41
50
  3. Capture the review findings: suggestions, blocking issues, and notes.
42
51
  4. A review finding is "blocking" only if it would cause a runtime error, data loss, or security vulnerability.
52
+ 5. The AI review includes a security-focused pass that complements the mechanical scanner — checking for semantic issues like user input flowing to dangerous sinks across function boundaries.
43
53
 
44
54
  ### Phase 3: REPORT
45
55
 
@@ -47,10 +57,11 @@ Produce a unified integrity report in this exact format:
47
57
 
48
58
  ```
49
59
  Integrity Check: [PASS/FAIL]
50
- - Tests: [PASS/FAIL/SKIPPED]
51
- - Lint: [PASS/FAIL/SKIPPED]
52
- - Types: [PASS/FAIL/SKIPPED]
53
- - Review: [PASS/FAIL] ([count] suggestions, [count] blocking)
60
+ - Tests: [PASS/FAIL/SKIPPED]
61
+ - Lint: [PASS/FAIL/SKIPPED]
62
+ - Types: [PASS/FAIL/SKIPPED]
63
+ - Security: [PASS/WARN/FAIL] ([count] errors, [count] warnings)
64
+ - Review: [PASS/FAIL] ([count] suggestions, [count] blocking)
54
65
 
55
66
  Overall: [PASS/FAIL]
56
67
  ```
@@ -90,19 +101,22 @@ Integrity Check: PASS
90
101
  - Tests: PASS (42/42)
91
102
  - Lint: PASS (0 warnings)
92
103
  - Types: PASS
104
+ - Security: PASS (0 errors, 0 warnings)
93
105
  - Review: 1 suggestion (0 blocking)
94
106
  ```
95
107
 
96
- ### Example: Blocking Issue
108
+ ### Example: Security Blocking Issue
97
109
 
98
110
  ```
99
111
  Integrity Check: FAIL
100
112
  - Tests: PASS (42/42)
101
113
  - Lint: PASS
102
114
  - Types: PASS
115
+ - Security: FAIL (1 error, 0 warnings)
116
+ - [SEC-INJ-002] src/auth/login.ts:42 — SQL query built with string concatenation
103
117
  - Review: 3 findings (1 blocking)
104
118
 
105
- Blocking: [src/auth/login.ts:42] Possible SQL injection — user input passed directly to query without parameterization.
119
+ Blocking: [SEC-INJ-002] SQL injection — user input passed directly to query without parameterization.
106
120
  ```
107
121
 
108
122
  ## Gates