Home › Vue / Nuxt › Nuxt 4 AGENTS.md

Nuxt 4 AGENTS.md

AGENTS.md for Nuxt 4 apps: the app/ directory layout, data fetching keys, server routes with validation, and runtime config.

AGENTS.mdVue / Nuxt

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

AGENTS.mdDownload  
# AGENTS.md: Nuxt 4

## Commands
`npm run dev` · `npm run build` · `npx nuxi typecheck` · `npm run lint` · `npx vitest run` (with `@nuxt/test-utils`)

## Layout (Nuxt 4)
- App code in `app/` (`app/pages`, `app/components`, `app/composables`, `app/layouts`, `app/middleware`). Server code in `server/` (`server/api`, `server/routes`, `server/utils`). Shared types/utils in `shared/`.
- Auto-imports are on; don't add manual imports for Vue/Nuxt composables or components in those folders.

## Data
- Fetch with `useFetch('/api/orders')` or `useAsyncData('orders', () => $fetch(...))` with a stable key; don't call `$fetch` directly in `setup` for SSR data (it double-fetches).
- Handle `pending`/`status` and `error` in templates. Use `watch` options or reactive params for refetching.
- Shared SSR-safe state via `useState('key', () => init)`, Pinia for larger stores.

## Server routes
- `server/api/orders.post.ts` with `defineEventHandler`. Validate with `readValidatedBody(event, schema.parse)` / `getValidatedQuery` (zod). Throw `createError({ statusCode: 400, statusMessage })`.
- Auth checked in each handler via a `server/utils` helper (`requireUser(event)`).

## Config
- `runtimeConfig` in `nuxt.config.ts` for secrets (server only) and `runtimeConfig.public` for client-safe values; override with `NUXT_*` env vars. Never read `process.env` in app code.

## Done
Typecheck, lint, tests, and `npm run build` pass.

More: all Vue / Nuxt rules · all AGENTS.md rules

Related rules

Nuxt 3 + Vue rules

Cursor rules for Nuxt 3 / Vue 3 apps using the Composition API, script setup and Pinia.

CursorVue / Nuxt

Vue 3 + Pinia AGENTS.md

AGENTS.md for Vue 3.5 single-page apps on Vite with the Composition API, Pinia, and Vue Router 4.

AGENTS.mdVue / Nuxt

Browser extension with WXT AGENTS.md

AGENTS.md for cross-browser Manifest V3 extensions built with WXT: entrypoints, messaging, storage, and permissions.

AGENTS.mdChrome extensions

htmx + server-rendered HTML AGENTS.md

AGENTS.md for htmx 2 apps with server-rendered templates (any backend), partials, and progressive enhancement.

AGENTS.mdhtmx

Next.js AGENTS.md

AGENTS.md for Next.js 16 App Router projects: commands, folder layout, data access, auth, and done criteria.

AGENTS.mdNext.js

SvelteKit AGENTS.md

AGENTS.md for SvelteKit 2 + Svelte 5 (runes) apps with TypeScript.

AGENTS.mdSvelteKit

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.