From harness-claude
Validates architectural layer boundaries and detects dependency violations using harness.config.json constraints and harness check-deps. Hard gate before PRs and refactors.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Validate architectural layer boundaries and detect dependency violations. No code may violate layer constraints — this is a hard gate, not a suggestion.
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.
Audits codebase architecture: maps module dependencies with Mermaid graphs, checks layering integrity, flags structural decay from 12 engineering books. For structure reviews, clean architecture checks, circular imports, and onboarding tours.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Validate architectural layer boundaries and detect dependency violations. No code may violate layer constraints — this is a hard gate, not a suggestion.
on_pre_commit or on_architecture_check triggers fireharness.config.json to understand the project's architectural constraints. The config defines:
ui -> service -> repository -> domain)design config exists, also load design constraint rules:
design-system/DESIGN.mdWhen a knowledge graph exists at .harness/graph/, use graph queries for faster, more accurate violation detection:
query_graph — traverse imports edges against layer constraint nodes to find all violations in a single queryget_relationships — find all code dependent on a violation target to show the full scope of impactGraph queries show the complete violation scope (not just the first occurrence per file) and reveal transitive violations that single-file analysis misses. Fall back to file-based commands if no graph is available.
harness check-deps to analyze all import statements against the constraint model. Capture the full JSON output.1b. Optionally run harness check-arch for comprehensive architecture analysis beyond dependency checking. This covers circular dependencies, complexity, coupling, module size, and dependency depth in addition to layer violations.
For each violation, determine:
Which layers are involved. Identify the source file's layer and the imported module's layer. Map them to the constraint model.
What rule is violated. Common violation types:
design.strictness in config. These violations surface as DESIGN-xxx codes:
DESIGN-001 [warn] — Hardcoded color/font/spacing instead of token referenceDESIGN-002 [warn] — Value matches a project anti-patternDESIGN-003 [error] — WCAG contrast ratio failure (error in strict mode)DESIGN-004 [info] — Missing platform binding for enabled platformExplain the impact. For each violation, state:
Some architecture violations can be auto-fixed. Apply these before surfacing remaining violations.
Import ordering violations:
Forbidden import replacement (with configured alternative):
harness.config.json for forbiddenImports entries that include an alternative field.Design token substitution (unambiguous mapping):
Never auto-fix these (always surface to user):
When running standalone (not through the orchestrator), apply a single-concern convergence loop:
harness check-deps again.Verification gate: After each fix batch, run:
pnpm lint && pnpm tsc --noEmit && pnpm test
If any command fails, revert the batch and reclassify those findings as unsafe.
For each violation, provide a specific fix:
harness.config.json for an alternative field. If present, this should have been auto-fixed in Phase 3.5. If not present, replace the forbidden import with the approved alternative or restructure the code.design-system/tokens.json. For anti-pattern violations, consult design-system/DESIGN.md for the project's aesthetic intent and approved alternatives. For contrast failures, use harness-accessibility to find compliant color pairs.A UI component imports a repository function directly because "it is just one query." Fix: add the query to the Service layer. The extra indirection is the architecture working correctly.
Two layers both need the same type definition. Fix: place shared types in the lowest layer that both depend on, or create a dedicated types or shared module at the bottom of the layer stack.
Test helpers import across layer boundaries for convenience. Fix: each layer's tests should only import from that layer and below. Test utilities should follow the same constraints as production code.
A component uses #3b82f6 directly instead of referencing color.primary from the design token system. Fix: import and reference the token. In Tailwind: use the token-mapped utility class. In CSS: use the custom property var(--color-primary).
Module A re-exports from Module B, and Module B imports from Module A. The circular dependency is hidden by the re-export. Fix: identify the true dependency direction and remove the reverse path.
harness check-deps — Primary tool. Analyzes all imports against the layer model defined in harness.config.json. Returns structured violation data including file, line, source layer, target layer, and rule violated.harness check-deps --json — Machine-readable output for automated pipelines. Use this when parsing results programmatically.harness validate — Includes dependency checking as part of full project validation. Use when you want a complete health check, not just architecture.harness-design-system — Provides the design token source of truth (tokens.json) that constraints validate against.harness-accessibility — Provides WCAG contrast validation used by DESIGN-003 constraints.design.strictness in harness.config.json. Design violations surface alongside architectural violations in the same report.harness check-arch — Architecture assertion framework. Runs all 7 metric collectors against baseline and thresholds. Use for comprehensive structural health checks beyond layer dependencies. Supports --update-baseline to capture current state and --json for machine-readable output.harness check-arch --module <path> — Scoped architecture check for a single module. Use when validating a specific subsystem.harness check-deps reports zero violationsharness.config.json accurately reflects the intended architectureViolation from harness check-deps:
VIOLATION: Upward dependency
File: src/services/user-service.ts:12
Import: import { UserForm } from '../components/UserForm'
Source layer: service (level 2)
Target layer: ui (level 3)
Rule: service layer must not depend on ui layer
Impact: The UserService now depends on a React component. It cannot be used in a CLI tool, a background job, or tested without a DOM. The service layer should be framework-agnostic.
Resolution:
// BEFORE (violating)
import { UserForm } from '../components/UserForm';
const data = UserForm.defaultValues; // using UI defaults in service
// AFTER (fixed)
// Define the defaults where they belong — in the service layer
const DEFAULT_USER_DATA: UserInput = { name: '', email: '' };
Violation from harness check-deps:
VIOLATION: Circular dependency detected
Cycle: src/services/order-service.ts -> src/services/inventory-service.ts -> src/services/order-service.ts
order-service imports checkStock from inventory-service
inventory-service imports getOrderQuantity from order-service
Resolution: Extract the shared concern into a new module:
// src/services/stock-calculator.ts (new, shared module)
export function calculateRequiredStock(quantity: number, reserved: number): number {
return quantity - reserved;
}
Both services import from stock-calculator instead of from each other. The cycle is broken.
These are hard stops. Architecture violations are not warnings — they are errors.
harness check-deps reports violations, the code must be fixed before it proceeds.harness.config.json before code is written in it.harness.config.json must be explicitly updated with a comment explaining why.When this skill makes claims about existing code, architecture, or behavior, it MUST cite evidence using one of:
file:line format (e.g., src/auth.ts:42)file with description (e.g., src/utils/hash.ts —
"existing bcrypt wrapper")evidence session section via manage_stateUncited claims: Technical assertions without citations MUST be prefixed with
[UNVERIFIED]. Example: [UNVERIFIED] The auth middleware supports refresh tokens.
These apply to ALL skills. If you catch yourself doing any of these, STOP.
These reasoning patterns sound plausible but lead to bad outcomes. Reject them.
| Rationalization | Reality |
|---|---|
| "The violation is minor — just one import" | One violation sets a precedent. Enforce the constraint or document an explicit exception with rationale. |
| "It works, so the architecture must be fine" | Working code with bad architecture is technical debt with compound interest. Correct function does not excuse structural violations. |
| "This is a legacy module, different rules apply" | Legacy does not mean exempt. Either the constraint applies or it needs an explicit documented exception. |
harness check-deps reports false positives: Verify the layer assignments in harness.config.json are correct. If a file is assigned to the wrong layer, fix the config. If the tool is genuinely wrong, report the issue.