Audit component anatomy

From Intense-Visions/harness-engineering · View interactive version

Audit component anatomy is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Detect missing required anatomy parts in component definitions and missing-anatomy-component patterns in composition. First programmatic enforcer of component-anatomy rules — finds what design-compo

How to use this skill

Skill file

Audit Component Anatomy

Detect missing required anatomy parts in component definitions and missing-anatomy-component patterns in composition. First programmatic enforcer of component-anatomy rules — finds what design-component-anatomy reference content prescribes.

When to Use

Capability Roles

<!-- Capability seam: this skill participates in a real extension point whose three roles are named and concrete. A seam with only one role filled is accidental single-implementation lock-in. See harness-skill-authoring Phase 1C. -->

Process

Phase 1: SCAN — Identify component types and run audits

  1. Read project configuration. Check harness.config.json for:
  1. Load source-of-truth catalogs (resolution order, most specific wins):
  1. Identify component type per file using the same resolution order:
  1. Run convention audit (definition findings, ANAT-D* codes). For each catalogued component file:
  1. Run pattern audit (pattern-presence findings, ANAT-P* codes). For each file matching pattern targets:
  1. Check for harness-accessibility overlap deferral. When design.audit.componentAnatomy.enabled = true, this skill OWNS label-slot definition findings; harness-accessibility defers A11Y-010 and A11Y-050 for catalogued components. Track deferrals in meta.deferralsToHarnessDesign count.

Phase 2: EVALUATE — Apply severity model

  1. Map finding severity using design.strictness:
  1. Cross-reference with graph constraints. If a graph exists at .harness/graph/:
  1. De-duplicate via deferral. When this skill produces a finding whose root-cause is also tracked by harness-accessibility, prefer this skill's finding (anatomy-level cause) and increment deferrals counter.

Phase 3: REPORT — Format and persist findings

  1. Write VIOLATES_CRAFT edges to graph. Each finding becomes:
  1. Format the report. Grouped by component file, with finding codes linked to docs/changes/design-pipeline/audit-component-anatomy/finding-codes.md. Each finding includes:
  1. Emit summary. Total findings, breakdown by severity, count of meta.deferralsToHarnessDesign, mode (fast/full), runId.

Harness Integration

Success Criteria

See docs/changes/design-pipeline/audit-component-anatomy/proposal.md for the full 30 success criteria. Highlights:

Rationalizations to Reject

These are common rationalizations that sound reasonable but lead to incorrect results. When you catch yourself thinking any of these, stop and follow the documented process instead.

| Rationalization | Why It Is Wrong |

| --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "This Button's prop type omits a loading state, but the component renders fine, so I'll pass it." | Detecting exactly that gap is the point of the audit. The Button convention marks state:loading as required, so a missing required part must emit ANAT-D002. Passing it defeats the enforcement — surface the finding with its fix hint. |

| "This file isn't in the catalog, but it looks like a Modal, so I'll audit it as one." | Component type is resolved by JSDoc → DESIGN.md Registry → export-name match. No match means silent skip — that is how the audit keeps zero false positives. Guessing a type produces findings against conventions the author never adopted. |

| "The .map() has no empty-state branch and the fix is one line, so I'll just add <EmptyState>." | This skill never modifies source. ANAT-P\* findings carry concrete fix-hint text only; autofix is out of scope. Emit ANAT-P001 and leave the code untouched. |

| "harness-accessibility already flags the missing label association, so I'll skip owning it here." | When componentAnatomy.enabled = true, this skill OWNS label-slot definition findings and a11y DEFERS A11Y-010/A11Y-050 for catalogued components — one finding per root cause. Skipping it means the anatomy-level cause goes unreported. |

| "The convention catalog won't load, so I'll emit findings from what I remember of the conventions." | No findings without a parsed catalog. If the convention library or DESIGN.md catalog cannot be loaded, stop with an explanatory error — never emit speculative findings from memory. |

Examples

Example: Button missing a required state

Input: packages/ui/src/Button.tsx exports a Button component whose prop type omits any loading prop.

Output:

ANAT-D002 [error] Button.tsx — Button convention requires state:loading (exclusive)
  File:        packages/ui/src/Button.tsx
  Component:   Button (identified via export-name match)
  Convention:  APG/button + Radix Primitives Button
  Fix:         Add a `loading?: boolean` prop, OR add `@anatomy-state loading exclusive`
               JSDoc tag to the component if loading is intentionally omitted.

Severity is error under design.strictness: standard because the missing part is required: true in the Button convention.

Example: Empty list with no fallback (pattern-presence finding)

Input: src/pages/Dashboard.tsx contains {items.map(item => <Card item={item} />)} with no empty-state branch.

Output:

ANAT-P001 [warn] Dashboard.tsx:42 — map() over data with no empty-state branch
  File:        src/pages/Dashboard.tsx:42
  Pattern:     ANAT-P001 map-without-empty
  Fix:         Wrap the map in a conditional that renders <EmptyState> when items.length === 0:
                 items.length === 0 ? <EmptyState ... /> : items.map(...)
               Or extract a guard component that handles both branches.

Severity is warn for pattern-presence findings under design.strictness: standard; error under strict.

Example: Catalogued component with JSDoc divergence

Input: A Tabs.tsx file has @anatomy-slot trigger JSDoc but the convention library says Tabs requires both trigger AND panel.

Output:

ANAT-D000 [info] Tabs.tsx — JSDoc declaration omits 2 conventional anatomy parts
  File:        packages/ui/src/Tabs.tsx
  Component:   Tabs (identified via JSDoc @component-type)
  Divergence:  declared slots [trigger]; convention also expects [panel, list]
  Note:        JSDoc wins (resolution order #1). This is an info finding to surface
               the divergence — no action required if intentional.

The ANAT-D000 info code surfaces JSDoc-vs-convention divergence so authors can confirm the divergence is intentional.

Gates

Escalation

Status

v1 — in implementation. See:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.