From jaan-to
Generate OpenAPI 3.1 contracts with schemas, RFC 9457 errors, versioning, and examples. Use when defining API contracts from entities.
npx claudepluginhub parhumm/jaan-to --plugin jaan-toThis skill is limited to using the following tools:
> Generate production-quality OpenAPI 3.1 contracts from API resource entities.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Generate production-quality OpenAPI 3.1 contracts from API resource entities.
$JAAN_CONTEXT_DIR/tech.md - Tech stack context (optional, auto-imported if exists)
#current-stack, #frameworks, #constraints, #versioning, #patterns$JAAN_CONTEXT_DIR/config.md - Project configuration$JAAN_TEMPLATES_DIR/jaan-to-backend-api-contract.template.md - Output template$JAAN_LEARN_DIR/jaan-to-backend-api-contract.learn.md - Past lessons (loaded in Pre-Execution)${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md - Language resolution protocolAPI Entities: $ARGUMENTS
Accepts any of:
If no input provided, ask: "What API resources should be included?"
MANDATORY — Read and execute ALL steps in: ${CLAUDE_PLUGIN_ROOT}/docs/extending/pre-execution-protocol.md
Skill name: backend-api-contract
Execute: Step 0 (Init Guard) → A (Load Lessons) → B (Resolve Template) → C (Offer Template Seeding)
Also read tech context if available:
$JAAN_CONTEXT_DIR/tech.md - Know the tech stack for framework-specific patterns (versioning, auth, error format)Read and apply language protocol: ${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
Override field for this skill: language_backend-api-contract
Language exception: Generated code output (variable names, code blocks, schemas, SQL, API specs) is NOT affected by this setting and remains in the project's programming language.
ultrathink
Use extended reasoning for:
Analyze the provided input to extract API resources:
If entity list:
If PRD reference:
If database schema:
If existing spec:
Build initial understanding:
INPUT SUMMARY
─────────────
Type: {input-type}
Resources: {resources}
Relationships: {implied relationships}
Unknown: {unclear areas}
Ask up to 6 smart questions based on what's unclear from Step 1. Skip questions already answered by the input or tech.md.
Scope question (ask if multiple resources):
Design questions (ask if not in tech.md): 2. Use AskUserQuestion:
Use AskUserQuestion:
Use AskUserQuestion:
Use AskUserQuestion:
Ownership question (always ask): 6. Use AskUserQuestion:
For each resource, determine:
| Attribute | Options | Example |
|---|---|---|
| Type | Collection / Singleton / Nested / Action | Collection |
| Relationships | 1:N / M:N / Polymorphic / None | User 1:N Posts |
| CRUD | Which HTTP methods needed | GET, POST, PATCH, DELETE |
| Fields | Name, type, constraints | email: string, format: email |
| Nullable | Which fields can be null | bio: ["string", "null"] |
Present resource map:
RESOURCE MAP
────────────
Resource: User
Type: Collection
Fields: id (uuid), email (email), name (string), role (enum), bio (nullable string), created_at, updated_at
Relations: 1:N → Posts, 1:N → Comments
Operations: List, Create, Read, Update, Delete
Custom: Verify email (POST /users/{id}/verify)
Resource: Post
Type: Collection (nested under User optional)
Fields: id (uuid), title (string), body (string), status (enum: draft/published), author_id (uuid)
Relations: N:1 → User, 1:N → Comments
Operations: List, Create, Read, Update, Delete, Publish (action)
Plan the component architecture using research-informed patterns.
Reference: See
${CLAUDE_PLUGIN_ROOT}/docs/extending/backend-api-contract-reference.md— "Schema Design Patterns" for base schemas, per-resource schemas, shared components, and design rules.
Present schema plan:
SCHEMA PLAN
───────────
Base schemas: {count} (Timestamps, ProblemDetails, ValidationProblemDetails, PaginationMeta)
Resource schemas: {count} ({Resource}, {Resource}Create, {Resource}Update, {Resource}Response, {Resource}List × N)
Shared params: {count}
Shared responses: {count}
Named examples: {count}
Total components: {total}
API CONTRACT PLAN
═════════════════
RESOURCES ({count})
───────────────────
{resource1} ({op_count} ops)
{resource2} ({op_count} ops)
...
SCHEMAS ({count} total)
───────────────────────
Base: {count} (Timestamps, ProblemDetails, ValidationProblemDetails, PaginationMeta)
Resource: {count} (5 per resource × {resource_count})
Shared: {count} (params, responses, examples)
ENDPOINTS ({count} total)
─────────────────────────
Auth: {strategy}
Versioning: {strategy}
Errors: RFC 9457 Problem Details
Pagination: {strategy}
Consumers: {audience}
STATUS CODES
────────────
Success: 200 (GET/PATCH), 201 (POST), 204 (DELETE)
Client: 400, 401, 403, 404, 409, 422, 429
Server: 500
OUTPUT
──────
Main: api.yaml (OpenAPI 3.1)
Companion: {id}-{slug}.md (quick-start guide)
Use AskUserQuestion:
Do NOT proceed to Phase 2 without explicit approval.
Read template: $JAAN_TEMPLATES_DIR/jaan-to-backend-api-contract.template.md
If tech stack needed, extract sections from tech.md:
#current-stack#frameworks#constraints#versioning#patternsGenerate the OpenAPI 3.1 YAML in this order (minimizes broken $ref):
openapi: 3.1.0, info (title, version, description, contact, license), serverssecuritySchemes — Based on auth choice from Step 2
b. schemas — Base schemas first (Timestamps, ProblemDetails, ValidationProblemDetails, PaginationMeta), then resource schemas in dependency order
c. parameters — CursorParam, LimitParam, path ID params
d. responses — Shared error responses referencing ProblemDetails schemas
e. examples — Named examples per operation (happy path, edge cases)$refReference: See
${CLAUDE_PLUGIN_ROOT}/docs/extending/backend-api-contract-reference.md— "Generation Rules" for schema rules, operation rules, status codes per operation type, example rules, and pagination format.
Generate a companion markdown guide covering: Executive Summary, Authentication, Quick Start (cURL examples), Pagination, Error Handling (RFC 9457), Resources endpoint table, Validation & Tooling commands, and Metadata.
Reference: See
${CLAUDE_PLUGIN_ROOT}/docs/extending/backend-api-contract-reference.md— "Companion Markdown Structure" for the full template with examples.
Before preview, verify all structural (OpenAPI 3.1), error handling, and completeness checks pass. If any check fails, fix before preview.
Reference: See
${CLAUDE_PLUGIN_ROOT}/docs/extending/backend-api-contract-reference.md— "Quality Checklist" for the full verification checklist.
Use AskUserQuestion:
If approved, set up the output structure:
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/id-generator.sh"
# Define subdomain directory
SUBDOMAIN_DIR="$JAAN_OUTPUTS_DIR/backend/api-contract"
mkdir -p "$SUBDOMAIN_DIR"
# Generate next ID
NEXT_ID=$(generate_next_id "$SUBDOMAIN_DIR")
# Create folder and file paths (slug from API name)
slug="{lowercase-hyphenated-api-name}"
OUTPUT_FOLDER="${SUBDOMAIN_DIR}/${NEXT_ID}-${slug}"
MAIN_FILE="${OUTPUT_FOLDER}/api.yaml"
COMPANION_FILE="${OUTPUT_FOLDER}/${NEXT_ID}-${slug}.md"
Output Configuration
- ID: {NEXT_ID}
- Folder:
$JAAN_OUTPUTS_DIR/backend/api-contract/{NEXT_ID}-{slug}/- Main:
api.yaml- Companion:
{NEXT_ID}-{slug}.md
mkdir -p "$OUTPUT_FOLDER"
Write OpenAPI spec to api.yaml
Write companion guide to {NEXT_ID}-{slug}.md
Update subdomain index:
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/index-updater.sh"
add_to_index \
"$SUBDOMAIN_DIR/README.md" \
"$NEXT_ID" \
"${NEXT_ID}-${slug}" \
"{API Title}" \
"{executive-summary}"
✓ Contract written to:
$JAAN_OUTPUTS_DIR/backend/api-contract/{NEXT_ID}-{slug}/api.yaml✓ Guide written to:$JAAN_OUTPUTS_DIR/backend/api-contract/{NEXT_ID}-{slug}/{NEXT_ID}-{slug}.md✓ Index updated:$JAAN_OUTPUTS_DIR/backend/api-contract/README.md
Generate a .spectral.yaml companion file alongside the contract:
extends:
- "spectral:oas"
- "spectral:asyncapi"
rules:
operation-operationId: error
operation-description: warn
oas3-api-servers: error
no-$ref-siblings: error
If OWASP ruleset is relevant (auth endpoints detected), add:
extends:
- "spectral:oas"
- "@stoplight/spectral-owasp-ruleset"
Write to: $OUTPUT_FOLDER/.spectral.yaml
Add "Validation Commands" section to companion markdown guide:
## Validation Commands
Lint this contract:
npx @stoplight/spectral-cli lint api.yaml --ruleset .spectral.yaml
Mock server:
npx @stoplight/prism-cli mock api.yaml
Contract validation (full pipeline):
/jaan-to:qa-contract-validate api.yaml
"Contract generated. Suggested next steps:"
- Lint contract:
npx @stoplight/spectral-cli lint api.yaml --ruleset .spectral.yaml- Mock server:
npx @stoplight/prism-cli mock api.yaml- Full validation:
/jaan-to:qa-contract-validate {output-path}/api.yaml- Generate client SDK:
npx orval --input api.yaml --output ./src/api/- Contract tests:
schemathesis run api.yaml- API documentation:
/jaan-to:dev-docs-generate
Use AskUserQuestion:
Question: "Any feedback on the generated contract?"
Header: "Feedback"
Options:
Fix now: Update the output files, re-preview, re-write
Learn: Run /jaan-to:learn-add backend-api-contract "{feedback}"
Both: Do both
tech.md detection$JAAN_OUTPUTS_DIR path$JAAN_OUTPUTS_DIR/backend/api-contract/{id}-{slug}/