Free rules / Generate

Free rules file generator for Cursor, Claude Code, Codex and Copilot

Answer five short questions and get a rules file you can save in your repo: a Cursor .mdc rule, CLAUDE.md, AGENTS.md (Codex and other tools that read it), or .github/copilot-instructions.md. It tells you the exact file name and folder, and warns you about the size and file-type mistakes that make a tool skip or cut off a rules file.

Checked against the docs on · Your file · Things to check · Where the rules come from · Docs links

Template only. Runs in your browser. This page fills in a template with your answers. It makes no AI or model calls and sends nothing to a server, and nothing you type or tick is stored: close the tab and it's gone. Like every page on this site, the visit itself is counted by Vercel Web Analytics; your answers aren't part of that. If you'd rather check, the page works with your network turned off after it loads.

Your answers

1. WHICH TOOL?

WHEN SHOULD CURSOR APPLY IT?

2. STACK OR FRAMEWORK

Next.js, discord.js and game jam have a stack section built from our docs-checked pages. The other stacks get the general rules only.

3. LANGUAGE AND PACKAGE MANAGER

4. COMMANDS (OPTIONAL)

5. HARD RULES

Your file

Save as .cursor/rules/core.mdc (create the .cursor/rules folder first if it isn't there).

69 lines · 5,129 bytes

---
description: Project rules for AI coding agents - Next.js (App Router)
alwaysApply: true
---
# Project rules

## Project facts
- Stack: Next.js (App Router)
- Language: TypeScript
- Package manager: npm. Use it for installs and scripts; don't switch package managers or add a second lockfile.

## How to work
- Read the files you will change plus 2-3 neighbours. Match their patterns, naming, error handling and test style.
- Make the smallest diff that fully solves the task. No drive-by refactors, renames or reformatting.
- If the task touches more than one file or ~30 lines, write a short plan (files + approach) first.
- If the request is ambiguous, ask one focused question instead of guessing.
- Ask before adding a dependency, and say why it's needed.

## Safety
- Never hard-code, log or echo secrets. Read them from env vars at runtime.
- Every env var the code reads goes in `.env.example` with a placeholder value. `.env*` files (except `.env.example`) stay out of git.
- Public prefixes (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `PUBLIC_`) end up in the browser bundle. Never put server keys behind them.
- Ask before anything destructive: deleting data, dropping tables, `git push --force`, `rm -rf`, migrations against production.

## Verify and report
- Run what the project has: typecheck, lint, tests, build. Fix failures instead of suppressing them.
- New behaviour gets a test, or a one-line reason why not.
- End every task with: what changed, files touched, how you verified it, and anything left undone or risky.

## Next.js 16 rules

These rules are for Next.js 16. If this project is on an older Next.js version, delete this section.

### Versions
- Node.js 20.9 or newer, TypeScript 5.1 or newer. Don't suggest Node.js 18.
- Don't add `--turbopack` or `--turbo` to scripts: Turbopack is already the default for `next dev` and `next build`.

### Request APIs are async only
- Always `await cookies()`, `await headers()`, `await draftMode()`.
- In pages, layouts, route handlers, `default.js` and metadata image files, `params` is a Promise: `const { slug } = await props.params`. In pages, `searchParams` is a Promise too.
- Use the generated helper types (`PageProps<'/blog/[slug]'>`, `LayoutProps`, `RouteContext`; run `npx next typegen`) instead of hand-written prop types.
- `opengraph-image`, `twitter-image`, `icon` and `apple-icon` functions get `params` and `id` as Promises: await them. `sitemap({ id })` gets `id` as a Promise<string>. `generateImageMetadata` still gets plain `params`.
- In Client Components that receive these Promises, unwrap them with React's `use()`.

### proxy.ts, not middleware.ts
- New request interception goes in `proxy.ts` (or `proxy.js`) and the exported function is named `proxy`. The `middleware` file name and export are deprecated.
- `proxy` always runs on the Node.js runtime and can't be configured. If the existing middleware needs the edge runtime, keep `middleware.ts` and say so; never rename it silently.
- Config flags with "middleware" in the name are renamed (for example `skipMiddlewareUrlNormalize` is now `skipProxyUrlNormalize`).

### Caching APIs
- `revalidateTag(tag, profile)` needs the second argument, for example `revalidateTag('posts', 'max')`. The one-argument form is deprecated.
- In a Server Action where the user must see their own change right away, use `updateTag(tag)` (Server Actions only). Use `refresh()` from `next/cache` to refresh the client router from a Server Action.
- Import `cacheLife` and `cacheTag` from `next/cache` without the `unstable_` prefix.
- Don't add `experimental.ppr`, `experimental_ppr`, `experimental.dynamicIO` or `experimental.useCache`: they are removed. `cacheComponents: true` is a different model, not a rename; don't turn it on just to finish an upgrade.
- Don't turn on `reactCompiler` just to finish an upgrade either; it is opt-in and slows builds.

### Config that no longer exists
- No `next lint` (removed) and no `eslint` key in next.config. Lint with the ESLint CLI (flat config) or Biome. `next build` no longer lints.
- No `serverRuntimeConfig`, `publicRuntimeConfig` or `getConfig()`. Use `process.env` on the server and `NEXT_PUBLIC_` variables for the client.
- Turbopack options go in top-level `turbopack`, not `experimental.turbopack`.
- A custom `webpack` config makes `next build` fail. Ask before switching the build to `--webpack`.
- No AMP (`next/amp`, `amp` config): removed.
- Every parallel route slot (`@slot`) needs a `default.js` that returns `null` or calls `notFound()`, or the build fails.
- Don't add `experimental.viewTransition` (removed in 16.3) or `experimental.appNewScrollHandler` (removed in 16.4).

### next/image
- Use `images.remotePatterns`, not `images.domains` (deprecated). Use `next/image`, not `next/legacy/image`.
- Defaults changed: `qualities` is `[75]` (other `quality` values are coerced to the closest allowed one), `minimumCacheTTL` is 4 hours, `16` is gone from `imageSizes`, at most 3 redirects, local IPs are blocked.
- A local `src` with a query string (`/photo.png?v=1`) needs a matching `images.localPatterns` entry with `search`.
How to create the folder

Mac, Linux or Git Bash, in your repo folder:

mkdir -p .cursor/rules

Windows PowerShell, in your repo folder:

New-Item -ItemType Directory -Force .cursor/rules

If you save with a text editor, set the file type to “All files” so Windows doesn't add .txt. The DOWNLOAD button uses the exact file name.

Things to check

  • Save it as a .mdc file in .cursor/rules. Cursor ignores a plain .md file in that folder, because project rules must use the .mdc extension.
  • The frontmatter at the top (description, globs, alwaysApply) is already filled in. Keep the --- lines: a .mdc with no frontmatter sets none of those fields.
  • OK: 69 lines. Cursor's help page advises keeping rules under 500 lines.
  • The Next.js section is written for Next.js 16. On an older version, delete that section.
  • No test, lint or build command entered. Add them above so your agent runs the right ones.
  • After you save it, run the free read-only check in your repo to see every agent file it loads and to confirm the file is where the tool looks.

Want a head start on a project that already follows these rules? The SaaS Starter Cartridge ($49) is a working Next.js 16 app with sign-in, Stripe subscriptions, tests and the Next.js 16 rules built in.

What it doesn't do

Where the rules come from

Nothing in the output is new tool behavior. Every rule is reused as written from a page that was checked against official docs, and each of those pages shows its own checked date:

Checked against the docs on Nov 28, 2026

The file names, folders and limits this page states were checked on Nov 28, 2026 on these official pages: Cursor project rules must be .mdc and a plain .md in .cursor/rules is ignored; Cursor rules use description, globs and alwaysApply frontmatter; Cursor's help page advises keeping rules under 500 lines; Claude Code reads CLAUDE.md or .claude/CLAUDE.md and advises under 200 lines; Codex reads AGENTS.md and stops at 32 KiB combined by default; Copilot reads .github/copilot-instructions.md.

More free pages: all free rules files · check which agent files a repo loads · which rules file each tool reads.

NEWSLETTER

Get new cartridges and free rules in your inbox. About 2 emails a month, no spam, unsubscribe anytime.

Opens Buttondown in a new tab. Confirm via the email they send. Past issues