Nuxt 3 gives you file-based routing, auto-imports, server routes, and hybrid rendering out of the box. These recipes help you use AI tools to build on that foundation without fighting the framework’s conventions. Every prompt here produces code that respects Nuxt’s directory structure, leverages auto-imports, and handles SSR/CSR boundaries correctly.
Scenario: Protected pages need to check authentication and transparently refresh expired tokens without redirecting the user.
This scaffold spans two middleware files, a plugin, and a composable — and the SSR-vs-client split (cookie on the server, useState on the client) is where AI tools quietly produce a hydration mismatch. Pick the workflow that lets you catch it.
Use agent mode to generate middleware/auth.ts, middleware/guest.ts, the plugin, and useAuth() together, then checkpoint before accepting. Auth refresh is the classic spot where the AI reads document.cookie during SSR — the inline diff lets you catch the browser-only API in setup before it crashes the server render.
Generate the whole auth surface headless, then guard the SSR boundary with a hook: add a PostToolUse hook on middleware/*.ts and plugins/*.ts that greps for document. or window. outside an onMounted/import.meta.client guard and fails the edit. Run claude -p "build the auth middleware, guest middleware, plugin, and useAuth composable" so the transparent-refresh path lands in one turn.
Develop the auth layer in a worktree so a half-finished plugin never breaks your running dev branch, then push and let the Cloud reviewer focus on the token-refresh and redirect-preservation logic — the silent-refresh edge cases are exactly what a fresh review pass surfaces.
Expected output: Two middleware files, one plugin, one composable, and integration tests.
Scenario: Your Nuxt app needs type-safe database queries, migrations, and seeding.
The database layer is schema plus typed queries plus a seed script plus migration config — a lot of files that must agree on the same types. The relations and the migration step are where tooling choice matters.
Use agent mode to generate schema.ts, the query functions, and seed.ts in one pass, watching the inline diffs so the foreign-key references (authorId references users) actually line up. Run drizzle-kit generate from the integrated terminal and review the produced SQL migration before applying.
Generate the schema and queries headless, then make the contract enforceable: add a PostToolUse hook on server/db/schema.ts that runs drizzle-kit generate so the migration never drifts from the schema. Pipe the seed run’s output back in if Faker data violates a constraint — the terminal loop makes that one command.
Build the DB layer in a worktree so an in-progress migration never touches your shared dev database, then push and let the Cloud reviewer check that every query is parameterized and the getPostsWithAuthor join paginates correctly before merge.
Scenario: Your Nuxt app has zero tests. You need coverage for components, server routes, and composables.
Standing up a test harness is config plus utilities plus the first batch of tests — and the value only lands when those tests actually run on every change, which is where the tool workflows diverge.
Use agent mode to write vitest.config.ts, the tests/utils/ helpers, and the first component tests, then run them in the integrated terminal and feed any mountSuspended failures back inline. The visual diff helps you confirm the test utilities match how your real pages mount.
The natural fit: generate the harness headless, then make tests non-optional with a PostToolUse hook that runs npm run test:unit after edits to *.vue or server/**. Use claude -p "write @nuxt/test-utils tests for these three composables and two server routes" and let it iterate against the failing output until green.
Have a Cloud task add the test suite and open a PR with coverage reported, so reviewers see the 70%-server-route threshold enforced. Generating tests in a worktree keeps the noisy new test files off your feature branch until they pass.
Expected output: Vitest config, test utilities, component tests, server route tests, composable tests, and updated scripts.