mockapi
Use this skill to create stateful mock API servers from OpenAPI contracts. The
agent owns behavior analysis and sidecar authoring; bundled scripts only perform
structural validation and deterministic typed scaffolding. Generated operation
services are TODOs; the agent completes wiring and behavior from
.mockapi/behavior.md anchors.
Command Router
Route invocations:
- No argument: show a short menu with
profile, generate, and freeform
examples. Ask what the user wants to do.
- First word
profile: read reference/profile.md and follow that workflow.
Everything after profile is the target or context.
- First word
generate: before any OpenAPI search or repo-wide file scan,
read reference/generate.md and run the generate sidecar preflight from
that workflow. Everything after generate is the target or context. After
the profile and sidecars are present and validation succeeds, always run
<python> <skill-root>/scripts/generate.py; do not satisfy a generate
command by only describing, planning, or hand-writing the scaffold.
- Any other first word: treat the entire argument as a general mockapi request.
Do not reject unknown first words merely because they are not commands.
General mockapi request routing:
- Mock-server creation requests such as "make", "build", "create", "generate",
"scaffold", or "use this OpenAPI" route to
reference/generate.md.
generate auto-runs the profile workflow when sidecars are missing.
- Profile, analyze, describe, or sidecar-only requests route to
reference/profile.md.
- Validate, check, repair, or diagnose sidecar requests run
scripts/validate_profile.py, read reference/sidecars.md, and repair
or report blockers as needed. The validator checks profile.toml and
behavior.md unless --profile-only is used.
- Questions about existing generated mock-server code read
reference/generated-server.md, reference/mock-server-structure.md, and
reference/mock-server-examples.md, then inspect the relevant files. When
finishing or reviewing LLM-owned generated server code, also read
reference/mock-server-quality.md.
If the freeform intent remains ambiguous after inspecting the repository, ask
one concise clarification before mutating files. Do not invent extra commands or
run unbundled scripts.
Runtime Rules
- Requires Python 3.11+ for bundled scripts. Resolve
<python> to an
executable whose version is 3.11+ before running script examples. If no
suitable interpreter exists, stop and report the requirement to the user.
Bundled CLI scripts also verify the active interpreter and fail with a clear
error when it is too old.
- Resolve
<skill-root> to the directory containing this SKILL.md. Run shell
command examples by replacing <skill-root> with that absolute or
repository-relative skill directory.
- Run only committed bundled Python scripts from
scripts/*.py during normal
skill usage.
- Treat
reference/*.md and the target repository context as the primary
contract for agent decisions. Do not read script source as a source of
profiling requirements during normal profile work.
- Use
reference/sidecars.md as the authoritative sidecar schema, including
valid profile.toml fields. If a needed sidecar shape is missing from the
references, stop and report the exact documentation gap instead of inferring
it from scripts/mockapi_runtime/*.py.
- Inspect bundled Python source only to diagnose a validator or generator defect
after running the committed scripts. Do not use script source to discover
valid sidecar fields, defaults, or profile behavior policy.
- Do not run dependency installation inside the skill folder.
- For generated package dependency/script steps, use
scripts/detect_package_manager.py; do not hand-roll command -v package
manager checks or rely on interactive shell startup files.
- In
generate workflows, run generated package codegen before implementing or
editing LLM-owned controller wiring or feature modules.
- Do not edit OpenAPI contracts unless the user explicitly requests contract
changes.
- Treat
.mockapi/profile.toml and .mockapi/behavior.md as the durable
source of truth for generation.
- For any
generate workflow, run scripts/generate.py --run-codegen after
successful validation. If validation fails, repair sidecars or report blockers
instead of running the generator on invalid data.
- Treat
profile.toml as the structural operation index. Implement operation
behavior from the matching behavior.md anchor, not from operation shape.
- Use
reference/sidecars.md for sidecar shape and validation expectations.
- Use
reference/generated-server.md, reference/mock-server-structure.md,
reference/mock-server-examples.md, reference/seed-data.md,
reference/testing.md, and reference/mock-server-quality.md when
inspecting or finishing generated server code.
Bundled Scripts
Validate sidecars:
<python> <skill-root>/scripts/validate_profile.py
Preflight sidecars for generate:
<python> <skill-root>/scripts/preflight_generate.py --root .
Profile-only validation:
<python> <skill-root>/scripts/validate_profile.py --profile-only
Generate server scaffold and run codegen:
<python> <skill-root>/scripts/generate.py --root . --profile .mockapi/profile.toml --run-codegen
Detect generated package manager for manual regeneration:
<python> <skill-root>/scripts/detect_package_manager.py --root . --profile .mockapi/profile.toml
Final quality gate after implementation only:
<python> <skill-root>/scripts/check_generated_quality.py --package-root <packageRoot> --profile .mockapi/profile.toml
1---2name: mockapi3description: Create stateful TypeScript/Hono mock API servers from OpenAPI 3.0/3.1 contracts. Use for building OpenAPI-based mock APIs, creating or repairing .mockapi sidecars, validating mock profiles, generating admin state endpoints, or freeform requests such as "mockapi build a mock server for api/openapi.yaml".4---56# mockapi78Use this skill to create stateful mock API servers from OpenAPI contracts. The9agent owns behavior analysis and sidecar authoring; bundled scripts only perform10structural validation and deterministic typed scaffolding. Generated operation11services are TODOs; the agent completes wiring and behavior from12`.mockapi/behavior.md` anchors.1314## Command Router1516Route invocations:17181. No argument: show a short menu with `profile`, `generate`, and freeform19 examples. Ask what the user wants to do.202. First word `profile`: read `reference/profile.md` and follow that workflow.21 Everything after `profile` is the target or context.223. First word `generate`: before any OpenAPI search or repo-wide file scan,23 read `reference/generate.md` and run the generate sidecar preflight from24 that workflow. Everything after `generate` is the target or context. After25 the profile and sidecars are present and validation succeeds, always run26 `<python> <skill-root>/scripts/generate.py`; do not satisfy a `generate`27 command by only describing, planning, or hand-writing the scaffold.284. Any other first word: treat the entire argument as a general mockapi request.29 Do not reject unknown first words merely because they are not commands.3031General mockapi request routing:3233- Mock-server creation requests such as "make", "build", "create", "generate",34 "scaffold", or "use this OpenAPI" route to `reference/generate.md`.35 `generate` auto-runs the profile workflow when sidecars are missing.36- Profile, analyze, describe, or sidecar-only requests route to37 `reference/profile.md`.38- Validate, check, repair, or diagnose sidecar requests run39 `scripts/validate_profile.py`, read `reference/sidecars.md`, and repair40 or report blockers as needed. The validator checks `profile.toml` and41 `behavior.md` unless `--profile-only` is used.42- Questions about existing generated mock-server code read43 `reference/generated-server.md`, `reference/mock-server-structure.md`, and44 `reference/mock-server-examples.md`, then inspect the relevant files. When45 finishing or reviewing LLM-owned generated server code, also read46 `reference/mock-server-quality.md`.4748If the freeform intent remains ambiguous after inspecting the repository, ask49one concise clarification before mutating files. Do not invent extra commands or50run unbundled scripts.5152## Runtime Rules5354- Requires Python 3.11+ for bundled scripts. Resolve `<python>` to an55 executable whose version is 3.11+ before running script examples. If no56 suitable interpreter exists, stop and report the requirement to the user.57 Bundled CLI scripts also verify the active interpreter and fail with a clear58 error when it is too old.59- Resolve `<skill-root>` to the directory containing this `SKILL.md`. Run shell60 command examples by replacing `<skill-root>` with that absolute or61 repository-relative skill directory.62- Run only committed bundled Python scripts from `scripts/*.py` during normal63 skill usage.64- Treat `reference/*.md` and the target repository context as the primary65 contract for agent decisions. Do not read script source as a source of66 profiling requirements during normal profile work.67- Use `reference/sidecars.md` as the authoritative sidecar schema, including68 valid `profile.toml` fields. If a needed sidecar shape is missing from the69 references, stop and report the exact documentation gap instead of inferring70 it from `scripts/mockapi_runtime/*.py`.71- Inspect bundled Python source only to diagnose a validator or generator defect72 after running the committed scripts. Do not use script source to discover73 valid sidecar fields, defaults, or profile behavior policy.74- Do not run dependency installation inside the skill folder.75- For generated package dependency/script steps, use76 `scripts/detect_package_manager.py`; do not hand-roll `command -v` package77 manager checks or rely on interactive shell startup files.78- In `generate` workflows, run generated package codegen before implementing or79 editing LLM-owned controller wiring or feature modules.80- Do not edit OpenAPI contracts unless the user explicitly requests contract81 changes.82- Treat `.mockapi/profile.toml` and `.mockapi/behavior.md` as the durable83 source of truth for generation.84- For any `generate` workflow, run `scripts/generate.py --run-codegen` after85 successful validation. If validation fails, repair sidecars or report blockers86 instead of running the generator on invalid data.87- Treat `profile.toml` as the structural operation index. Implement operation88 behavior from the matching `behavior.md` anchor, not from operation shape.89- Use `reference/sidecars.md` for sidecar shape and validation expectations.90- Use `reference/generated-server.md`, `reference/mock-server-structure.md`,91 `reference/mock-server-examples.md`, `reference/seed-data.md`,92 `reference/testing.md`, and `reference/mock-server-quality.md` when93 inspecting or finishing generated server code.9495## Bundled Scripts9697Validate sidecars:9899```bash100<python> <skill-root>/scripts/validate_profile.py101```102103Preflight sidecars for generate:104105```bash106<python> <skill-root>/scripts/preflight_generate.py --root .107```108109Profile-only validation:110111```bash112<python> <skill-root>/scripts/validate_profile.py --profile-only113```114115Generate server scaffold and run codegen:116117```bash118<python> <skill-root>/scripts/generate.py --root . --profile .mockapi/profile.toml --run-codegen119```120121Detect generated package manager for manual regeneration:122123```bash124<python> <skill-root>/scripts/detect_package_manager.py --root . --profile .mockapi/profile.toml125```126127Final quality gate after implementation only:128129```bash130<python> <skill-root>/scripts/check_generated_quality.py --package-root <packageRoot> --profile .mockapi/profile.toml131```