From harness-claude
Runs mechanical constraint checks: linter rules, boundary schemas, forbidden imports via harness commands. Categorizes violations by severity and auto-fixes safe issues like formatting and import ordering. Use before commits, PRs, or code generation.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> 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.
Validates architectural layer boundaries and detects dependency violations using harness.config.json constraints and harness check-deps. Hard gate before PRs and refactors.
Pre-commit quality gate validating logic correctness, error handling, regressions, and completeness in code changes. Auto-fires before commit via cook or on large diffs.
Sets up ast-grep in TypeScript codebases with rules detecting anti-patterns, enforcing best practices, and preventing bugs. Creates sgconfig.yml, rule files, and tests for structural linting, legacy bans, and ratchet gates.
Share bugs, ideas, or general feedback.
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.
on_pre_commit or on_validate triggers fireRun harness validate to check project-wide constraints: file structure, naming conventions, required files, and configuration validity.
Run harness linter validate to check all linter rules: code style, import restrictions, forbidden patterns, and boundary schemas.
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.
Capture all output. Combine results from all three commands into a single violation list for triage.
Organize violations into three tiers:
Tier 1 — Errors (must fix before commit):
Tier 2 — Warnings (must fix before merge):
Tier 3 — Info (fix when convenient):
Some violations can be fixed automatically without risk:
import lodash to import lodash-es), apply the substitution.Rules for auto-fix:
For each violation that was not auto-fixed, report:
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.
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.
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.
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.
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.
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.
harness validate — Project-wide structural validation. Checks file structure, naming conventions, required files, and configuration schemas.harness validate --json — Machine-readable output for parsing and categorization.harness linter validate — Runs all configured linter rules. Checks code patterns, import restrictions, and style conventions.harness check-deps — Architectural boundary enforcement. Checks all imports against the layer model.harness check-deps --json — Machine-readable dependency check output.harness validate, harness linter validate, harness check-deps) pass with zero errors| Rationalization | Why It Is Wrong |
|---|---|
| "This forbidden import is just for one utility function -- I will suppress it inline" | The gate says no suppressing rules without documentation. Undocumented suppressions accumulate and erode the constraint system. |
| "The auto-fix looks right, so I do not need to re-run tests" | The gate says no auto-fix without test verification. Even import reordering can break code that depends on module initialization order. |
| "This is just a Tier 2 warning -- it can wait until after merge" | Tier 2 violations must be resolved before merge to main. Warnings that accumulate on main become the new baseline. |
| "The linter rule does not make sense for this project, so I will just disable it" | Propose a config change with justification, do not disable the rule inline. Fix it at the configuration level. |
Violation:
ERROR [forbidden-import] src/components/Dashboard.tsx:3
Import 'pg' is forbidden in layer 'ui'
Rule: ui layer must not import database drivers
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).
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.
Violation:
WARNING [import-order] src/services/auth-service.ts:1-8
Imports are not in the configured order
Expected: builtin -> external -> internal -> relative
Found: relative -> external -> builtin
Auto-fix applied:
// BEFORE
import { hashPassword } from './utils';
import bcrypt from 'bcrypt';
import { createHash } from 'crypto';
// AFTER (auto-fixed)
import { createHash } from 'crypto';
import bcrypt from 'bcrypt';
import { hashPassword } from './utils';
Tests re-run: all passing. No behavioral change.
Violation:
ERROR [schema-violation] harness.config.json:24
Property 'layers[2].allowedImports' must be an array of strings
Found: number (42)
Schema: harness-config-schema.json#/properties/layers/items/properties/allowedImports
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.
Fix: Correct the config value to be a valid string array: "allowedImports": ["@shared/types", "@shared/utils"].
These are hard stops. Mechanical constraints are non-negotiable.
harness.config.json and linter configs. If a rule does not fit, propose a config change with justification. Do not disable the rule inline.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.