@harness-engineering/cli 1.2.0 → 1.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 (52) hide show
  1. package/dist/bin/harness.js +1 -1
  2. package/dist/{chunk-IXT3KLVN.js → chunk-5RQKSZLA.js} +4 -3
  3. package/dist/index.js +1 -1
  4. package/package.json +6 -4
  5. package/dist/agents/commands/claude-code/harness/add-component.md +0 -34
  6. package/dist/agents/commands/claude-code/harness/align-documentation.md +0 -33
  7. package/dist/agents/commands/claude-code/harness/architecture-advisor.md +0 -41
  8. package/dist/agents/commands/claude-code/harness/brainstorming.md +0 -42
  9. package/dist/agents/commands/claude-code/harness/check-mechanical-constraints.md +0 -32
  10. package/dist/agents/commands/claude-code/harness/cleanup-dead-code.md +0 -33
  11. package/dist/agents/commands/claude-code/harness/code-review.md +0 -33
  12. package/dist/agents/commands/claude-code/harness/debugging.md +0 -43
  13. package/dist/agents/commands/claude-code/harness/detect-doc-drift.md +0 -32
  14. package/dist/agents/commands/claude-code/harness/diagnostics.md +0 -43
  15. package/dist/agents/commands/claude-code/harness/enforce-architecture.md +0 -32
  16. package/dist/agents/commands/claude-code/harness/execution.md +0 -43
  17. package/dist/agents/commands/claude-code/harness/git-workflow.md +0 -32
  18. package/dist/agents/commands/claude-code/harness/initialize-project.md +0 -33
  19. package/dist/agents/commands/claude-code/harness/onboarding.md +0 -32
  20. package/dist/agents/commands/claude-code/harness/parallel-agents.md +0 -35
  21. package/dist/agents/commands/claude-code/harness/planning.md +0 -41
  22. package/dist/agents/commands/claude-code/harness/pre-commit-review.md +0 -38
  23. package/dist/agents/commands/claude-code/harness/refactoring.md +0 -35
  24. package/dist/agents/commands/claude-code/harness/skill-authoring.md +0 -35
  25. package/dist/agents/commands/claude-code/harness/state-management.md +0 -35
  26. package/dist/agents/commands/claude-code/harness/tdd.md +0 -42
  27. package/dist/agents/commands/claude-code/harness/validate-context-engineering.md +0 -32
  28. package/dist/agents/commands/claude-code/harness/verification.md +0 -38
  29. package/dist/agents/commands/gemini-cli/harness/add-component.toml +0 -240
  30. package/dist/agents/commands/gemini-cli/harness/align-documentation.toml +0 -238
  31. package/dist/agents/commands/gemini-cli/harness/architecture-advisor.toml +0 -469
  32. package/dist/agents/commands/gemini-cli/harness/brainstorming.toml +0 -326
  33. package/dist/agents/commands/gemini-cli/harness/check-mechanical-constraints.toml +0 -249
  34. package/dist/agents/commands/gemini-cli/harness/cleanup-dead-code.toml +0 -258
  35. package/dist/agents/commands/gemini-cli/harness/code-review.toml +0 -461
  36. package/dist/agents/commands/gemini-cli/harness/debugging.toml +0 -436
  37. package/dist/agents/commands/gemini-cli/harness/detect-doc-drift.toml +0 -215
  38. package/dist/agents/commands/gemini-cli/harness/diagnostics.toml +0 -401
  39. package/dist/agents/commands/gemini-cli/harness/enforce-architecture.toml +0 -222
  40. package/dist/agents/commands/gemini-cli/harness/execution.toml +0 -381
  41. package/dist/agents/commands/gemini-cli/harness/git-workflow.toml +0 -325
  42. package/dist/agents/commands/gemini-cli/harness/initialize-project.toml +0 -257
  43. package/dist/agents/commands/gemini-cli/harness/onboarding.toml +0 -316
  44. package/dist/agents/commands/gemini-cli/harness/parallel-agents.toml +0 -221
  45. package/dist/agents/commands/gemini-cli/harness/planning.toml +0 -405
  46. package/dist/agents/commands/gemini-cli/harness/pre-commit-review.toml +0 -294
  47. package/dist/agents/commands/gemini-cli/harness/refactoring.toml +0 -209
  48. package/dist/agents/commands/gemini-cli/harness/skill-authoring.toml +0 -350
  49. package/dist/agents/commands/gemini-cli/harness/state-management.toml +0 -354
  50. package/dist/agents/commands/gemini-cli/harness/tdd.toml +0 -247
  51. package/dist/agents/commands/gemini-cli/harness/validate-context-engineering.toml +0 -186
  52. package/dist/agents/commands/gemini-cli/harness/verification.toml +0 -334
@@ -1,326 +0,0 @@
1
- # Generated by harness generate-slash-commands. Do not edit.
2
- description = "Structured ideation and exploration with harness methodology"
3
- prompt = """
4
- <context>
5
- Cognitive mode: constructive-architect
6
- Type: rigid
7
- </context>
8
-
9
- <objective>
10
- Structured ideation and exploration with harness methodology
11
-
12
- Phases:
13
- - explore: Generate ideas and possibilities
14
- - evaluate: Assess ideas against constraints
15
- - prioritize: Select and sequence top ideas
16
- - validate: Run harness checks on selected approach
17
- </objective>
18
-
19
- <execution_context>
20
- --- SKILL.md (agents/skills/claude-code/harness-brainstorming/SKILL.md) ---
21
- # Harness Brainstorming
22
-
23
- > Design exploration to spec to plan. No implementation before design approval. Think first, build second.
24
-
25
- ## When to Use
26
-
27
- - Starting a new feature or project that requires design decisions
28
- - When the problem space is ambiguous and needs exploration before planning
29
- - When multiple implementation approaches exist and tradeoffs must be weighed
30
- - When `on_new_feature` trigger fires and the scope is non-trivial
31
- - NOT when the implementation path is already clear (go straight to harness-planning)
32
- - NOT when fixing a bug with an obvious root cause (use harness-debugging or harness-tdd)
33
- - NOT when the task is a simple refactor with no design decisions (use harness-refactoring)
34
-
35
- ## Process
36
-
37
- ### Iron Law
38
-
39
- **No implementation may begin before the design is approved by the human.**
40
-
41
- If you find yourself writing production code, tests, or scaffolding before the human has signed off on the design, STOP. You are in the wrong skill. Brainstorming produces a spec document, not code.
42
-
43
- ---
44
-
45
- ### Phase 1: EXPLORE — Gather Context
46
-
47
- 1. **Read the existing codebase.** Understand the current architecture, constraints, and conventions. Check AGENTS.md, existing specs in `docs/`, and relevant source files.
48
-
49
- 2. **Identify the problem boundary.** What exactly needs to be solved? What is explicitly out of scope? Write down both.
50
-
51
- 3. **Check for prior art.** Has this problem been partially solved elsewhere in the codebase? Are there existing patterns that should be followed or deliberately broken?
52
-
53
- 4. **Assess scope.** If the problem spans more than 3 major subsystems or would take more than 2 weeks to implement, it is too large. Decompose into sub-projects first, then brainstorm each one separately.
54
-
55
- ---
56
-
57
- ### Phase 2: EVALUATE — Ask Questions and Narrow
58
-
59
- 1. **Ask ONE question at a time.** Do not dump a list of 10 questions on the human. Ask the most important question first. Wait for the answer. Let the answer inform the next question.
60
-
61
- 2. **Prefer multiple choice.** Instead of "How should we handle auth?", ask "For auth, should we: (A) use existing JWT middleware, (B) add OAuth2 via provider X, or (C) delegate to an external service?" Give 2-4 concrete options with brief tradeoff notes.
62
-
63
- 3. **When the human answers, acknowledge and build on it.** Do not re-ask clarified points. Track decisions as they accumulate.
64
-
65
- 4. **Apply YAGNI ruthlessly.** For every proposed capability, ask: "Do we need this for the stated goal, or is this speculative?" If speculative, cut it. If the human insists, note it as a future consideration, not a requirement.
66
-
67
- 5. **Continue until you have enough clarity** to propose concrete approaches. Typically 3-7 questions are sufficient. If you need more than 10, the scope is too large — decompose.
68
-
69
- ### Context Keywords
70
-
71
- During Phase 2, extract 5-10 domain keywords that capture the problem space. Include them in the spec frontmatter:
72
-
73
- ```
74
- **Keywords:** auth, middleware, session-tokens, refresh-flow, OAuth2
75
- ```
76
-
77
- These keywords flow into the `handoff.json` `contextKeywords` field when the spec is handed off to planning. Select keywords that would help a fresh agent — one that has never seen this conversation — understand the domain area quickly.
78
-
79
- ---
80
-
81
- ### Phase 3: PRIORITIZE — Propose Approaches
82
-
83
- 1. **Propose 2-3 concrete approaches.** Not 1 (no choice), not 5 (decision paralysis). Each approach must include:
84
- - **Summary:** One sentence describing the approach
85
- - **How it works:** Key technical decisions (what data structures, what APIs, what patterns)
86
- - **Tradeoffs:** What you gain, what you lose, what gets harder later
87
- - **Estimated complexity:** Low / Medium / High, with a brief justification
88
- - **Risk:** What could go wrong, what assumptions might be wrong
89
-
90
- 2. **Be honest about tradeoffs.** Do not soft-sell a preferred approach. If approach A is simpler but less extensible, say so plainly.
91
-
92
- 3. **State your recommendation** and why, but defer to the human's decision.
93
-
94
- 4. **Wait for the human to choose.** Do not proceed until an approach is selected.
95
-
96
- ---
97
-
98
- ### Phase 4: VALIDATE — Write the Spec
99
-
100
- 1. **Present the design section by section.** Do not dump the entire spec at once. Present each major section, get feedback, and incorporate it before moving to the next:
101
- - Overview and goals
102
- - Decisions made (with rationale from the brainstorming conversation)
103
- - Technical design (data structures, APIs, file layout)
104
- - Success criteria (observable, testable outcomes)
105
- - Implementation order (high-level phases, not detailed tasks — that is harness-planning's job)
106
-
107
- 2. **After all sections are reviewed, write the spec to `docs/`.** Use the project's existing spec naming convention. If none exists, use `docs/specs/YYYY-MM-DD-<feature-name>.md`.
108
-
109
- When the project has `docs/specs/`, write proposals to `docs/changes/<feature>/proposal.md` instead. This keeps change proposals separate from established specs. Fall back to the existing behavior (`docs/specs/`) when no `docs/specs/` directory exists yet.
110
-
111
- 3. **Run `harness validate`** to verify the spec file is properly placed and the project remains healthy.
112
-
113
- 4. **Ask for final sign-off.** Present the complete spec file path and a one-paragraph summary. The human must explicitly approve before this skill is complete.
114
-
115
- ---
116
-
117
- ### Scope Check
118
-
119
- At any point during brainstorming, if the design reveals that the project is larger than initially expected:
120
-
121
- 1. **Identify natural decomposition boundaries.** Where can the project be split into independently deliverable pieces?
122
- 2. **Propose sub-projects.** Each sub-project should be brainstormable and plannable on its own.
123
- 3. **Get approval for the decomposition** before continuing to brainstorm any individual sub-project.
124
-
125
- ## Party Mode
126
-
127
- When activated with `--party`, add a multi-perspective evaluation step after proposing approaches.
128
-
129
- ### Perspective Selection
130
-
131
- Select 2-3 perspectives based on design topic:
132
-
133
- | Topic | Perspectives |
134
- | -------------- | -------------------------------------------- |
135
- | API / backend | Backend Developer, API Consumer, Operations |
136
- | UI / frontend | Developer, Designer, End User |
137
- | Infrastructure | Architect, SRE, Developer |
138
- | Data model | Backend Developer, Data Consumer, Migration |
139
- | Library / SDK | Library Author, Library Consumer, Maintainer |
140
- | Cross-cutting | Architect, Security, Developer |
141
- | Default | Architect, Developer, User/Consumer |
142
-
143
- ### Evaluation Process
144
-
145
- For each proposed approach, evaluate from each perspective:
146
-
147
- ```
148
- ### Approach N: [name]
149
-
150
- **[Perspective 1] perspective:**
151
- [Assessment]. Concern: [specific concern or "None"].
152
-
153
- **[Perspective 2] perspective:**
154
- [Assessment]. Concern: [specific concern or "None"].
155
-
156
- **[Perspective 3] perspective:**
157
- [Assessment]. Concern: [specific concern or "None"].
158
-
159
- **Synthesis:** [Consensus summary. Address raised concerns. Recommend proceed/revise.]
160
- ```
161
-
162
- Converge on a recommendation that addresses all concerns before presenting the design.
163
-
164
- ## Harness Integration
165
-
166
- - **`harness validate`** — Run after writing the spec to `docs/`. Verifies project health and that the new spec file is properly placed.
167
- - **`harness check-docs`** — Run to verify the spec does not conflict with existing documentation.
168
- - **Spec location** — Specs go to `docs/` (or `docs/specs/` if the project uses that convention). Follow existing naming patterns.
169
- - **Handoff to harness-planning** — Once the spec is approved, invoke harness-planning to create the implementation plan from the spec.
170
-
171
- #### Requirement Phrasing
172
-
173
- When brainstorming produces requirements or acceptance criteria that will feed into planning, prefer EARS sentence patterns for behavioral requirements. See the EARS Requirement Patterns section in harness-planning for the full template reference. Key patterns:
174
-
175
- - **Event-driven:** "When [trigger], the system shall [response]."
176
- - **Unwanted:** "If [condition], then the system shall not [behavior]."
177
-
178
- These patterns make requirements testable and unambiguous. Apply them when the output of brainstorming includes specific behavioral expectations.
179
-
180
- ## Success Criteria
181
-
182
- - A spec document exists in `docs/` with all required sections (overview, decisions, technical design, success criteria, implementation order)
183
- - The human explicitly approved the design before any implementation
184
- - YAGNI was applied: no speculative features made it into the spec
185
- - 2-3 approaches were presented with honest tradeoffs before a decision was made
186
- - Questions were asked one at a time with multiple-choice options where possible
187
- - `harness validate` passes after the spec is written
188
- - If scope was too large, it was decomposed into sub-projects with the human's approval
189
-
190
- ## Examples
191
-
192
- ### Example: Designing a Notification System
193
-
194
- **EXPLORE:**
195
-
196
- ```
197
- Read AGENTS.md — project is a TypeScript monorepo with React frontend and Express backend.
198
- Read existing docs/ — no prior notification specs. Found docs/specs/2026-01-15-user-auth.md as naming example.
199
- Checked src/services/ — no notification code exists. Found email utility in src/utils/email.ts.
200
- Scope assessment: single subsystem (notifications), estimated 1 week. Proceed.
201
- ```
202
-
203
- **EVALUATE:**
204
-
205
- ```
206
- Q1: "For notifications, should we support:
207
- (A) Email only (simplest, covers 90% of use cases)
208
- (B) Email + in-app (covers real-time needs)
209
- (C) Email + in-app + push (full coverage, most complex)?"
210
- Human: "B — email and in-app."
211
-
212
- Q2: "For in-app notifications, should we:
213
- (A) Poll from client every 30s (simple, slight delay)
214
- (B) WebSocket push (real-time, more infrastructure)?"
215
- Human: "A — polling is fine for now."
216
-
217
- Q3: "Should notifications be stored permanently or expire after 30 days?"
218
- Human: "Expire after 30 days."
219
- ```
220
-
221
- **PRIORITIZE:**
222
-
223
- ```
224
- Approach 1: Event-driven with queue
225
- - Services emit events, notification worker consumes and dispatches
226
- - Tradeoff: More infrastructure (needs queue), but decoupled and scalable
227
- - Complexity: Medium
228
- - Risk: Queue adds operational overhead
229
-
230
- Approach 2: Direct service calls
231
- - Services call NotificationService directly
232
- - Tradeoff: Simpler, but couples services to notification logic
233
- - Complexity: Low
234
- - Risk: Harder to add channels later, synchronous blocking
235
-
236
- Recommendation: Approach 2. YAGNI — direct calls are sufficient for email + polling.
237
- We can migrate to event-driven later if we add push notifications.
238
- Human: "Agreed, approach 2."
239
- ```
240
-
241
- **VALIDATE:**
242
-
243
- ```
244
- Wrote docs/specs/2026-03-14-notification-system.md
245
- Sections: Overview, Decisions, Technical Design, Success Criteria, Implementation Order
246
- harness validate — passes
247
- "Spec written to docs/specs/2026-03-14-notification-system.md. Ready for sign-off?"
248
- Human: "Approved."
249
- ```
250
-
251
- ## Gates
252
-
253
- These are hard stops. Violating any gate means the process has broken down.
254
-
255
- - **No implementation before approval.** No production code, no test code, no scaffolding, no "let me just set up the directory structure." The spec must be approved first. If you wrote code, delete it.
256
- - **No skipping the question phase.** You must ask at least one clarifying question before proposing approaches. If you think you already know the answer, you are making assumptions — validate them.
257
- - **No single-approach proposals.** Always present at least 2 approaches with tradeoffs. A single approach is a recommendation disguised as a decision — the human has no real choice.
258
- - **No speculative features.** Every capability in the spec must trace to a stated requirement. "We might need this later" is not a requirement. Cut it.
259
- - **No section-dump specs.** Present the design section by section with feedback between each. Do not write the entire spec and ask "looks good?"
260
-
261
- ## Escalation
262
-
263
- - **When the human cannot decide between approaches:** Identify the key differentiator. Ask: "The main difference is X. Given your priorities, does X matter more than Y?" If still stuck, suggest building a small spike to compare (but the spike is NOT production code).
264
- - **When scope keeps growing during brainstorming:** Stop brainstorming. Explicitly say: "The scope has expanded beyond the original problem. Should we (A) decompose into sub-projects, or (B) revisit the original goal to narrow it?" Do not continue accumulating scope.
265
- - **When the problem domain is unfamiliar:** State what you do not know. Ask the human if they have domain expertise, documentation, or a reference implementation. Do not guess at domain-specific requirements.
266
- - **When requirements conflict with existing architecture:** Flag the conflict explicitly: "The spec calls for X, but the current architecture assumes Y. Should we (A) change the spec to work within current architecture, or (B) plan an architecture change as a prerequisite?"
267
- - **When you have asked more than 10 questions without converging:** The problem is too large or too ambiguous. Stop and propose a decomposition or a scoping exercise before continuing.
268
-
269
-
270
- --- skill.yaml (agents/skills/claude-code/harness-brainstorming/skill.yaml) ---
271
- name: harness-brainstorming
272
- version: "1.0.0"
273
- description: Structured ideation and exploration with harness methodology
274
- cognitive_mode: constructive-architect
275
- triggers:
276
- - manual
277
- - on_new_feature
278
- platforms:
279
- - claude-code
280
- - gemini-cli
281
- tools:
282
- - Bash
283
- - Read
284
- - Write
285
- - Edit
286
- - Glob
287
- - Grep
288
- cli:
289
- command: harness skill run harness-brainstorming
290
- args:
291
- - name: path
292
- description: Project root path
293
- required: false
294
- mcp:
295
- tool: run_skill
296
- input:
297
- skill: harness-brainstorming
298
- path: string
299
- type: rigid
300
- phases:
301
- - name: explore
302
- description: Generate ideas and possibilities
303
- required: true
304
- - name: evaluate
305
- description: Assess ideas against constraints
306
- required: true
307
- - name: prioritize
308
- description: Select and sequence top ideas
309
- required: true
310
- - name: validate
311
- description: Run harness checks on selected approach
312
- required: true
313
- state:
314
- persistent: false
315
- files: []
316
- depends_on:
317
- - harness-planning
318
-
319
- </execution_context>
320
-
321
- <process>
322
- 1. Try: invoke mcp__harness__run_skill with skill: "harness-brainstorming"
323
- 2. If MCP unavailable: follow the SKILL.md workflow provided above directly
324
- 3. Pass through any arguments provided by the user
325
- </process>
326
- """
@@ -1,249 +0,0 @@
1
- # Generated by harness generate-slash-commands. Do not edit.
2
- description = "Run all mechanical constraint checks (context validation + architecture)"
3
- prompt = """
4
- <context>
5
- Cognitive mode: meticulous-verifier
6
- Type: rigid
7
- </context>
8
-
9
- <objective>
10
- Run all mechanical constraint checks (context validation + architecture)
11
- </objective>
12
-
13
- <execution_context>
14
- --- SKILL.md (agents/skills/claude-code/check-mechanical-constraints/SKILL.md) ---
15
- # Check Mechanical Constraints
16
-
17
- > Run all mechanical constraint checks: linter rules, boundary schemas, and forbidden imports. These are automated, enforceable rules — if it can be checked by a machine, it must be.
18
-
19
- ## When to Use
20
-
21
- - Before every commit (ideally via pre-commit hook)
22
- - Before submitting a pull request for review
23
- - After any code generation or automated refactoring
24
- - When `on_pre_commit` or `on_validate` triggers fire
25
- - After resolving merge conflicts (constraints may have been silently violated)
26
- - NOT as a substitute for code review — mechanical constraints catch structural issues, not logic errors
27
- - NOT when only editing non-code files (docs, config) unless those files have their own schema constraints
28
-
29
- ## Process
30
-
31
- ### Phase 1: Run All Checks
32
-
33
- 1. **Run `harness validate`** to check project-wide constraints: file structure, naming conventions, required files, and configuration validity.
34
-
35
- 2. **Run `harness linter validate`** to check all linter rules: code style, import restrictions, forbidden patterns, and boundary schemas.
36
-
37
- 3. **Run `harness check-deps`** to check architectural layer boundaries. This is included here because dependency violations are mechanical — they can be detected purely from import statements and the constraint config.
38
-
39
- 4. **Capture all output.** Combine results from all three commands into a single violation list for triage.
40
-
41
- ### Phase 2: Categorize Violations by Severity
42
-
43
- Organize violations into three tiers:
44
-
45
- **Tier 1 — Errors (must fix before commit):**
46
-
47
- - Forbidden imports (importing banned modules)
48
- - Layer boundary violations (importing across architectural boundaries)
49
- - Schema violations (config files that do not match required schema)
50
- - Missing required files (every package must have index.ts, etc.)
51
-
52
- **Tier 2 — Warnings (must fix before merge):**
53
-
54
- - Naming convention violations (wrong casing, wrong prefix)
55
- - Import ordering issues
56
- - Unused exports detected by linter
57
- - Documentation file references that do not resolve
58
-
59
- **Tier 3 — Info (fix when convenient):**
60
-
61
- - Style suggestions (formatting that does not affect behavior)
62
- - Complexity warnings (functions exceeding thresholds)
63
- - Minor inconsistencies with project conventions
64
-
65
- ### Phase 3: Auto-Fix Where Safe
66
-
67
- Some violations can be fixed automatically without risk:
68
-
69
- - **Import ordering** — reorder imports to match the configured convention. This never changes behavior.
70
- - **Formatting** — apply the project's formatter (prettier, etc.). Pure whitespace and style changes.
71
- - **Simple forbidden imports** — when a forbidden import has a known replacement (e.g., `import lodash` to `import lodash-es`), apply the substitution.
72
- - **Missing trailing commas, semicolons** — mechanical formatting fixes.
73
-
74
- **Rules for auto-fix:**
75
-
76
- - ONLY auto-fix violations that cannot change runtime behavior
77
- - Run the test suite after auto-fixing to confirm nothing broke
78
- - Present the auto-fix diff to the user for awareness (do not silently change code)
79
- - If unsure whether a fix is safe, do NOT auto-fix — report it for manual resolution
80
-
81
- ### Phase 4: Report Remaining Violations
82
-
83
- For each violation that was not auto-fixed, report:
84
-
85
- 1. **File and line number** — exact location of the violation
86
- 2. **Rule name** — which constraint was violated
87
- 3. **What it protects against** — why this rule exists (see reference below)
88
- 4. **How to fix** — specific guidance for resolving this type of violation
89
- 5. **Severity tier** — whether it blocks commit, merge, or is informational
90
-
91
- ## What Each Constraint Type Protects Against
92
-
93
- ### Forbidden Imports
94
-
95
- **Protects against:** Implementation detail leakage and unwanted coupling. When a library is forbidden in a layer, it is because using it there would create a dependency that makes the layer harder to test, replace, or maintain. Example: forbidding `fs` in the UI layer ensures UI code never directly accesses the filesystem.
96
-
97
- ### Layer Boundaries
98
-
99
- **Protects against:** Architectural erosion. Without enforced boundaries, codebases gradually become a tangle where everything depends on everything. Layer boundaries ensure changes in one area do not ripple unpredictably through the whole system.
100
-
101
- ### Boundary Schemas
102
-
103
- **Protects against:** Configuration drift and invalid state. When config files must match a schema, you catch invalid configurations at lint time rather than at runtime. This prevents deployment failures and hard-to-debug runtime errors.
104
-
105
- ### Naming Conventions
106
-
107
- **Protects against:** Cognitive overhead and inconsistency. Consistent naming means developers (human and AI) can predict file locations, function names, and module structure without searching. It also ensures automated tools that rely on naming patterns continue to work.
108
-
109
- ### Required File Rules
110
-
111
- **Protects against:** Incomplete modules. When every package must have an `index.ts` or every component must have a test file, you ensure that the project structure remains complete and navigable.
112
-
113
- ### Import Ordering
114
-
115
- **Protects against:** Merge conflicts and readability issues. Consistent import ordering reduces git conflicts when multiple developers add imports to the same file. It also makes imports scannable at a glance.
116
-
117
- ## Harness Integration
118
-
119
- - **`harness validate`** — Project-wide structural validation. Checks file structure, naming conventions, required files, and configuration schemas.
120
- - **`harness validate --json`** — Machine-readable output for parsing and categorization.
121
- - **`harness linter validate`** — Runs all configured linter rules. Checks code patterns, import restrictions, and style conventions.
122
- - **`harness check-deps`** — Architectural boundary enforcement. Checks all imports against the layer model.
123
- - **`harness check-deps --json`** — Machine-readable dependency check output.
124
-
125
- ## Success Criteria
126
-
127
- - All three commands (`harness validate`, `harness linter validate`, `harness check-deps`) pass with zero errors
128
- - All Tier 1 violations are resolved before any commit
129
- - All Tier 2 violations are resolved before any merge to main
130
- - Auto-fixed changes are verified by running the test suite
131
- - No violations are suppressed without explicit team approval and a documented reason
132
-
133
- ## Examples
134
-
135
- ### Example: Forbidden import detected
136
-
137
- **Violation:**
138
-
139
- ```
140
- ERROR [forbidden-import] src/components/Dashboard.tsx:3
141
- Import 'pg' is forbidden in layer 'ui'
142
- Rule: ui layer must not import database drivers
143
- ```
144
-
145
- **What it protects against:** The UI layer importing a PostgreSQL driver means UI code could execute raw SQL queries, bypassing the service and repository layers entirely. This breaks testability (tests need a real database) and security (SQL injection risk from UI layer).
146
-
147
- **Fix:** Remove the direct database call. Add the needed query to the appropriate repository, expose it through the service layer, and call the service from the UI component.
148
-
149
- ### Example: Auto-fixable import ordering
150
-
151
- **Violation:**
152
-
153
- ```
154
- WARNING [import-order] src/services/auth-service.ts:1-8
155
- Imports are not in the configured order
156
- Expected: builtin -> external -> internal -> relative
157
- Found: relative -> external -> builtin
158
- ```
159
-
160
- **Auto-fix applied:**
161
-
162
- ```typescript
163
- // BEFORE
164
- import { hashPassword } from './utils';
165
- import bcrypt from 'bcrypt';
166
- import { createHash } from 'crypto';
167
-
168
- // AFTER (auto-fixed)
169
- import { createHash } from 'crypto';
170
- import bcrypt from 'bcrypt';
171
- import { hashPassword } from './utils';
172
- ```
173
-
174
- Tests re-run: all passing. No behavioral change.
175
-
176
- ### Example: Schema violation in config
177
-
178
- **Violation:**
179
-
180
- ```
181
- ERROR [schema-violation] harness.config.json:24
182
- Property 'layers[2].allowedImports' must be an array of strings
183
- Found: number (42)
184
- Schema: harness-config-schema.json#/properties/layers/items/properties/allowedImports
185
- ```
186
-
187
- **What it protects against:** An invalid config means `harness check-deps` will either crash or silently skip validation. The layer constraints would not be enforced, allowing violations to slip through undetected.
188
-
189
- **Fix:** Correct the config value to be a valid string array: `"allowedImports": ["@shared/types", "@shared/utils"]`.
190
-
191
- ## Gates
192
-
193
- These are hard stops. Mechanical constraints are non-negotiable.
194
-
195
- - **No commits with Tier 1 violations.** Errors must be resolved before the code is committed. No exceptions.
196
- - **No merges with Tier 2 violations.** Warnings must be resolved before merging to the main branch.
197
- - **No suppressing rules without documentation.** If a rule must be disabled for a specific line or file, the suppression comment must explain WHY (not just disable the rule).
198
- - **No auto-fix without test verification.** Every auto-fix must be followed by a test run to confirm no behavioral change.
199
-
200
- ## Escalation
201
-
202
- - **When a rule seems wrong for the project:** Rules are configured in `harness.config.json` and linter configs. If a rule does not fit, propose a config change with justification. Do not disable the rule inline.
203
- - **When a violation cannot be fixed without a larger refactor:** Document the violation, create a task for the refactor, and get team approval for a temporary inline suppression with a TODO linking to the task.
204
- - **When auto-fix produces unexpected changes:** Undo the auto-fix, report the issue, and fix manually. Auto-fix tools are not infallible.
205
- - **When multiple constraints conflict:** The stricter constraint wins. If `harness validate` says a file is required but `harness linter validate` says its contents violate a rule, fix the contents to satisfy both. Escalate if truly irreconcilable.
206
-
207
-
208
- --- skill.yaml (agents/skills/claude-code/check-mechanical-constraints/skill.yaml) ---
209
- name: check-mechanical-constraints
210
- version: "1.0.0"
211
- description: Run all mechanical constraint checks (context validation + architecture)
212
- cognitive_mode: meticulous-verifier
213
- triggers:
214
- - manual
215
- - on_pr
216
- platforms:
217
- - claude-code
218
- - gemini-cli
219
- tools:
220
- - Bash
221
- - Read
222
- - Glob
223
- cli:
224
- command: harness skill run check-mechanical-constraints
225
- args:
226
- - name: path
227
- description: Project root path
228
- required: false
229
- mcp:
230
- tool: run_skill
231
- input:
232
- skill: check-mechanical-constraints
233
- path: string
234
- type: rigid
235
- state:
236
- persistent: false
237
- files: []
238
- depends_on:
239
- - validate-context-engineering
240
- - enforce-architecture
241
-
242
- </execution_context>
243
-
244
- <process>
245
- 1. Try: invoke mcp__harness__run_skill with skill: "check-mechanical-constraints"
246
- 2. If MCP unavailable: follow the SKILL.md workflow provided above directly
247
- 3. Pass through any arguments provided by the user
248
- </process>
249
- """