/harness-claude:harness:api-craft runs instead · from harness-claude
Critiques API design quality using LLM judgment, evaluating abstraction level, HTTP verb honesty, resource naming, response predictability, and error clarity. Complements rule-based OpenAPI compliance checks.
This skill never runs in Claude Code
It ships in harness-claude at agents/, but /harness-claude:harness:api-craft (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
LLM-judgment critique of API design quality — the ceiling counterpart to rule-based API checks (OpenAPI-format compliance and webhook-format validation). A linter can confirm a path is documented and a schema validates; only judgment can tell whether the endpoint sits at the right abstraction, whether the HTTP verb is honest, whether a resource name belongs in the URL or a query param, whether a stranger could predict the response shape, and whether the error tells the consumer what to do. Emits 3-axis findings (tier × impact × confidence per ADR 0019).
packages/cli/src/shared/craft/) — LlmProvider + finding/axes schema + run store — shared across all *-craft skills. This skill implements, and does not own, that contract.packages/cli/src/api-craft/).craft-fleet (the craft-pipeline elevation sweep) and the harness natural-language router, which invoke every *-craft provider uniformly through the shared critique/finding shapeapi-craft is the ceiling; it runs regardless of setup, but its critique sharpens when a project declares its API conventions. Before critiquing, note the state:
| Precondition | Source | If missing |
|---|---|---|
apiStyleDeclared | a project API style guide (e.g. docs/**/API.md) | Run with the generic seed rubrics; note in the summary that a style guide would sharpen critique and offer to seed one (progressive upgrade — the same posture as docs-craft's B'). |
When no style guide exists, api-craft still runs with the seed rubrics (degraded, not blocked). It never refuses to critique just because a project has not written its API conventions down.
Read project configuration. Shared craft config under craft.llm.* selects the judgment backend. maxFiles (default 60) caps the surface count.
Discover the API surface. Two kinds are collected:
docs, spec, specs, api, openapi, src), matched by filename (openapi.yaml, swagger.json) or a root openapi: / swagger: key.src/routes, src/api, src/controllers, src/handlers, app/api, pages/api, routes, api, …), included only when the file carries a route SIGNAL — a .get(/.post( call, an @Get()/@Controller() decorator, an exported GET/POST handler, etc. --routes-dir points route discovery at an explicit directory; --spec-file names an explicit OpenAPI document; --files overrides discovery entirely.Exclude non-API surfaces. Tests / specs, type declarations, barrels and registries (index.ts, _registry.ts), build / dependency trees (node_modules, dist), and helper modules under an API root that define no endpoint are skipped — they are not authored API surfaces.
9 seed rubrics, each declaring which surface kinds it applies to:
| Rubric | Title | Applies to |
|---|---|---|
API-R001 | Resources model the domain, not the implementation | all |
API-R002 | Resource naming and URL structure are predictable | all |
API-R003 | HTTP methods are honest | all |
API-R004 | Status codes are correct and meaningful | all |
API-R005 | Error responses tell the consumer what to do | all |
API-R006 | Response shapes are predictable and consistent | all |
API-R007 | Collections paginate and filter consistently | all |
API-R008 | Mutations are idempotency-honest | route only |
API-R009 | Evolves without breaking consumers | all |
For each (surface, rubric) where the rubric applies to the surface's kind:
null (rubric doesn't apply / the surface already clears the bar) OR { tier, impact, confidence, message }.ApiFinding with cite.rubricId populated for ADR 0020 traceability, and a derived priority for sorting.Idempotency (API-R008) is a handler-behavior concern a declarative spec rarely captures, so it critiques route surfaces only; an OpenAPI document is critiqued against the other eight rubrics. This is the API analogue of cli-ergonomics-craft's leaf/group filter.
A small curated exemplar set anchors the catalog — Stripe, Linear's GraphQL API, GitHub's REST API, Resend, and the Anthropic API — each a public reference point for one API-quality dimension (Stripe for idempotent requests, cursor pagination, and dated versioning; Linear for domain-mirroring types; GitHub for a guessable path grammar; Resend for a right-sized resource surface; Anthropic for honest methods and a consistent error contract). The exemplars ground the rubric sources today and seed a future BENCHMARK phase, the direct analogue of docs-craft's exemplar corpus.
Emit ApiCraftOutput:
{
findings: ApiFinding[];
summary: {
phaseRun: ['critique'];
mode: 'fast';
durationMs: number;
llmCalls: { provider, model, count, costUsd };
catalog: { rubricsApplied: string[]; exemplarsAvailable: number };
counts: { filesScanned, filesSkipped };
runId: string;
}
}
harness api-craft — CLI entry. --files <glob> / --routes-dir <dir> / --spec-file <file> / --exclude-dirs <dirs...> / --max-files <n> / --json / --verbose. Exits non-zero when any foundational-tier finding is present.mcp__harness__api_craft — MCP tool. Two modes (see "In-session flow" below).mcp__harness__api_craft_finalize — MCP tool that completes the in-session flow.critiqueApiSurfaceFile(file, opts) exported from packages/cli/src/api-craft/index.ts. Another craft skill (or an orchestrator) can critique a single spec or route file without re-walking the project.LlmProvider, MockLlmProvider, derivePriority, and the 3-axis types all live in packages/cli/src/shared/craft/.api-craft auto-activates as an advisory review hook whenever a diff touches the surface it
owns — harness-autopilot at after:REVIEW / after:FINAL_REVIEW, and harness-code-review at
after:mechanical. The domain table is CRAFT_REVIEW_DOMAINS and the per-host events are
CRAFT_REVIEW_EVENTS_BY_HOST, both in packages/core/src/hooks/craft-review-hooks.ts. The host
forwards the subset of the diff this domain owns:
files — this domain's owned subset of the changed files, as ABSOLUTE paths. The host
reads it from plan.files["api-craft"], which holds repo-relative POSIX paths, and resolves each
entry against the project root before calling mcp__harness__api_craft. Absolute is the
recommended form, not a correctness requirement for this domain: its collector resolves a
relative entry against the tool's path (never the process CWD), so a repo-relative entry
forwarded unresolved still reads the in-diff file (pinned by
packages/cli/tests/shared/craft/relative-files-scope.test.ts). Only
mcp__harness__design_craft still requires absolute paths.promptBudget — accepted; raises the prompt ceiling for the forwarded scope when the diff subset is large.Findings from a hook-triggered run are advisory: reported, never blocking, never counted toward review severity, and never entered into a host's mechanical exclusion set. A hook-triggered run that fails is a missing opinion, not a broken gate.
See docs/changes/api-craft/proposal.md for the full success criteria. Highlights:
catalog/rubrics/<slug>.ts (file-per-rubric, matching the craft family)cite.rubricId populated on every finding (ADR 0020)critiqueApiSurfaceFile works on a single surface without a project walkThese 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 endpoint validates against its OpenAPI schema, so the contract is fine." | Schema validity is the mechanical floor. api-craft asks whether the SHAPE is right — is the verb honest, does the resource model the domain, does the error tell the consumer what to do. A schema-valid GET /widgets/delete/:id still fails API-R003. |
| "It is just an internal API, so I can skip the compatibility critique." | API-R009 applies wherever there are consumers. Internal callers break exactly the way external ones do when a response shape or field meaning shifts unannounced — the blast radius is smaller, not the rule. |
| "The handler returns a 500 with a message, so errors are covered." | API-R004 and API-R005 ask whether the status code is CORRECT for the failure and whether the body tells the consumer what to DO next — not merely that some error came back. A generic 500 on a client-caused failure fails both. |
| "I can see the fix, so I will add the idempotency key to the handler while I am here." | api-craft is judgment-only. It emits a finding naming the surface and a concrete suggested change; it never rewrites a contract or handler. Editing here violates the no-autofix gate and hides the finding from the consumer who owns the decision. |
| "No API style guide is declared, so a critique would not be meaningful." | The B' check degrades to the seed rubrics — it never blocks. Refusing to critique because a project has not written its conventions down abandons the ceiling role; note the degraded context and run anyway. |
Input: src/routes/widgets.ts defining router.get('/widgets/delete/:id', …) whose handler deletes the record.
Output (mock LLM):
src/routes/widgets.ts (route)
API-R003 [foundational/large/high] src/routes/widgets.ts (route)
`GET /widgets/delete/:id` mutates state — a GET must be safe, and caches or
prefetchers may replay it. Model this as `DELETE /widgets/:id` so retry and
caching behavior are predictable from the method alone.
Input: src/routes/payments.ts — a POST /payments handler that charges a card with no idempotency key and no dedup.
Output:
src/routes/payments.ts (route)
API-R008 [foundational/large/high] src/routes/payments.ts (route)
`POST /payments` charges on every call with no idempotency key — a network
retry double-charges. Accept an `Idempotency-Key` header and return the
original result for a repeated key, the way Stripe's charge API does.
Input: An openapi.yaml with domain-modeled resources, plural paths, honest methods, correct status codes, a consistent typed error schema, cursor pagination, and a version.
Output:
No API-craft findings.
Summary: 0 findings across 1 API surfaces (0 skipped, 8 rubrics, 5 exemplars, 8 LLM calls, $0.0000, 5ms)
--max-files (default 60), or scope to specific surfaces with --files / --spec-file. Per-surface cost = applicable rubrics × per-call; source is truncated at 8000 input chars.--files, or filter findings by cite.rubricId in your consumer. Per-rubric disable is a later minor version.--routes-dir, name the contract with --spec-file, or pass an explicit --files list.craft.llm.*; do not expect rule-based output.v1 — CRITIQUE phase. See:
docs/changes/api-craft/proposal.mdcraft-pipeline initiativeharness-cli-ergonomics-craft (the structural twin), harness-docs-craft, harness-code-craft, harness-design-craft, naming-craft, spec-craft, copy-craft, test-craft, knowledge-craft, security-craftpackages/cli/src/shared/craft/What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claude793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job