harness-everything 0.2.1 → 0.2.2

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 (70) hide show
  1. package/README.md +1 -1
  2. package/build-multi-agent-system/SKILL.md +68 -68
  3. package/create-agent-launcher/SKILL.md +48 -48
  4. package/docs/architecture.md +2 -2
  5. package/docs/workflows/build-multi-agent-system.md +62 -62
  6. package/docs/workflows/create-agent-launcher.md +62 -62
  7. package/docs/workflows/environment-detection.md +63 -63
  8. package/docs/workflows/eval-harness.md +57 -57
  9. package/docs/workflows/fable-discipline.md +59 -59
  10. package/docs/workflows/fable-mode.md +32 -32
  11. package/docs/workflows/git-commit.md +62 -62
  12. package/docs/workflows/grill-me.md +62 -62
  13. package/docs/workflows/grill-with-docs.md +62 -62
  14. package/docs/workflows/improve-codebase-architecture.md +60 -60
  15. package/docs/workflows/repo-docs.md +59 -59
  16. package/docs/workflows/rewrite-commits.md +60 -60
  17. package/docs/workflows/security-review.md +58 -58
  18. package/docs/workflows/self-evolve.md +59 -59
  19. package/docs/workflows/tdd.md +39 -39
  20. package/docs/workflows/todo-driven-workflow.md +36 -36
  21. package/docs/workflows/using-git-worktrees.md +63 -63
  22. package/docs/workflows/verification-loop.md +69 -69
  23. package/docs/workflows/verify-before-claim.md +60 -60
  24. package/docs/workflows/zoom-out.md +62 -62
  25. package/environment-detection/SKILL.md +77 -77
  26. package/eval-framework/behavioral-test.js +105 -105
  27. package/eval-framework/mechanism-test.js +251 -251
  28. package/eval-harness/SKILL.md +59 -59
  29. package/fable-discipline/SKILL.md +38 -38
  30. package/fable-mode/SKILL.md +51 -51
  31. package/git-commit/SKILL.md +55 -55
  32. package/grill-me/SKILL.md +36 -36
  33. package/grill-with-docs/SKILL.md +99 -99
  34. package/harness-everything/SKILL.md +141 -141
  35. package/harness-everything/examples/README.md +9 -9
  36. package/harness-everything/examples/todo-workflow.md +22 -22
  37. package/harness-everything/scripts/todo-cli.js +157 -157
  38. package/harness-everything/scripts/verify-gate.js +31 -31
  39. package/hooks/scripts/atomic-commit-check.js +68 -68
  40. package/hooks/scripts/context-compact.js +114 -114
  41. package/hooks/scripts/lib/platforms/claude.js +132 -42
  42. package/hooks/scripts/lib/platforms/codex.js +96 -46
  43. package/hooks/scripts/lib/platforms/continue.js +73 -41
  44. package/hooks/scripts/lib/platforms/copilot.js +91 -41
  45. package/hooks/scripts/lib/platforms/cursor.js +71 -41
  46. package/hooks/scripts/lib/platforms/hermes.js +25 -0
  47. package/hooks/scripts/rule-of-3.js +176 -176
  48. package/improve-codebase-architecture/SKILL.md +44 -44
  49. package/install-cognitive-os/SKILL.md +95 -95
  50. package/package.json +1 -1
  51. package/repo-docs/SKILL.md +45 -45
  52. package/rewrite-commits/SKILL.md +32 -32
  53. package/scripts/installer.js +57 -200
  54. package/scripts/lib/advisory-text.js +163 -163
  55. package/scripts/lib/claude-hooks.js +71 -71
  56. package/scripts/lib/manifest.js +82 -82
  57. package/scripts/lib/prompts.js +241 -241
  58. package/scripts/lib/skills.js +174 -172
  59. package/scripts/lib/workspace.js +28 -28
  60. package/security-review/SKILL.md +510 -510
  61. package/self-evolve/SKILL.md +54 -54
  62. package/skill-creator/SKILL.md +91 -91
  63. package/skill-creator/references/testing-workflow.md +32 -32
  64. package/skill-style/SKILL.md +48 -48
  65. package/tdd/SKILL.md +53 -53
  66. package/todo-driven-workflow/SKILL.md +54 -54
  67. package/using-git-worktrees/SKILL.md +161 -161
  68. package/verification-loop/SKILL.md +138 -138
  69. package/verify-before-claim/SKILL.md +86 -86
  70. package/zoom-out/SKILL.md +90 -90
@@ -1,176 +1,176 @@
1
- #!/usr/bin/env node
2
- // Rule of 3 circuit breaker (PreToolUse: Bash|PowerShell|Edit|Write).
3
- //
4
- // Tripping the breaker forces REFLECTION, not surrender. The most common
5
- // agent failure mode is drilling deeper on one unverified assumption, so the
6
- // breaker locks mutating tools and demands a zoom-out fact-check first
7
- // (read-only tools stay available). A valid reflection report - written to
8
- // the session's zoom-out-report.md (path given in the block message below) -
9
- // releases the breaker again. Only a SECOND trip on the same failure
10
- // signature - proof that reflection alone couldn't crack it - hard-locks the
11
- // session until the Human Partner decides.
12
- //
13
- // State is scoped per Claude Code session_id (see lib/harness-state.js) so
14
- // two sessions open on the same repo never share a trip count. The common
15
- // case - nobody's breaker tripped anywhere - never has to read stdin to find
16
- // that out; only once some session IS tripped do we pay to read the payload
17
- // and check whether it's this one.
18
- const fs = require('fs');
19
- const path = require('path');
20
- const { getWorkspaceRoot, getSessionDir, listSessionDirs } = require('./lib/harness-state');
21
-
22
- const REQUIRED_SECTIONS = [
23
- '## Goal',
24
- '## Failed Attempts',
25
- '## Verified Facts',
26
- '## Diagnosis',
27
- '## Decision'
28
- ];
29
-
30
- function readState(stateFile) {
31
- if (!fs.existsSync(stateFile)) return null;
32
- try { return JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch (err) { return null; }
33
- }
34
-
35
- function isTripped(state) {
36
- return !!state && state.count >= 3 && !state.zoomOutResolved;
37
- }
38
-
39
- function anySessionTripped(root) {
40
- return listSessionDirs(root).some(dir => isTripped(readState(path.join(dir, 'rule-of-3-state.json'))));
41
- }
42
-
43
- // The one mutation allowed while tripped: writing the reflection report.
44
- function isReportWrite(payload, reportFile) {
45
- if (!payload) return false;
46
- if (payload.tool_name !== 'Write' && payload.tool_name !== 'Edit') return false;
47
- const target = payload.tool_input && payload.tool_input.file_path;
48
- if (!target) return false;
49
- return path.resolve(target).toLowerCase() === path.resolve(reportFile).toLowerCase();
50
- }
51
-
52
- // A report only counts if it was written AFTER the failure that tripped the
53
- // breaker (a stale report from an earlier loop can't unlock a new one), has
54
- // every required section, and actually committed to a RESUME/ESCALATE call.
55
- function reportIsValid(state, reportFile) {
56
- if (!fs.existsSync(reportFile)) return false;
57
- if (fs.statSync(reportFile).mtimeMs < (state.lastFailureAt || 0)) return false;
58
- const text = fs.readFileSync(reportFile, 'utf8');
59
- if (!REQUIRED_SECTIONS.every(h => text.includes(h))) return false;
60
- return /\b(RESUME|ESCALATE)\b/.test(text);
61
- }
62
-
63
- function blockForReflection(state, reportFile) {
64
- console.error(`[CRITICAL] RULE OF 3 CIRCUIT BREAKER TRIGGERED!`);
65
- console.error(`The same failure signature has now occurred 3 times.`);
66
- console.error(`Error Signature: ${state.lastHash}`);
67
- console.error(`\nMutating tools (Bash/PowerShell/Edit/Write) are locked - not because you`);
68
- console.error(`must wait for a human, but because you must stop drilling and rebuild the`);
69
- console.error(`full picture first. Do NOT ask the Human Partner yet.`);
70
- console.error(`\nACTION REQUIRED (reflect first):`);
71
- console.error(`1. CEASE FIRE. No new fix attempts, no variations of the last one.`);
72
- console.error(`2. Load the 'zoom-out' skill and follow its Reflect & Fact-Check protocol.`);
73
- console.error(`3. Using READ-ONLY tools (Read/Grep/Glob - still available), re-verify the`);
74
- console.error(` assumption behind each failed attempt against the actual code/logs/docs.`);
75
- console.error(`4. Write your findings to '${reportFile}' (the ONLY write`);
76
- console.error(` allowed right now) with sections: ## Goal, ## Failed Attempts,`);
77
- console.error(` ## Verified Facts, ## Diagnosis, ## Decision (ending RESUME: or ESCALATE:).`);
78
- console.error(`\nA valid report releases this breaker automatically. Escalate to the Human`);
79
- console.error(`Partner ONLY if your Decision concludes a genuinely human call is needed`);
80
- console.error(`(requirement conflict, architecture trade-off, destructive action, missing`);
81
- console.error(`access) - and then present options with a recommendation, not apologies.`);
82
- // For PreToolUse, only exit code 2 actually blocks the tool call.
83
- // Exit 1 is a non-blocking error and Claude Code proceeds anyway.
84
- process.exit(2);
85
- }
86
-
87
- function blockForHumanDecision(state) {
88
- console.error(`[CRITICAL] RULE OF 3 CIRCUIT BREAKER TRIGGERED! (repeat trip - hard lock)`);
89
- console.error(`Error Signature: ${state.lastHash}`);
90
- console.error(`\nYou already completed a zoom-out reflection for this same failure signature`);
91
- console.error(`and the fresh diagnosis failed too. This is now past reflect-and-retry:`);
92
- console.error(`STOP and hand the decision to your Human Partner.`);
93
- console.error(`\nPresent a DECISION REQUEST, not a plea: the goal, the verified facts, every`);
94
- console.error(`path already falsified (including the post-reflection diagnosis), 2-3`);
95
- console.error(`concrete options with trade-offs, and your recommendation.`);
96
- console.error(`\nThis lock persists until the Human Partner clears it by running`);
97
- console.error(`"npm run harness:reset" in their own terminal, or by starting a new`);
98
- console.error(`session / running /clear (which resets it automatically on SessionStart).`);
99
- process.exit(2);
100
- }
101
-
102
- function main(payload) {
103
- try {
104
- const root = getWorkspaceRoot();
105
- const sessionDir = getSessionDir(root, payload && payload.session_id);
106
- const stateFile = path.join(sessionDir, 'rule-of-3-state.json');
107
- const reportFile = path.join(sessionDir, 'zoom-out-report.md');
108
-
109
- const state = readState(stateFile);
110
- if (!isTripped(state)) {
111
- process.exit(0);
112
- }
113
-
114
- if (isReportWrite(payload, reportFile)) {
115
- process.exit(0);
116
- }
117
-
118
- if (reportIsValid(state, reportFile)) {
119
- state.count = 0;
120
- state.zoomOutResolved = true;
121
- state.zoomOutCycles = (state.zoomOutCycles || 0) + 1;
122
- fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
123
- console.log(
124
- `[Rule of 3] Zoom-out report accepted - breaker released. Follow your ` +
125
- `report's Decision: RESUME means one fresh run at the NEW diagnosis; ` +
126
- `ESCALATE means present the decision request and WAIT for the Human ` +
127
- `Partner before mutating anything. If this same signature trips the ` +
128
- `breaker again, it hard-locks for a human decision.`
129
- );
130
- process.exit(0);
131
- }
132
-
133
- if ((state.zoomOutCycles || 0) >= 1) {
134
- blockForHumanDecision(state);
135
- }
136
- blockForReflection(state, reportFile);
137
- } catch (err) {
138
- // Fail open if state tracking breaks
139
- process.exit(0);
140
- }
141
- }
142
-
143
- // Fast path: skip stdin entirely unless some session's breaker is actually
144
- // tripped (also keeps manual terminal runs instant).
145
- let tripped = false;
146
- try {
147
- tripped = anySessionTripped(getWorkspaceRoot());
148
- } catch (err) {
149
- tripped = false; // fail open
150
- }
151
-
152
- if (!tripped) {
153
- process.exit(0);
154
- }
155
-
156
- if (process.stdin.isTTY) {
157
- // Manual run in a terminal - no payload is coming.
158
- main(null);
159
- } else {
160
- let raw = '';
161
- let finished = false;
162
- const finish = () => {
163
- if (finished) return;
164
- finished = true;
165
- let payload = null;
166
- try { payload = JSON.parse(raw); } catch (err) { /* no payload */ }
167
- main(payload);
168
- };
169
- // Claude Code closes stdin right after writing the payload; the timer is a
170
- // safety net so an odd caller that never closes stdin can't hang the hook.
171
- const timer = setTimeout(finish, 300);
172
- process.stdin.setEncoding('utf8');
173
- process.stdin.on('data', chunk => { raw += chunk; });
174
- process.stdin.on('end', () => { clearTimeout(timer); finish(); });
175
- process.stdin.on('error', () => { clearTimeout(timer); finish(); });
176
- }
1
+ #!/usr/bin/env node
2
+ // Rule of 3 circuit breaker (PreToolUse: Bash|PowerShell|Edit|Write).
3
+ //
4
+ // Tripping the breaker forces REFLECTION, not surrender. The most common
5
+ // agent failure mode is drilling deeper on one unverified assumption, so the
6
+ // breaker locks mutating tools and demands a zoom-out fact-check first
7
+ // (read-only tools stay available). A valid reflection report - written to
8
+ // the session's zoom-out-report.md (path given in the block message below) -
9
+ // releases the breaker again. Only a SECOND trip on the same failure
10
+ // signature - proof that reflection alone couldn't crack it - hard-locks the
11
+ // session until the Human Partner decides.
12
+ //
13
+ // State is scoped per Claude Code session_id (see lib/harness-state.js) so
14
+ // two sessions open on the same repo never share a trip count. The common
15
+ // case - nobody's breaker tripped anywhere - never has to read stdin to find
16
+ // that out; only once some session IS tripped do we pay to read the payload
17
+ // and check whether it's this one.
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ const { getWorkspaceRoot, getSessionDir, listSessionDirs } = require('./lib/harness-state');
21
+
22
+ const REQUIRED_SECTIONS = [
23
+ '## Goal',
24
+ '## Failed Attempts',
25
+ '## Verified Facts',
26
+ '## Diagnosis',
27
+ '## Decision'
28
+ ];
29
+
30
+ function readState(stateFile) {
31
+ if (!fs.existsSync(stateFile)) return null;
32
+ try { return JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch (err) { return null; }
33
+ }
34
+
35
+ function isTripped(state) {
36
+ return !!state && state.count >= 3 && !state.zoomOutResolved;
37
+ }
38
+
39
+ function anySessionTripped(root) {
40
+ return listSessionDirs(root).some(dir => isTripped(readState(path.join(dir, 'rule-of-3-state.json'))));
41
+ }
42
+
43
+ // The one mutation allowed while tripped: writing the reflection report.
44
+ function isReportWrite(payload, reportFile) {
45
+ if (!payload) return false;
46
+ if (payload.tool_name !== 'Write' && payload.tool_name !== 'Edit') return false;
47
+ const target = payload.tool_input && payload.tool_input.file_path;
48
+ if (!target) return false;
49
+ return path.resolve(target).toLowerCase() === path.resolve(reportFile).toLowerCase();
50
+ }
51
+
52
+ // A report only counts if it was written AFTER the failure that tripped the
53
+ // breaker (a stale report from an earlier loop can't unlock a new one), has
54
+ // every required section, and actually committed to a RESUME/ESCALATE call.
55
+ function reportIsValid(state, reportFile) {
56
+ if (!fs.existsSync(reportFile)) return false;
57
+ if (fs.statSync(reportFile).mtimeMs < (state.lastFailureAt || 0)) return false;
58
+ const text = fs.readFileSync(reportFile, 'utf8');
59
+ if (!REQUIRED_SECTIONS.every(h => text.includes(h))) return false;
60
+ return /\b(RESUME|ESCALATE)\b/.test(text);
61
+ }
62
+
63
+ function blockForReflection(state, reportFile) {
64
+ console.error(`[CRITICAL] RULE OF 3 CIRCUIT BREAKER TRIGGERED!`);
65
+ console.error(`The same failure signature has now occurred 3 times.`);
66
+ console.error(`Error Signature: ${state.lastHash}`);
67
+ console.error(`\nMutating tools (Bash/PowerShell/Edit/Write) are locked - not because you`);
68
+ console.error(`must wait for a human, but because you must stop drilling and rebuild the`);
69
+ console.error(`full picture first. Do NOT ask the Human Partner yet.`);
70
+ console.error(`\nACTION REQUIRED (reflect first):`);
71
+ console.error(`1. CEASE FIRE. No new fix attempts, no variations of the last one.`);
72
+ console.error(`2. Load the 'zoom-out' skill and follow its Reflect & Fact-Check protocol.`);
73
+ console.error(`3. Using READ-ONLY tools (Read/Grep/Glob - still available), re-verify the`);
74
+ console.error(` assumption behind each failed attempt against the actual code/logs/docs.`);
75
+ console.error(`4. Write your findings to '${reportFile}' (the ONLY write`);
76
+ console.error(` allowed right now) with sections: ## Goal, ## Failed Attempts,`);
77
+ console.error(` ## Verified Facts, ## Diagnosis, ## Decision (ending RESUME: or ESCALATE:).`);
78
+ console.error(`\nA valid report releases this breaker automatically. Escalate to the Human`);
79
+ console.error(`Partner ONLY if your Decision concludes a genuinely human call is needed`);
80
+ console.error(`(requirement conflict, architecture trade-off, destructive action, missing`);
81
+ console.error(`access) - and then present options with a recommendation, not apologies.`);
82
+ // For PreToolUse, only exit code 2 actually blocks the tool call.
83
+ // Exit 1 is a non-blocking error and Claude Code proceeds anyway.
84
+ process.exit(2);
85
+ }
86
+
87
+ function blockForHumanDecision(state) {
88
+ console.error(`[CRITICAL] RULE OF 3 CIRCUIT BREAKER TRIGGERED! (repeat trip - hard lock)`);
89
+ console.error(`Error Signature: ${state.lastHash}`);
90
+ console.error(`\nYou already completed a zoom-out reflection for this same failure signature`);
91
+ console.error(`and the fresh diagnosis failed too. This is now past reflect-and-retry:`);
92
+ console.error(`STOP and hand the decision to your Human Partner.`);
93
+ console.error(`\nPresent a DECISION REQUEST, not a plea: the goal, the verified facts, every`);
94
+ console.error(`path already falsified (including the post-reflection diagnosis), 2-3`);
95
+ console.error(`concrete options with trade-offs, and your recommendation.`);
96
+ console.error(`\nThis lock persists until the Human Partner clears it by running`);
97
+ console.error(`"npm run harness:reset" in their own terminal, or by starting a new`);
98
+ console.error(`session / running /clear (which resets it automatically on SessionStart).`);
99
+ process.exit(2);
100
+ }
101
+
102
+ function main(payload) {
103
+ try {
104
+ const root = getWorkspaceRoot();
105
+ const sessionDir = getSessionDir(root, payload && payload.session_id);
106
+ const stateFile = path.join(sessionDir, 'rule-of-3-state.json');
107
+ const reportFile = path.join(sessionDir, 'zoom-out-report.md');
108
+
109
+ const state = readState(stateFile);
110
+ if (!isTripped(state)) {
111
+ process.exit(0);
112
+ }
113
+
114
+ if (isReportWrite(payload, reportFile)) {
115
+ process.exit(0);
116
+ }
117
+
118
+ if (reportIsValid(state, reportFile)) {
119
+ state.count = 0;
120
+ state.zoomOutResolved = true;
121
+ state.zoomOutCycles = (state.zoomOutCycles || 0) + 1;
122
+ fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
123
+ console.log(
124
+ `[Rule of 3] Zoom-out report accepted - breaker released. Follow your ` +
125
+ `report's Decision: RESUME means one fresh run at the NEW diagnosis; ` +
126
+ `ESCALATE means present the decision request and WAIT for the Human ` +
127
+ `Partner before mutating anything. If this same signature trips the ` +
128
+ `breaker again, it hard-locks for a human decision.`
129
+ );
130
+ process.exit(0);
131
+ }
132
+
133
+ if ((state.zoomOutCycles || 0) >= 1) {
134
+ blockForHumanDecision(state);
135
+ }
136
+ blockForReflection(state, reportFile);
137
+ } catch (err) {
138
+ // Fail open if state tracking breaks
139
+ process.exit(0);
140
+ }
141
+ }
142
+
143
+ // Fast path: skip stdin entirely unless some session's breaker is actually
144
+ // tripped (also keeps manual terminal runs instant).
145
+ let tripped = false;
146
+ try {
147
+ tripped = anySessionTripped(getWorkspaceRoot());
148
+ } catch (err) {
149
+ tripped = false; // fail open
150
+ }
151
+
152
+ if (!tripped) {
153
+ process.exit(0);
154
+ }
155
+
156
+ if (process.stdin.isTTY) {
157
+ // Manual run in a terminal - no payload is coming.
158
+ main(null);
159
+ } else {
160
+ let raw = '';
161
+ let finished = false;
162
+ const finish = () => {
163
+ if (finished) return;
164
+ finished = true;
165
+ let payload = null;
166
+ try { payload = JSON.parse(raw); } catch (err) { /* no payload */ }
167
+ main(payload);
168
+ };
169
+ // Claude Code closes stdin right after writing the payload; the timer is a
170
+ // safety net so an odd caller that never closes stdin can't hang the hook.
171
+ const timer = setTimeout(finish, 300);
172
+ process.stdin.setEncoding('utf8');
173
+ process.stdin.on('data', chunk => { raw += chunk; });
174
+ process.stdin.on('end', () => { clearTimeout(timer); finish(); });
175
+ process.stdin.on('error', () => { clearTimeout(timer); finish(); });
176
+ }
@@ -1,44 +1,44 @@
1
- ---
2
- name: improve-codebase-architecture
3
- description: Discovers and transforms shallow modules into deep ones to improve testability and AI navigability.
4
- author: Miya Daniel | Harness Core Team
5
- version: 0.2.0
6
- ---
7
-
8
- # Improve Codebase Architecture (Deep Architectural Optimization)
9
-
10
- ## 📋 Skill Contract
11
-
12
- | Component | Specification |
13
- | :--- | :--- |
14
- | **Trigger / Input** | Project shows tech debt, overly coupled modules, or the user requests to "refactor / improve architecture quality". |
15
- | **Expected Output** | A "Deepening Opportunities" report naming shallow modules and improperly coupled seams, followed (after human approval) by `tdd`-guarded refactoring. |
16
- | **State Mutations** | Refactors module boundaries/interfaces; may add Characterization Tests before touching legacy code that has no existing coverage. |
17
- | **Enforcement Gate** | Blind refactoring is **PROHIBITED** — must scan `CONTEXT.md`/ADRs/interfaces first. Refactoring code with no test safety net **MUST** start with Characterization Tests. More than 3 cascading compile errors **MUST** trigger `zoom-out` and rollback, not continued patching. |
18
-
19
- Triggered when a project is full of "Tech Debt", modules are overly coupled, or the user requests to "refactor / improve architecture quality". This skill aims to transform "Shallow" modules into "Deep" modules to enhance testability and AI navigability.
20
-
21
- ## 1. Architectural Exploration & Discovery `[Discover]`
22
- - **Blind Refactoring Prohibited**: Before proposing any modification suggestions, you MUST first scan `CONTEXT.md`, `docs/adr/`, and core interface definitions (Interfaces/Types).
23
- - Identify "Shallow Modules" (interfaces that are complex but have very little internal implementation).
24
- - Identify improperly coupled boundaries (Seams).
25
-
26
- ## 2. Analysis & Proposal `[Think]`
27
- Use consistent domain terminology (Module, Interface, Implementation, Depth, Seam, Adapter) to communicate with the human.
28
- - Submit a "Deepening Opportunities" report to the user.
29
- - Explicitly point out which modules should be encapsulated and which boundaries (Seams) should be extracted into Adapters.
30
-
31
- ## 3. Implementation Refactoring `[Try]`
32
- - After gaining human approval, launch `tdd` mode.
33
- - **Iron Rule of Refactoring**: MUST be done under the safety net of test coverage. If there are no tests, the first step MUST be to "write Characterization Tests for the legacy code" before modifying the architecture.
34
-
35
- ## 4. Circuit Breaker & Evolution `[Summarize] & [Self-Evolve]`
36
- - If refactoring triggers more than 3 cascading compilation errors that cannot be fixed immediately, trigger the `zoom-out` circuit breaker and Rollback.
37
- - Write the discovered coupling traps into `self-evolve` memory, ensuring future newly generated code does not repeat the same mistakes.
38
-
39
- ## Deep Reference Guides
40
- For precise architectural paradigms and deep module analysis, refer to:
41
- - `improve-codebase-architecture/guides/DEEPENING.md` — Deepening opportunities & modular depth rules
42
- - `improve-codebase-architecture/guides/INTERFACE-DESIGN.md` — Principles of interface design and seams
43
- - `improve-codebase-architecture/guides/LANGUAGE.md` — Language-specific refactoring and pattern guidelines
44
- - `improve-codebase-architecture/guides/HTML-REPORT.md` — Creating visual reports with Mermaid diagrams
1
+ ---
2
+ name: improve-codebase-architecture
3
+ description: Discovers and transforms shallow modules into deep ones to improve testability and AI navigability.
4
+ author: Miya Daniel | Harness Core Team
5
+ version: 0.2.0
6
+ ---
7
+
8
+ # Improve Codebase Architecture (Deep Architectural Optimization)
9
+
10
+ ## 📋 Skill Contract
11
+
12
+ | Component | Specification |
13
+ | :--- | :--- |
14
+ | **Trigger / Input** | Project shows tech debt, overly coupled modules, or the user requests to "refactor / improve architecture quality". |
15
+ | **Expected Output** | A "Deepening Opportunities" report naming shallow modules and improperly coupled seams, followed (after human approval) by `tdd`-guarded refactoring. |
16
+ | **State Mutations** | Refactors module boundaries/interfaces; may add Characterization Tests before touching legacy code that has no existing coverage. |
17
+ | **Enforcement Gate** | Blind refactoring is **PROHIBITED** — must scan `CONTEXT.md`/ADRs/interfaces first. Refactoring code with no test safety net **MUST** start with Characterization Tests. More than 3 cascading compile errors **MUST** trigger `zoom-out` and rollback, not continued patching. |
18
+
19
+ Triggered when a project is full of "Tech Debt", modules are overly coupled, or the user requests to "refactor / improve architecture quality". This skill aims to transform "Shallow" modules into "Deep" modules to enhance testability and AI navigability.
20
+
21
+ ## 1. Architectural Exploration & Discovery `[Discover]`
22
+ - **Blind Refactoring Prohibited**: Before proposing any modification suggestions, you MUST first scan `CONTEXT.md`, `docs/adr/`, and core interface definitions (Interfaces/Types).
23
+ - Identify "Shallow Modules" (interfaces that are complex but have very little internal implementation).
24
+ - Identify improperly coupled boundaries (Seams).
25
+
26
+ ## 2. Analysis & Proposal `[Think]`
27
+ Use consistent domain terminology (Module, Interface, Implementation, Depth, Seam, Adapter) to communicate with the human.
28
+ - Submit a "Deepening Opportunities" report to the user.
29
+ - Explicitly point out which modules should be encapsulated and which boundaries (Seams) should be extracted into Adapters.
30
+
31
+ ## 3. Implementation Refactoring `[Try]`
32
+ - After gaining human approval, launch `tdd` mode.
33
+ - **Iron Rule of Refactoring**: MUST be done under the safety net of test coverage. If there are no tests, the first step MUST be to "write Characterization Tests for the legacy code" before modifying the architecture.
34
+
35
+ ## 4. Circuit Breaker & Evolution `[Summarize] & [Self-Evolve]`
36
+ - If refactoring triggers more than 3 cascading compilation errors that cannot be fixed immediately, trigger the `zoom-out` circuit breaker and Rollback.
37
+ - Write the discovered coupling traps into `self-evolve` memory, ensuring future newly generated code does not repeat the same mistakes.
38
+
39
+ ## Deep Reference Guides
40
+ For precise architectural paradigms and deep module analysis, refer to:
41
+ - `improve-codebase-architecture/guides/DEEPENING.md` — Deepening opportunities & modular depth rules
42
+ - `improve-codebase-architecture/guides/INTERFACE-DESIGN.md` — Principles of interface design and seams
43
+ - `improve-codebase-architecture/guides/LANGUAGE.md` — Language-specific refactoring and pattern guidelines
44
+ - `improve-codebase-architecture/guides/HTML-REPORT.md` — Creating visual reports with Mermaid diagrams