api-regeneration
Regenerate TypeScript types after editing api.yml / connectionProfile.yml / connectionState.yml. Use whenever a spec file changes.
SKILL.md.claude/skills/api-regeneration/SKILL.md
GitHubRegenerating after spec edits
After any change to api.yml, connectionProfile.yml, or connectionState.yml, the generated TypeScript under generated/ and hub-sdk/generated/ is stale. Code that imports ../generated/model/index.js will compile against the previous shape until you regenerate.
Command
From the module directory:
zbb generate
That single task chains through syncMeta → assembleSpec → bundleSpec → generate*, rewriting:
generated/api/— connector interface, tag APIs, operation wrappers,manifest.jsongenerated/model/—ConnectionProfile,ConnectionState, resource types, enumshub-sdk/generated/— the typed client e2e tests import
You do not need to clean first — gradle's input-aware caching invalidates the right outputs. If gradle reports UP-TO-DATE after a spec edit, the spec file may not be staged for the task; run zbb clean && zbb generate to force.
When to run
- After any commit-worthy change to
api.yml(paths, components, security, examples) - After editing
connectionProfile.ymlorconnectionState.yml - After updating a
$reftarget version (e.g. bumping@zerobias-org/product-…) - Before invoking
:compileor:test— both depend on:generateindirectly, so they'll trigger it themselves, but running:generatedirectly is faster for catching codegen errors early
You do not need to run it:
- While iterating on
api.yml— finish the edit pass, then regenerate once - For source-only edits in
src/ortest/ - To "just check" — gradle's daemon already knows what's stale
What to look for in the output
> Task :<…>:syncMeta
> Task :<…>:assembleSpec
> Task :<…>:bundleSpec
> Task :<…>:generate
If bundleSpec fails with Can't resolve $ref:
- Inspect the offending reference; it's usually a path that needs a published dependency (e.g.
./node_modules/@zerobias-org/product-foo/catalog.yml#/Product) - Confirm
npm view @zerobias-org/product-foo versionreturns something; if not, the dep needs publishing - For module interface refs, use the bundled spec in the package's
dist/, not the rawapi.yml:# CORRECT $ref: ./node_modules/@zerobias-com/interface-foo/dist/interface-foo.yml#/paths/...
If generate fails:
- Surface the codegen error verbatim — it usually points at a schema with conflicting types or an
operationIdthat doesn't match^[a-z][a-zA-Z0-9]+$ - Don't hand-edit
generated/to "fix" the error; that directory is gitignored and overwritten every run
What it does NOT do
:generate doesn't run :compile, :test, or :lint. Those run on demand or as part of :build / :gate. Run them separately when you need them:
zbb compile # tsc against src/, test/, generated/
zbb test --slot local # mocha in-process
zbb build # full lifecycle
Common pitfalls
- Editing
generated/directly — overwritten on next:generate. Make the change inapi.ymlinstead. - Cleaning
hub-sdk/generated/by hand — same story. Gradle owns it. - Skipping
:generateafter spec edit —:testwill still pass against stale types and you'll get a confusing runtime error later. Always regenerate before testing a spec change. - Multiple
:generateinvocations — fine; gradle caches. The cost is small. - CI failures with "spec drift" — locally the daemon was warm and skipped a step. CI runs from cold; reproduce with
zbb clean && zbb build.
Related
- @.claude/skills/api-spec-core/SKILL.md — what makes a valid
api.yml - @.claude/skills/connection-profile/SKILL.md —
connectionProfile.yml/connectionState.ymlshape - @.claude/skills/tool-requirements/SKILL.md — zbb command reference
- @.claude/skills/build-quality/SKILL.md — full lifecycle checkpoints