@harness-engineering/cli 1.3.0 → 1.6.0

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 (55) hide show
  1. package/dist/agents/personas/architecture-enforcer.yaml +1 -0
  2. package/dist/agents/personas/code-reviewer.yaml +41 -0
  3. package/dist/agents/personas/codebase-health-analyst.yaml +27 -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/task-executor.yaml +41 -0
  9. package/dist/agents/skills/README.md +8 -0
  10. package/dist/agents/skills/claude-code/add-harness-component/SKILL.md +10 -0
  11. package/dist/agents/skills/claude-code/align-documentation/SKILL.md +19 -0
  12. package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +19 -0
  13. package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +8 -0
  14. package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +9 -0
  15. package/dist/agents/skills/claude-code/harness-architecture-advisor/SKILL.md +9 -0
  16. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +10 -0
  17. package/dist/agents/skills/claude-code/harness-debugging/SKILL.md +10 -0
  18. package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +150 -0
  19. package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +41 -0
  20. package/dist/agents/skills/claude-code/harness-execution/SKILL.md +19 -0
  21. package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +135 -0
  22. package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +44 -0
  23. package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +139 -0
  24. package/dist/agents/skills/claude-code/harness-impact-analysis/skill.yaml +44 -0
  25. package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +154 -0
  26. package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +49 -0
  27. package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +10 -0
  28. package/dist/agents/skills/claude-code/harness-parallel-agents/SKILL.md +9 -0
  29. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +9 -0
  30. package/dist/agents/skills/claude-code/harness-pre-commit-review/SKILL.md +6 -0
  31. package/dist/agents/skills/claude-code/harness-refactoring/SKILL.md +19 -0
  32. package/dist/agents/skills/claude-code/harness-tdd/SKILL.md +10 -0
  33. package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +131 -0
  34. package/dist/agents/skills/claude-code/harness-test-advisor/skill.yaml +44 -0
  35. package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +10 -0
  36. package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +9 -0
  37. package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +150 -0
  38. package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +41 -0
  39. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +135 -0
  40. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +44 -0
  41. package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +139 -0
  42. package/dist/agents/skills/gemini-cli/harness-impact-analysis/skill.yaml +44 -0
  43. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +154 -0
  44. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +49 -0
  45. package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +131 -0
  46. package/dist/agents/skills/gemini-cli/harness-test-advisor/skill.yaml +44 -0
  47. package/dist/agents/skills/tests/platform-parity.test.ts +131 -0
  48. package/dist/agents/skills/tests/schema.ts +2 -0
  49. package/dist/bin/harness.js +2 -2
  50. package/dist/{chunk-EFZOLZFB.js → chunk-ACMDUQJG.js} +4 -2
  51. package/dist/{chunk-APYEWOCR.js → chunk-VS4OTOKZ.js} +1393 -350
  52. package/dist/{create-skill-4GKJZB5R.js → create-skill-NZDLMMR6.js} +1 -1
  53. package/dist/index.d.ts +265 -143
  54. package/dist/index.js +30 -4
  55. package/package.json +3 -2
@@ -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: []
@@ -0,0 +1,154 @@
1
+ # Harness Knowledge Mapper
2
+
3
+ > Auto-generate always-current knowledge maps from graph topology. Never stale because it's computed, not authored.
4
+
5
+ ## When to Use
6
+
7
+ - When AGENTS.md is outdated or doesn't exist — generate it from the graph
8
+ - After major refactoring — regenerate the knowledge map to reflect new structure
9
+ - On scheduled basis — keep documentation aligned with code
10
+ - When `on_commit` to main triggers fire
11
+ - NOT for validating existing AGENTS.md (use validate-context-engineering)
12
+ - NOT for fixing documentation drift (use align-documentation)
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: SURVEY — Query Graph for Structure
22
+
23
+ 1. **Module hierarchy**: Query for module nodes and their `contains` edges to file nodes.
24
+
25
+ ```
26
+ query_graph(rootNodeIds=[all module nodes], includeTypes=["module", "file"], includeEdges=["contains"])
27
+ ```
28
+
29
+ 2. **Entry points**: Find file nodes with high out-degree but low in-degree (they initiate dependency chains).
30
+
31
+ ```
32
+ search_similar(query="main entry point index")
33
+ ```
34
+
35
+ 3. **Layer structure**: Query for layer nodes if defined.
36
+
37
+ 4. **Dependency flow**: For each module, trace outbound `imports` edges to other modules.
38
+
39
+ ```
40
+ get_relationships(nodeId=<module>, direction="outbound", depth=1)
41
+ ```
42
+
43
+ ### Phase 2: GENERATE — Build Knowledge Map
44
+
45
+ Generate markdown sections following AGENTS.md conventions:
46
+
47
+ 1. **Repository Structure**: Module hierarchy with brief descriptions derived from file contents and function names.
48
+
49
+ 2. **Key Entry Points**: Files identified as entry points with their purpose (inferred from exports and naming).
50
+
51
+ 3. **Module Dependencies**: For each module, list what it depends on and what depends on it. Format as a dependency table.
52
+
53
+ 4. **API Surface**: Public exports from each module, grouped by type (functions, classes, types).
54
+
55
+ 5. **Patterns and Conventions**: Detected patterns from graph structure (e.g., "all services follow Repository pattern", "tests co-located with source").
56
+
57
+ ### Phase 3: AUDIT — Identify Coverage Gaps
58
+
59
+ 1. **Undocumented modules**: Use `check_docs` to find code nodes without `documents` edges.
60
+
61
+ 2. **Missing descriptions**: Modules with no README or doc file.
62
+
63
+ 3. **Stale references**: If an existing AGENTS.md exists, compare its file references against the graph to find mentions of files that no longer exist.
64
+
65
+ ### Phase 4: OUTPUT — Write Knowledge Map
66
+
67
+ 1. **Default**: Write to AGENTS.md in project root.
68
+ 2. **Custom path**: Write to specified output path.
69
+ 3. **Diff mode**: If AGENTS.md exists, show what changed rather than overwriting.
70
+
71
+ ### Output
72
+
73
+ ```
74
+ ## Generated Knowledge Map
75
+
76
+ ### Repository Structure
77
+ - **packages/core/** — Core library: context assembly, entropy detection, constraints, feedback
78
+ - src/context/ — Token budget, filtering, doc coverage, knowledge map validation
79
+ - src/entropy/ — Drift detection, dead code analysis, pattern violations
80
+ - src/constraints/ — Layer validation, circular dependency detection, boundaries
81
+ - src/feedback/ — Self-review, peer review, diff analysis
82
+
83
+ - **packages/graph/** — Knowledge graph: store, query, ingest, search
84
+ - src/store/ — LokiJS-backed graph store, vector store, serialization
85
+ - src/query/ — ContextQL traversal, projection
86
+ - src/ingest/ — Code, git, knowledge, connector ingestion
87
+ - src/search/ — FusionLayer hybrid search
88
+
89
+ ### Entry Points
90
+ 1. packages/core/src/index.ts — Core library barrel export
91
+ 2. packages/graph/src/index.ts — Graph library barrel export
92
+ 3. packages/cli/src/index.ts — CLI entry point (Commander.js)
93
+ 4. packages/mcp-server/src/server.ts — MCP server registration
94
+
95
+ ### Coverage Gaps
96
+ - 3 modules have no documentation
97
+ - 5 files have no test coverage
98
+ ```
99
+
100
+ ### Graph Refresh
101
+
102
+ After generating documentation, refresh the graph so new `documents` edges reflect the updated docs:
103
+
104
+ ```
105
+ harness scan [path]
106
+ ```
107
+
108
+ This ensures subsequent graph queries (impact analysis, drift detection) include the newly generated documentation.
109
+
110
+ ## Harness Integration
111
+
112
+ - **`harness scan`** — Must run before this skill to ensure graph is current.
113
+ - **`harness validate`** — Run after acting on findings to verify project health.
114
+ - **Graph tools** — This skill uses `query_graph`, `get_relationships`, and `check_docs` MCP tools.
115
+
116
+ ## Success Criteria
117
+
118
+ - Knowledge map generated with all sections (structure, entry points, dependencies, API surface, patterns)
119
+ - Coverage gaps identified (undocumented modules, missing descriptions, stale references)
120
+ - Output written to AGENTS.md (or specified path) in proper markdown format
121
+ - Report follows the structured output format
122
+ - All findings are backed by graph query evidence, not heuristics
123
+
124
+ ## Examples
125
+
126
+ ### Example: Generating AGENTS.md from Graph
127
+
128
+ ```
129
+ Input: No AGENTS.md exists, graph is current after harness scan
130
+
131
+ 1. SURVEY — query_graph for module hierarchy: 4 packages found
132
+ search_similar for entry points: 4 identified
133
+ get_relationships for dependency flow per module
134
+ 2. GENERATE — Built 5 sections: structure, entry points,
135
+ dependencies, API surface, patterns
136
+ 3. AUDIT — check_docs found 3 undocumented modules,
137
+ 5 files with no test coverage
138
+ 4. OUTPUT — Wrote AGENTS.md to project root (new file)
139
+
140
+ Output:
141
+ AGENTS.md generated (142 lines)
142
+ Coverage gaps: 3 undocumented modules, 5 untested files
143
+ No stale references (fresh generation)
144
+ ```
145
+
146
+ ## Gates
147
+
148
+ - **No generation without graph.** If no graph exists, stop and instruct to run `harness scan`.
149
+ - **Never overwrite without confirmation.** If AGENTS.md exists, show the diff and ask before replacing.
150
+
151
+ ## Escalation
152
+
153
+ - **When >50% of modules are undocumented**: Flag as critical documentation debt.
154
+ - **When graph structure doesn't match directory structure**: The graph may be stale — recommend re-scanning.
@@ -0,0 +1,49 @@
1
+ name: harness-knowledge-mapper
2
+ version: "1.0.0"
3
+ description: Auto-generate always-current knowledge maps from graph topology
4
+ cognitive_mode: constructive-architect
5
+ triggers:
6
+ - manual
7
+ - on_commit
8
+ - scheduled
9
+ platforms:
10
+ - claude-code
11
+ - gemini-cli
12
+ tools:
13
+ - Bash
14
+ - Read
15
+ - Write
16
+ - Glob
17
+ - Grep
18
+ cli:
19
+ command: harness skill run harness-knowledge-mapper
20
+ args:
21
+ - name: path
22
+ description: Project root path
23
+ required: false
24
+ - name: output
25
+ description: Output file path (default AGENTS.md)
26
+ required: false
27
+ mcp:
28
+ tool: run_skill
29
+ input:
30
+ skill: harness-knowledge-mapper
31
+ path: string
32
+ type: rigid
33
+ phases:
34
+ - name: survey
35
+ description: Query graph for module structure and topology
36
+ required: true
37
+ - name: generate
38
+ description: Generate structured knowledge map from graph data
39
+ required: true
40
+ - name: audit
41
+ description: Identify undocumented modules and coverage gaps
42
+ required: true
43
+ - name: output
44
+ description: Write knowledge map to file
45
+ required: true
46
+ state:
47
+ persistent: false
48
+ files: []
49
+ depends_on: []
@@ -73,6 +73,16 @@
73
73
  - Is documentation up to date with the code?
74
74
  - Are there tests? What is the approximate coverage?
75
75
 
76
+ ### Graph-Enhanced Context (when available)
77
+
78
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate codebase mapping:
79
+
80
+ - `query_graph` — map architecture automatically from module and layer nodes, replacing manual directory walking
81
+ - `search_similar` — find entry points and key files by querying for high-connectivity nodes
82
+ - `get_relationships` — show layer dependencies and module structure as a traversable graph
83
+
84
+ Graph queries produce a complete architecture map in seconds, including transitive relationships that directory inspection misses. Fall back to file-based commands if no graph is available.
85
+
76
86
  ### Phase 3: ORIENT — Identify Adoption Level and Maturity
77
87
 
78
88
  1. **Confirm the adoption level** matches what `harness.yaml` declares:
@@ -30,6 +30,15 @@ Before dispatching anything in parallel, rigorously verify independence:
30
30
 
31
31
  5. **When in doubt, run serially.** The cost of a false parallel dispatch (merge conflicts, subtle bugs, wasted work) far exceeds the cost of running serially.
32
32
 
33
+ ### Graph-Enhanced Context (when available)
34
+
35
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate independence verification:
36
+
37
+ - `query_graph` — get the dependency subgraph per candidate task and check for node overlap between tasks
38
+ - `get_impact` — verify tasks do not write to overlapping files or share transitive dependencies
39
+
40
+ Automated graph-based independence verification replaces manual import grep and catches transitive overlaps that file-level checks miss. Fall back to file-based commands if no graph is available.
41
+
33
42
  ### Step 2: Create Focused Agent Tasks
34
43
 
35
44
  For each independent task, write a focused agent brief:
@@ -60,6 +60,15 @@ When writing observable truths and acceptance criteria, use EARS (Easy Approach
60
60
 
61
61
  **When to use EARS:** Apply these patterns when writing observable truths in Phase 1. Not every criterion needs an EARS pattern — use them when the requirement is behavioral (not structural). File existence checks ("src/types/user.ts exists with User interface") do not need EARS framing.
62
62
 
63
+ ### Graph-Enhanced Context (when available)
64
+
65
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
66
+
67
+ - `query_graph` — discover module dependencies for realistic task decomposition
68
+ - `get_impact` — estimate which modules a feature touches and their dependencies
69
+
70
+ Enables accurate effort estimation and task sequencing. Fall back to file-based commands if no graph is available.
71
+
63
72
  ---
64
73
 
65
74
  ### Phase 2: DECOMPOSE — Map File Structure and Create Tasks
@@ -61,6 +61,12 @@ Mechanical Checks:
61
61
  Action: Fix lint errors before committing.
62
62
  ```
63
63
 
64
+ ### Graph Freshness Check
65
+
66
+ If a knowledge graph exists at `.harness/graph/` and code files have changed since the last scan, run `harness scan` before proceeding. The AI review phase uses graph-enhanced MCP tools (impact analysis, harness checks) that return stale results with an outdated graph.
67
+
68
+ If no graph exists, skip this step — the tools fall back to non-graph behavior.
69
+
64
70
  ### Phase 2: Classify Changes
65
71
 
66
72
  Determine whether AI review is needed based on what changed.
@@ -32,6 +32,15 @@ If tests are not green before you start, you are not refactoring — you are deb
32
32
 
33
33
  4. **Plan the steps.** Break the refactoring into the smallest possible individual changes. Each step should be independently committable and verifiable. If you cannot describe a step in one sentence, it is too large.
34
34
 
35
+ ### Graph-Enhanced Context (when available)
36
+
37
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
38
+
39
+ - `get_impact` — precise impact analysis: "if I move this function, what breaks?"
40
+ - `query_graph` — find all transitive consumers, not just direct importers
41
+
42
+ Catches indirect consumers that grep misses. Fall back to file-based commands if no graph is available.
43
+
35
44
  ### Phase 2: Execute — One Small Change at a Time
36
45
 
37
46
  For EACH step in the plan:
@@ -62,6 +71,16 @@ For EACH step in the plan:
62
71
 
63
72
  2. **Run `harness validate` and `harness check-deps` one final time.** Clean output.
64
73
 
74
+ ### Graph Refresh
75
+
76
+ If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
77
+
78
+ ```
79
+ harness scan [path]
80
+ ```
81
+
82
+ Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
83
+
65
84
  3. **Review the cumulative diff.** Does the final state match the intended improvement? Is the code genuinely better, or just different?
66
85
 
67
86
  4. **If the refactoring introduced no improvement,** revert the entire sequence. Refactoring for its own sake is churn.
@@ -75,6 +75,16 @@ If you find yourself writing production code first, STOP. Delete it. Write the t
75
75
 
76
76
  4. **Commit the cycle.** Each RED-GREEN-REFACTOR-VALIDATE cycle produces one atomic commit. The commit message references what behavior was added (not "add test" — describe the behavior).
77
77
 
78
+ ### Graph Refresh
79
+
80
+ If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
81
+
82
+ ```
83
+ harness scan [path]
84
+ ```
85
+
86
+ Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
87
+
78
88
  ### Cycle Rhythm
79
89
 
80
90
  Repeat the 4 phases for each new behavior. A typical feature requires 3-10 cycles. Each cycle should take 2-15 minutes. If a cycle takes longer than 15 minutes, the step is too large — break it down.