@harness-engineering/cli 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/personas/documentation-maintainer.yaml +3 -1
- package/dist/agents/personas/performance-guardian.yaml +23 -0
- package/dist/agents/skills/claude-code/align-documentation/SKILL.md +13 -0
- package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +25 -1
- package/dist/agents/skills/claude-code/cleanup-dead-code/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +12 -0
- package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +48 -1
- package/dist/agents/skills/claude-code/enforce-architecture/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/harness-accessibility/SKILL.md +7 -0
- package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +11 -3
- package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +81 -11
- package/dist/agents/skills/claude-code/harness-brainstorming/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +487 -234
- package/dist/agents/skills/claude-code/harness-code-review/skill.yaml +15 -2
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/skill.yaml +64 -0
- package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/claude-code/harness-docs-pipeline/skill.yaml +69 -0
- package/dist/agents/skills/claude-code/harness-execution/SKILL.md +73 -8
- package/dist/agents/skills/claude-code/harness-execution/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/claude-code/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/claude-code/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +17 -1
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +46 -5
- package/dist/agents/skills/claude-code/harness-perf/SKILL.md +37 -8
- package/dist/agents/skills/claude-code/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +17 -4
- package/dist/agents/skills/claude-code/harness-planning/SKILL.md +59 -5
- package/dist/agents/skills/claude-code/harness-planning/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +16 -0
- package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +561 -0
- package/dist/agents/skills/claude-code/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +36 -2
- package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +8 -6
- package/dist/agents/skills/claude-code/harness-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/claude-code/harness-soundness-review/skill.yaml +48 -0
- package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-verification/SKILL.md +66 -0
- package/dist/agents/skills/claude-code/harness-verification/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-verify/SKILL.md +11 -0
- package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +15 -1
- package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +12 -0
- package/dist/agents/skills/gemini-cli/add-harness-component/SKILL.md +192 -0
- package/dist/agents/skills/gemini-cli/add-harness-component/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/align-documentation/SKILL.md +213 -0
- package/dist/agents/skills/gemini-cli/align-documentation/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/check-mechanical-constraints/SKILL.md +191 -0
- package/dist/agents/skills/gemini-cli/check-mechanical-constraints/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/cleanup-dead-code/SKILL.md +245 -0
- package/dist/agents/skills/gemini-cli/cleanup-dead-code/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/detect-doc-drift/SKILL.md +179 -0
- package/dist/agents/skills/gemini-cli/detect-doc-drift/skill.yaml +30 -0
- package/dist/agents/skills/gemini-cli/enforce-architecture/SKILL.md +240 -0
- package/dist/agents/skills/gemini-cli/enforce-architecture/skill.yaml +34 -0
- package/dist/agents/skills/gemini-cli/harness-accessibility/SKILL.md +7 -0
- package/dist/agents/skills/gemini-cli/harness-architecture-advisor/SKILL.md +397 -0
- package/dist/agents/skills/gemini-cli/harness-architecture-advisor/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +11 -3
- package/dist/agents/skills/gemini-cli/harness-brainstorming/SKILL.md +317 -0
- package/dist/agents/skills/gemini-cli/harness-brainstorming/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-code-review/SKILL.md +681 -0
- package/dist/agents/skills/gemini-cli/harness-code-review/skill.yaml +45 -0
- package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/skill.yaml +64 -0
- package/dist/agents/skills/gemini-cli/harness-debugging/SKILL.md +366 -0
- package/dist/agents/skills/gemini-cli/harness-debugging/skill.yaml +47 -0
- package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +35 -6
- package/dist/agents/skills/gemini-cli/harness-diagnostics/SKILL.md +318 -0
- package/dist/agents/skills/gemini-cli/harness-diagnostics/skill.yaml +50 -0
- package/dist/agents/skills/gemini-cli/harness-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/gemini-cli/harness-docs-pipeline/skill.yaml +69 -0
- package/dist/agents/skills/gemini-cli/harness-execution/SKILL.md +382 -0
- package/dist/agents/skills/gemini-cli/harness-execution/skill.yaml +51 -0
- package/dist/agents/skills/gemini-cli/harness-git-workflow/SKILL.md +268 -0
- package/dist/agents/skills/gemini-cli/harness-git-workflow/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/gemini-cli/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/gemini-cli/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +35 -6
- package/dist/agents/skills/gemini-cli/harness-integrity/SKILL.md +167 -0
- package/dist/agents/skills/gemini-cli/harness-integrity/skill.yaml +47 -0
- package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +46 -5
- package/dist/agents/skills/gemini-cli/harness-onboarding/SKILL.md +288 -0
- package/dist/agents/skills/gemini-cli/harness-onboarding/skill.yaml +30 -0
- package/dist/agents/skills/gemini-cli/harness-parallel-agents/SKILL.md +171 -0
- package/dist/agents/skills/gemini-cli/harness-parallel-agents/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +37 -8
- package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +17 -4
- package/dist/agents/skills/gemini-cli/harness-planning/SKILL.md +389 -0
- package/dist/agents/skills/gemini-cli/harness-planning/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-pre-commit-review/SKILL.md +262 -0
- package/dist/agents/skills/gemini-cli/harness-pre-commit-review/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-refactoring/SKILL.md +169 -0
- package/dist/agents/skills/gemini-cli/harness-refactoring/skill.yaml +33 -0
- package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +16 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +561 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +8 -6
- package/dist/agents/skills/gemini-cli/harness-skill-authoring/SKILL.md +292 -0
- package/dist/agents/skills/gemini-cli/harness-skill-authoring/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/harness-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/gemini-cli/harness-soundness-review/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-state-management/SKILL.md +309 -0
- package/dist/agents/skills/gemini-cli/harness-state-management/skill.yaml +32 -0
- package/dist/agents/skills/gemini-cli/harness-tdd/SKILL.md +177 -0
- package/dist/agents/skills/gemini-cli/harness-tdd/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +35 -6
- package/dist/agents/skills/gemini-cli/harness-verification/SKILL.md +328 -0
- package/dist/agents/skills/gemini-cli/harness-verification/skill.yaml +42 -0
- package/dist/agents/skills/gemini-cli/harness-verify/SKILL.md +159 -0
- package/dist/agents/skills/gemini-cli/harness-verify/skill.yaml +40 -0
- package/dist/agents/skills/gemini-cli/initialize-harness-project/SKILL.md +224 -0
- package/dist/agents/skills/gemini-cli/initialize-harness-project/skill.yaml +31 -0
- package/dist/agents/skills/gemini-cli/validate-context-engineering/SKILL.md +150 -0
- package/dist/agents/skills/gemini-cli/validate-context-engineering/skill.yaml +31 -0
- package/dist/agents/skills/shared/i18n-knowledge/accessibility/intersection.yaml +142 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/encoding.yaml +67 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/formatting.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/layout.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/pluralization.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/string-handling.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/android-resources.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/apple-strings.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/backend-patterns.yaml +50 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/flutter-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/i18next.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/react-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/vue-i18n.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/ecommerce.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/fintech.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/gaming.yaml +69 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/healthcare.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/legal.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ar.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/de.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/en.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/es.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/he.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/hi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/it.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ja.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ko.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/nl.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pl.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pt.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ru.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/sv.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/th.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/tr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hans.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hant.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/i18next-mcp.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lingo-dev.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lokalise.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/tolgee.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/locale-testing.yaml +107 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/pseudo-localization.yaml +86 -0
- package/dist/bin/harness.js +64 -4
- package/dist/{chunk-GA6GN5J2.js → chunk-E2RTDBMG.js} +2263 -41
- package/dist/{chunk-FFIX3QVG.js → chunk-KJANDVVC.js} +141 -49
- package/dist/{chunk-4WUGOJQ7.js → chunk-RT2LYQHF.js} +1 -1
- package/dist/{dist-C4J67MPP.js → dist-CCM3L3UE.js} +95 -1
- package/dist/{dist-N4D4QWFV.js → dist-K6KTTN3I.js} +4 -4
- package/dist/index.d.ts +187 -7
- package/dist/index.js +7 -3
- package/dist/validate-cross-check-ZGKFQY57.js +7 -0
- package/package.json +9 -9
- package/dist/agents/skills/node_modules/.bin/glob +0 -17
- package/dist/agents/skills/node_modules/.bin/vitest +0 -17
- package/dist/agents/skills/node_modules/.bin/yaml +0 -17
- package/dist/templates/advanced/docs/specs/.gitkeep +0 -0
- package/dist/templates/intermediate/docs/specs/.gitkeep +0 -0
- package/dist/validate-cross-check-WGXQ7K62.js +0 -7
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: harness-pre-commit-review
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
description: Lightweight pre-commit quality gate combining mechanical checks and AI review
|
|
4
|
+
triggers: [manual, on_commit]
|
|
5
|
+
platforms: [claude-code, gemini-cli]
|
|
6
|
+
tools: [Bash, Read, Glob, Grep]
|
|
7
|
+
cli:
|
|
8
|
+
command: harness skill run harness-pre-commit-review
|
|
9
|
+
args:
|
|
10
|
+
- name: path
|
|
11
|
+
description: Project root path
|
|
12
|
+
required: false
|
|
13
|
+
mcp:
|
|
14
|
+
tool: run_skill
|
|
15
|
+
input:
|
|
16
|
+
skill: harness-pre-commit-review
|
|
17
|
+
path: string
|
|
18
|
+
type: rigid
|
|
19
|
+
phases:
|
|
20
|
+
- name: mechanical-checks
|
|
21
|
+
description: Run deterministic checks (lint, typecheck, tests)
|
|
22
|
+
required: true
|
|
23
|
+
- name: classify-changes
|
|
24
|
+
description: Determine if AI review is needed based on change type
|
|
25
|
+
required: true
|
|
26
|
+
- name: ai-review
|
|
27
|
+
description: Lightweight AI review of staged changes (skipped for docs/config-only)
|
|
28
|
+
required: false
|
|
29
|
+
state:
|
|
30
|
+
persistent: false
|
|
31
|
+
files: []
|
|
32
|
+
depends_on:
|
|
33
|
+
- harness-code-review
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Harness Refactoring
|
|
2
|
+
|
|
3
|
+
> Safe refactoring with constraint verification at every step. Change structure without changing behavior, with harness checks as your safety net.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- When improving code structure, readability, or maintainability without changing behavior
|
|
8
|
+
- When reducing duplication (DRY refactoring)
|
|
9
|
+
- When moving code to the correct architectural layer
|
|
10
|
+
- When splitting large files or functions into smaller, focused ones
|
|
11
|
+
- When renaming for clarity across the codebase
|
|
12
|
+
- After completing a feature (post-TDD cleanup beyond single-cycle refactoring)
|
|
13
|
+
- NOT when adding new behavior (use harness-tdd instead)
|
|
14
|
+
- NOT when fixing bugs (use harness-tdd — write a failing test first)
|
|
15
|
+
- NOT when the test suite is already failing — fix the tests before refactoring
|
|
16
|
+
|
|
17
|
+
## Process
|
|
18
|
+
|
|
19
|
+
### Iron Rule
|
|
20
|
+
|
|
21
|
+
**All tests must pass BEFORE you start refactoring and AFTER every single change.**
|
|
22
|
+
|
|
23
|
+
If tests are not green before you start, you are not refactoring — you are debugging. Fix the tests first. If tests break during refactoring, undo the last change immediately. Do not try to fix forward.
|
|
24
|
+
|
|
25
|
+
### Phase 1: Prepare — Verify Starting State
|
|
26
|
+
|
|
27
|
+
1. **Run the full test suite.** Every test must pass. Record the count of passing tests — this number must not decrease at any point.
|
|
28
|
+
|
|
29
|
+
2. **Run `harness validate`** and **`harness check-deps`**. Both must pass. You are establishing a clean baseline. If either reports issues, fix those first (that is a separate task, not part of this refactoring).
|
|
30
|
+
|
|
31
|
+
3. **Identify the refactoring target.** Be specific: which file, function, class, or module? What is wrong with the current structure? What will be better after refactoring?
|
|
32
|
+
|
|
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
|
+
|
|
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
|
+
|
|
44
|
+
### Phase 2: Execute — One Small Change at a Time
|
|
45
|
+
|
|
46
|
+
For EACH step in the plan:
|
|
47
|
+
|
|
48
|
+
1. **Make ONE small change.** Examples of "one small change":
|
|
49
|
+
- Rename one variable or function
|
|
50
|
+
- Extract one function from a larger function
|
|
51
|
+
- Move one function to a different file
|
|
52
|
+
- Inline one unnecessary abstraction
|
|
53
|
+
- Replace one conditional with polymorphism
|
|
54
|
+
- Remove one instance of duplication
|
|
55
|
+
|
|
56
|
+
2. **Run the full test suite.** All tests must pass. If any test fails:
|
|
57
|
+
- **STOP immediately.**
|
|
58
|
+
- **Undo the change** (git checkout the file or revert manually).
|
|
59
|
+
- **Analyze why it broke.** Either the change was not purely structural (it changed behavior) or the tests are coupled to implementation details.
|
|
60
|
+
- **Try a smaller step** or a different approach.
|
|
61
|
+
|
|
62
|
+
3. **Run `harness validate` and `harness check-deps`.** Both must pass. A refactoring that fixes code structure but violates architectural constraints is not safe.
|
|
63
|
+
|
|
64
|
+
4. **Commit the step.** Each step gets its own commit. The commit message describes the structural change: "extract validateInput from processOrder" or "move UserRepository to data-access layer."
|
|
65
|
+
|
|
66
|
+
5. **Repeat** for the next step in the plan.
|
|
67
|
+
|
|
68
|
+
### Phase 3: Verify — Confirm the Refactoring is Complete
|
|
69
|
+
|
|
70
|
+
1. **Run the full test suite one final time.** Same number of passing tests as Phase 1.
|
|
71
|
+
|
|
72
|
+
2. **Run `harness validate` and `harness check-deps` one final time.** Clean output.
|
|
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
|
+
|
|
84
|
+
3. **Review the cumulative diff.** Does the final state match the intended improvement? Is the code genuinely better, or just different?
|
|
85
|
+
|
|
86
|
+
4. **If the refactoring introduced no improvement,** revert the entire sequence. Refactoring for its own sake is churn.
|
|
87
|
+
|
|
88
|
+
## Common Refactoring Patterns
|
|
89
|
+
|
|
90
|
+
### Extract Function
|
|
91
|
+
|
|
92
|
+
**When:** A function is doing too many things, or a block of code is reused in multiple places.
|
|
93
|
+
**How:** Identify the block. Ensure all variables it uses are either parameters or local. Cut the block into a new function with a descriptive name. Replace the original block with a call to the new function.
|
|
94
|
+
**Harness guidance:** If the extracted function belongs in a different layer, move it there AND update the import. Run `harness check-deps` to verify the new import respects layer boundaries.
|
|
95
|
+
|
|
96
|
+
### Move to Layer
|
|
97
|
+
|
|
98
|
+
**When:** Code is in the wrong architectural layer (e.g., business logic in a UI component, database queries in a service).
|
|
99
|
+
**How:** Create the function in the correct layer. Update all callers to import from the new location. Delete the old function. Run `harness check-deps` after each step.
|
|
100
|
+
**Harness guidance:** This is where `harness check-deps` is most valuable. Moving code between layers changes the dependency graph. The tool will tell you immediately if the move created a violation.
|
|
101
|
+
|
|
102
|
+
### Split File
|
|
103
|
+
|
|
104
|
+
**When:** A file has grown too large or contains unrelated responsibilities.
|
|
105
|
+
**How:** Identify the cohesive groups within the file. Create new files, one per group. Move functions/classes to their new files. Update the original file to re-export from the new files (for backward compatibility) or update all callers.
|
|
106
|
+
**Harness guidance:** Run `harness validate` after splitting to ensure the new files follow naming conventions and are properly structured. Run `harness check-deps` to verify no new boundary violations.
|
|
107
|
+
|
|
108
|
+
### Inline Abstraction
|
|
109
|
+
|
|
110
|
+
**When:** An abstraction (class, interface, wrapper function) adds complexity without value. It has only one implementation, is never extended, and obscures what the code actually does.
|
|
111
|
+
**How:** Replace uses of the abstraction with the concrete implementation. Delete the abstraction. Run tests.
|
|
112
|
+
**Harness guidance:** Removing an abstraction may expose a layer violation that the abstraction was hiding. Run `harness check-deps` to check.
|
|
113
|
+
|
|
114
|
+
### Rename for Clarity
|
|
115
|
+
|
|
116
|
+
**When:** A name is misleading, ambiguous, or no longer reflects what the code does.
|
|
117
|
+
**How:** Use your editor's rename/refactor tool to change the name everywhere it appears. If the name is part of a public API, check for external consumers first.
|
|
118
|
+
**Harness guidance:** Run `harness check-docs` after renaming to detect documentation that still uses the old name. AGENTS.md, inline comments, and doc pages may all need updating.
|
|
119
|
+
|
|
120
|
+
## Harness Integration
|
|
121
|
+
|
|
122
|
+
- **`harness validate`** — Run before starting, after each step, and at the end. Catches structural issues, naming violations, and configuration drift.
|
|
123
|
+
- **`harness check-deps`** — Run after each step, especially when moving code between files or layers. Catches dependency violations introduced by structural changes.
|
|
124
|
+
- **`harness check-docs`** — Run after renaming or moving public APIs. Catches documentation that references old names or locations.
|
|
125
|
+
- **`harness cleanup`** — Run after completing a refactoring sequence. Detects dead code that the refactoring may have created (unused exports, orphaned files).
|
|
126
|
+
|
|
127
|
+
## Success Criteria
|
|
128
|
+
|
|
129
|
+
- All tests pass before, during, and after refactoring (same count, same results)
|
|
130
|
+
- `harness validate` passes at every step
|
|
131
|
+
- `harness check-deps` passes at every step
|
|
132
|
+
- Each step is an atomic commit with a clear structural description
|
|
133
|
+
- The code is measurably better after refactoring (clearer names, less duplication, correct layering, smaller functions)
|
|
134
|
+
- No behavioral changes were introduced (the test suite is the proof)
|
|
135
|
+
- No dead code was left behind (run `harness cleanup` to verify)
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
### Example: Moving business logic out of a UI component
|
|
140
|
+
|
|
141
|
+
**Target:** `src/components/OrderSummary.tsx` contains a `calculateDiscount()` function with complex business rules. This logic belongs in the service layer.
|
|
142
|
+
|
|
143
|
+
**Step 1:** Create `src/services/discount-service.ts` with the `calculateDiscount` function copied from the component.
|
|
144
|
+
|
|
145
|
+
- Run tests: pass
|
|
146
|
+
- Run `harness check-deps`: pass (new file, no violations)
|
|
147
|
+
- Commit: "extract calculateDiscount to discount-service"
|
|
148
|
+
|
|
149
|
+
**Step 2:** Update `OrderSummary.tsx` to import `calculateDiscount` from `discount-service` instead of using the local function.
|
|
150
|
+
|
|
151
|
+
- Run tests: pass
|
|
152
|
+
- Run `harness check-deps`: pass (UI importing from service is allowed)
|
|
153
|
+
- Commit: "update OrderSummary to use discount-service"
|
|
154
|
+
|
|
155
|
+
**Step 3:** Delete the original `calculateDiscount` function from `OrderSummary.tsx`.
|
|
156
|
+
|
|
157
|
+
- Run tests: pass
|
|
158
|
+
- Run `harness check-deps`: pass
|
|
159
|
+
- Run `harness cleanup`: no dead code detected
|
|
160
|
+
- Commit: "remove duplicate calculateDiscount from OrderSummary"
|
|
161
|
+
|
|
162
|
+
**Final verification:** 3 steps, 3 commits, all tests green throughout, all harness checks passing. The business logic is now in the correct layer.
|
|
163
|
+
|
|
164
|
+
## Escalation
|
|
165
|
+
|
|
166
|
+
- **When tests fail during refactoring and you cannot figure out why:** Revert to the last green commit. The test failure means the change was not purely structural. Analyze the test to understand what behavioral assumption it depends on, then plan a different approach.
|
|
167
|
+
- **When `harness check-deps` fails after a move:** The code you moved may have dependencies that are not allowed in its new layer. You may need to refactor the moved code itself (remove forbidden imports) before it can live in the new layer.
|
|
168
|
+
- **When a refactoring requires changing tests:** This is a warning sign. If the tests need to change, the refactoring may be changing behavior. The only valid reason to change tests during refactoring is if the tests were testing implementation details (not behavior) — and in that case, fix the tests first as a separate step before refactoring.
|
|
169
|
+
- **When the refactoring scope keeps growing:** Stop. Commit what you have (if it is clean). Re-plan with a smaller scope. Large refactorings should be broken into multiple sessions, each leaving the code in a better state.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: harness-refactoring
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
description: Safe refactoring with validation before and after changes
|
|
4
|
+
cognitive_mode: meticulous-implementer
|
|
5
|
+
triggers:
|
|
6
|
+
- manual
|
|
7
|
+
- on_refactor
|
|
8
|
+
platforms:
|
|
9
|
+
- claude-code
|
|
10
|
+
- gemini-cli
|
|
11
|
+
tools:
|
|
12
|
+
- Bash
|
|
13
|
+
- Read
|
|
14
|
+
- Write
|
|
15
|
+
- Edit
|
|
16
|
+
- Glob
|
|
17
|
+
- Grep
|
|
18
|
+
cli:
|
|
19
|
+
command: harness skill run harness-refactoring
|
|
20
|
+
args:
|
|
21
|
+
- name: path
|
|
22
|
+
description: Project root path
|
|
23
|
+
required: false
|
|
24
|
+
mcp:
|
|
25
|
+
tool: run_skill
|
|
26
|
+
input:
|
|
27
|
+
skill: harness-refactoring
|
|
28
|
+
path: string
|
|
29
|
+
type: flexible
|
|
30
|
+
state:
|
|
31
|
+
persistent: false
|
|
32
|
+
files: []
|
|
33
|
+
depends_on: []
|
|
@@ -113,6 +113,20 @@ Run every check below. Record each as **pass**, **warn**, or **fail**:
|
|
|
113
113
|
| `typecheck` or `tsc` script exists in root `package.json` | fail |
|
|
114
114
|
| `harness validate` passes (project-level health check) | fail |
|
|
115
115
|
|
|
116
|
+
##### i18n Coverage (conditional)
|
|
117
|
+
|
|
118
|
+
When `i18n.enabled: true` in `harness.config.json`, run these checks:
|
|
119
|
+
|
|
120
|
+
| Check | Severity if failing |
|
|
121
|
+
| ---------------------------------------------------------------------------------------------- | ------------------------------- |
|
|
122
|
+
| Translation coverage meets `i18n.coverage.minimumPercent` for all target locales | fail (strict) / warn (standard) |
|
|
123
|
+
| No untranslated values (source text in target locale files) when `coverage.detectUntranslated` | warn |
|
|
124
|
+
| All CLDR plural forms present for target locales when `coverage.requirePlurals` | warn |
|
|
125
|
+
| No stale translations (source changed since last translation timestamp) | warn |
|
|
126
|
+
| `harness-i18n` scan passes with zero errors | fail (strict) / warn (standard) |
|
|
127
|
+
|
|
128
|
+
If `i18n.enabled` is false or the `i18n` config block is absent, skip this section entirely and report it as "N/A" in the audit output.
|
|
129
|
+
|
|
116
130
|
#### Comprehensive Checks (only with `--comprehensive`)
|
|
117
131
|
|
|
118
132
|
These checks run only when `--comprehensive` is passed. They are slower and may require network access.
|
|
@@ -160,6 +174,7 @@ Packaging: 8/12 passed, 2 warnings, 2 failures
|
|
|
160
174
|
Docs: 5/6 passed, 1 warning, 0 failures
|
|
161
175
|
Hygiene: 3/5 passed, 2 warnings, 0 failures
|
|
162
176
|
CI/CD: 4/5 passed, 1 warning, 0 failures
|
|
177
|
+
i18n: N/N passed, N warnings, N failures (or: skipped — i18n not enabled)
|
|
163
178
|
[comprehensive] API Docs: skipped (use --comprehensive)
|
|
164
179
|
[comprehensive] Examples: skipped (use --comprehensive)
|
|
165
180
|
[comprehensive] Dep Health: skipped (use --comprehensive)
|
|
@@ -496,6 +511,7 @@ This framing is informational — it does not block anything. It gives the team
|
|
|
496
511
|
- **Sub-skill invocations** — Phase 2 dispatches `detect-doc-drift`, `cleanup-dead-code`, `enforce-architecture`, and `diagnostics` as parallel agents. Phase 3 delegates fixes to `align-documentation` and `cleanup-dead-code`.
|
|
497
512
|
- **State file** — `.harness/release-readiness.json` enables session resumption and progress tracking. This file is read at the start of each invocation and written at the end.
|
|
498
513
|
- **Report file** — `release-readiness-report.md` is written to the project root. It is a snapshot, not a tracked artifact — regenerate it on each run.
|
|
514
|
+
- **i18n coverage** — When `i18n.enabled: true`, Phase 1 checks translation coverage against configured thresholds. Uses `harness-i18n` scan results and `harness-i18n-workflow` coverage tracking. Blocks release in strict mode if coverage is below `i18n.coverage.minimumPercent`.
|
|
499
515
|
|
|
500
516
|
## Success Criteria
|
|
501
517
|
|