next-openapi-gen
AGENTS.md193 starsChanged 3 months agoMITView on GitHub
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ before writing any code. Heed deprecation notices.
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Prefer Oxc config to stay close to standard defaults and avoid large hand-maintained rule lists unless there is a clear repo-specific need.
- Very specific: line 13
Prefer standard, concise module names over verbose create-* filenames when the exported symbol already carries the constructor/factory …
- Distinctive: line 16
Prefer a single shared Zod schema per domain when practical instead of parallel DTO or duplicate inferred types.
- Distinctive: line 18
Prefer committed workspace editor defaults when they make formatter, lint, and TypeScript SDK behavior consistent across contributors and …
- Very specific: line 19
Prefer internal workspace package boundaries for core, CLI, init, and framework code when restructuring, while keeping …
- Distinctive: line 21
Keep Vitest coverage exclusions minimal.
- Distinctive: line 22
After a source restructure, prefer stable imports to concrete implementation files instead of keeping long-lived barrel re-export layers as …
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- BEGIN:nextjs-agent-rules -->This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->Learned User Preferences
- Prefer Oxc config to stay close to standard defaults and avoid large hand-maintained rule lists unless there is a clear repo-specific need.
- Prefer simpler, direct APIs over wrapper factories or overly clever abstraction layers when they do not add clear value. Preserve existing user-facing CLI/API behavior during internal refactors, and avoid adding new config or customization surface unless it is explicitly requested; when promoting experimental options to stable config, drop legacy experimental shims rather than keeping backward-compatibility aliases unless a deprecation window is explicitly requested. At app or API boundaries, prefer one client factory with direct method calls, inlining it when a call site uses it only once; for multipart uploads, prefer explicit
@bodyschemas over the bodyless@contentType multipart/form-databinary-filefallback when richer typed forms are needed. KeepclientSdka thin post-generate wrapper around an external generator rather than vendoring a client SDK product; leave custom OAuth/OIDC scheme objects incomponents/schemaFilesinstead of growing JSDoc into a scheme DSL. - Prefer standard, concise module names over verbose
create-*filenames when the exported symbol already carries the constructor/factory meaning. - Prefer
.ts/.mtsfor tool and config files when the tool supports it, with proper typing over workarounds that drop type safety; keep inherently non-TS formats as-is (.json,.yaml,.editorconfig,.gitattributes,.gitignore, GitHub Actions workflow files); migrate remaining JavaScript-based configs where the toolchain supports typed configs cleanly (including release tooling and example apps). - Prefer
openapi-genas the forward-looking CLI/config naming andopenapi-gen.config.tsas the TypeScript config format.initwritesopenapi-gen.config.tswithdefineConfigby default and still writes JSON when--outputends in.json. Sample apps keep a mix ofopenapi-gen.config.ts/.mts/.jsonplus legacynext.openapi.jsonandnext-openapi-genso discovery and both binaries stay covered. Keep those legacy names working through a deprecation window instead of breaking existing apps immediately. - Prefer a single shared Zod schema per domain when practical instead of parallel DTO or duplicate inferred types; keep provider-specific mapping in the provider package.
- Prefer
package.json, VS Code tasks, and Turbo pipelines composed from plainpnpmand upstream CLIs over bespoke.mjsorchestrators, and avoid duplicate script entries such as:turbovariants that only mirror an existing command. For pnpm release-age issues, prefer pinning a slightly older package version over addingminimumReleaseAgeExclude. - Prefer committed workspace editor defaults when they make formatter, lint, and TypeScript SDK behavior consistent across contributors and agents.
- Prefer internal workspace package boundaries for core, CLI, init, and framework code when restructuring, while keeping
packages/next-openapi-genas the public compatibility and install surface until an explicit publishing change is requested. - Keep automated tests for shared library behavior under the repo root
tests/directory with domain-aligned subfolders that mirrorsrc/; put cross-cutting scenario or behavior checks intotests/**/regressions/rather than leaving them flat at the root. Prefer checked-in project-style fixtures plus temp-copy harnesses for integration coverage over inline-generated temp app trees when realistic app structure matters; align integration coverage with documented JSDoc tags and README-backed examples where practical, and use real handler bodies in fixtures when testing implementation-driven inference. Prefer JSDoc tag names that match official OpenAPI field names, and keep aliases when renaming tags. Spread new generator features and annotations acrossapps/sample projects with realistic domain-shaped APIs instead of concentrating demos in one app. - Keep Vitest coverage exclusions minimal; do not broadly exclude core source directories just to satisfy coverage thresholds.
- After a source restructure, prefer stable imports to concrete implementation files instead of keeping long-lived barrel re-export layers as the primary layout.
Learned Workspace Facts
- Shared TypeScript baselines in
packages/typescript-config(base.json,nextjs.json,library.json) intentionally follow a stricter preset. Emitting workspace packages extendlibrary.json(composite+isolatedDeclarations) and are wired with project references from the roottsconfig.json;pnpm typecheck:packagesrunstsc -b. - Workspace editor defaults live in
.vscode/; they point TypeScript at the workspace SDK and use the Oxc VS Code extension for formatting and fixes. - Git hooks are installed via
simple-git-hooksfrom the rootpackage.json;pre-commitrunslint-stagedwith Oxfmt/Oxlint usingoxfmt.config.tsandoxlint.config.ts, andcommit-msgrunscommitlint. Root Ox configs ignore**/public/openapi.json; when only such generated JSON is staged,oxfmtcan otherwise receive no paths, so lint-staged runsoxfmtwith--no-error-on-unmatched-pattern(rootpackage.json). - The workspace pins a Zod 3 compatibility catalog (and related apps) to the latest Zod 3 line; broad dependency major upgrades should not fold that track onto Zod 4. The AST Zod converter in
packages/openapi-core/src/schema/zod/zod-converter.tsmust handle Zod Mini (zod/mini,zod/v4/mini) functional APIs—z.extend,z.optional/z.nullable,.check(z.minLength(...))—via structural dispatch, not only chain forms; top-levelz.extendon thezbinding must not use the named-schema.extendpre-check. Shared nullability lives innullability.ts; non-discriminated unions emitanyOf(notoneOf);z.undefined()union branches map to optional semantics. - Vitest coverage thresholds in
vitest.config.tscoverageScopesare tiered: satellites (CLI, init, frameworks, Arazzo, Overlay, facade) are99/95/99/99for statements, branches, functions, and lines;openapi-coreand the unscoped fallback are95/92/95/95. - Integration generator fixtures live under
tests/fixtures/projects/, andtests/helpers/test-project.tsprovides temp-copy, template-materialization, and isolated-cwd helpers for running them; thenext/app-router/core-flowfixture carries checked-in OpenAPI3.0/3.1/3.2templates plus upload routes covering schema-backed and bodyless multipart request bodies, andapps/next-app-next-configplusapps/next-app-zodserve as concrete3.1/3.2examples. Large-scale*-at-scalefixtures and appgenerated/trees are produced bypnpm generate:scale-fixtures; regenerate instead of hand-editing generated route or schema files, and keep them committed because CI does not rungenerate:scale-fixtureson checkout, exceptapps/next-app-drizzle-zodscale output (src/app/api/generated/,src/schemas/generated/,src/db/schema.generated.ts), which stays gitignored becausedrizzle-zod@0.8.3infers Zod 4 types that fail typecheck against that app's Zod 3 pin. TanStack/React Router scale routes fromscripts/fixture-scale/routes.mtsreference types via JSDoc only (noimport typeblocks), matching Next.js generated routes. - The repo now uses internal workspace packages for the generator split:
packages/openapi-core,packages/openapi-cli,packages/openapi-init,packages/openapi-framework-next,packages/openapi-framework-tanstack,packages/openapi-framework-react-router,packages/openapi-framework-remix,packages/openapi-framework-sveltekit,packages/openapi-framework-nuxt,packages/openapi-framework-astro,packages/openapi-framework-hono,packages/openapi-framework-express,packages/openapi-arazzo, andpackages/openapi-overlay, whilepackages/next-openapi-genremains the public compatibility facade. SupportedFrameworkKindvalues stay a closed enum: Next.js, TanStack, React Router, Remix, SvelteKit, Nuxt, Astro, Hono, and Express. Unknownframework.kindvalues error instead of falling back to Next.js.*-at-scalefixtures and bench matrix rows for the six newer stacks are a follow-up after their core-flow fixtures and sample apps. Keep Arazzo and Overlay as sibling packages rather than inlining them into core. Overlay 1.2 supports reusablecomponents.actionsplus$ref,$self, and optionaltargetFormat(openapi|asyncapi|arazzo);applyOverlayis format-agnostic, but the generator does not emit AsyncAPI documents. Published packages declare TypeScript>=5.9 <8;packages/openapi-core/src/shared/typescript-runtime.tsresolves the project-local compiler first with a bundled fallback, routes TS 5.9/6.x through classiclib/typescript.js, and TS 7.x through the native adapter innative-typescript-adapter.ts; the workspace catalog pins TypeScript7.0.2for baselinetscand sample apps, whileopenapi-coreand publishednext-openapi-genuse thetypescript-classiccatalog (npm:@typescript/typescript6@6.0.2) so classic compiler types and the bundled fallback stay on 6 and consumers on 5.9–6 are not hoisted onto 7. - Built-in docs UI template assets live under
packages/openapi-init/templates/init/ui/{nextjs,tanstack,react-router,remix,sveltekit,nuxt,astro,hono,express};packages/openapi-init/src/init/ui-registry.tsmaps UI metadata to those template files, the published package includes thetemplatesdirectory alongsidedist, and docs-page scaffolding dispatches by framework instead of assuming Next-only output. Generate-time emission uses the samecreateDocsPage({ framework })path for every supported kind; sample apps stay opted out sogenerate:appsdoes not overwrite hand-scaffolded docs pages. apps/next-app-adapteris the only Next sample that should useadapterPath(pointing at a siblingnext-openapi.adapter.mjs);apps/next-app-next-configwraps itsnext.config.tswithwithNextOpenApifromnext-openapi-gen/nextand must stayadapterPath-free.apps/next-app-ts-configowns theclientSdkgolden path: a typed config entry plus a thin env-gatedopenapi-generator-cliwrapper (GENERATE_CLIENT_SDK=1). Sample Next apps inherit shared@workspace/next-config(cacheComponents,partialPrefetching,agentRules: falsesonext devdoes not write sample-app AGENTS.md/CLAUDE.md;experimental.useTypeScriptClistays true because TypeScript 7 has no JavaScript compiler API).packages/next-openapi-genCLI bundling intsup.config.tsmust externalize non-workspace runtime dependencies; bundling CommonJS packages likecommanderinto the ESM CLI breaks sample-appgeneratewith Node'sDynamic requireerror. A committed bin wrapper atpackages/next-openapi-gen/bin/cli.mjsdelegates to the built CLI so thenext-openapi-gen/openapi-gencommands resolve in clean checkouts before any workspace build runs. Playwright e2e (playwright.config.ts) prebuilds the CLI workspace graph withpnpm exec turbo run build --filter=next-openapi-gen...so internal packages havedist/outputs, setsEXPOSE_TESTING_API=1soexperimental.exposeTestingApiInProductionBuildis on for measurednext builds, andtests/e2e/instant-nav.spec.tslocks Cache Components instant navigation fornext-app-drizzle-zod(seeinstant-nav.rig.md).- GitHub Actions CI is defined in
.github/workflows/ci.yml(quality, build, unit, integration, coverage, parallelized E2E,typescript-compatibilitymatrix for TS 5.9.3/6/7, default-branch/workflow_dispatch); standard Linux jobs usepnpm exec turbo runfor build and other tasks wired inturbo.jsonwhere applicable;.github/dependabot.ymlmaintains Actions dependencies; generator benchmarks usevitest.bench.config.ts(pnpm test:bench,pnpm test:bench:vitestundertests/bench), with a committed generator baseline attests/bench/generator/baseline.json, CLI subprocess benchmarks undertests/bench/cli/, and workflow notes indocs/performance.md;test:bench:schemascopes discovery with--dir tests/bench/schemaso Vitest does not duplicate benchmarks from.pnpm-store. The route-parse worker bench (tests/bench/generator/route-parse-worker.bench.ts) needs@babel/parseras a direct rootdevDependencybecause worker threads resolve modules from the workspace root. - OpenAPI generation writes
.openapi-gen/manifest.jsononly whenNODE_ENV !== "production"; it is dev-only metadata (for example config path, diagnostics, performance) and.openapi-gen/stays gitignored. Generator disk cache is on by default via top-levelcache: true(OPENAPI_GEN_CACHE=0/1overrides); route fragments and input hashes reuse unchanged work across runs. Generator output must be deterministic across runs: paths are sorted by folder path, then file name, then HTTP method, so re-generating the spec does not create order-only diffs. Bodyless@contentType multipart/form-dataroutes without@bodyemit a required multipart body with a binaryfilefield. Built-in auth presets emit defaultcomponents.securitySchemesobjects when a referenced scheme is missing (existingcomponents/schemaFiles/ templates win);@authand@securitytreat comma as OR and semicolon as AND. Supported OpenAPI targets are3.0,3.1,3.2, and experimental3.3-preview; OpenAPI 4.0 is not supported, and unreleased3.3.0/4.xfall back to3.2.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository23 other files it gives its agents.
- .agents/skills/typescript/AGENTS.mdAGENTS.md
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- .agents/skills/vitest/AGENTS.mdAGENTS.md
- .agents/skills/zod/AGENTS.mdAGENTS.md
- building-componentsSkill
- drizzleSkill
- find-skillsSkill
- github-actions-writerSkill
- next-cache-components-adoptionSkill
- next-cache-components-optimizerSkill
- next-dev-loopSkill
- next-partial-prefetching-adoptionSkill
- openapi-expertSkill
- openapi-specification-v3.2Skill
- playwright-best-practicesSkill
- pnpmSkill
- turborepoSkill
- typescriptSkill
- vercel-composition-patternsSkill
- vercel-react-best-practicesSkill
- vitestSkill
- zodSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

