# Ship Rules

> Production rules for Next.js + TypeScript, generated for every AI coding tool.

18 production rules for Next.js, TypeScript, Tailwind, Drizzle/Prisma, Stripe, auth and testing, generated into AGENTS.md, CLAUDE.md, Cursor, Copilot and Windsurf formats from one source.

- Type: Agent Kit
- Price: €29, one-time purchase, 12 months of updates, downloads forever
- URL: https://provencart.com/products/ship-rules

## One set of rules. Every coding agent.

Your team uses Cursor, someone else swears by Claude Code, CI runs Codex, and Copilot reviews the pull requests. Each tool reads its own rules file in its own format, and most repos have one of them half filled in. Agents then guess. They cache per-user data, skip the auth check in a Server Action, trust the price that comes from the client, or put `"use client"` on a whole layout.

Ship Rules is a production rulebook for Next.js + TypeScript apps, written once in plain Markdown and generated into the native format of every major AI coding tool.

## 18 rules, 150 concrete instructions

Core principles, architecture, TypeScript strictness, React Server Components, data fetching and caching, security (OWASP-aligned), authentication and authorisation, Drizzle or Prisma, Stripe payments, Tailwind CSS, accessibility (WCAG 2.2 AA), performance and Core Web Vitals, testing, error handling, logging, i18n, SEO, and git and pull request hygiene.

These are concrete instructions an agent can act on, not vague advice. A few examples:

- Every Server Action validates its arguments and checks authorisation for the specific resource, because Server Actions are public endpoints.
- With Cache Components, every `"use cache"` gets a `cacheLife`, a `cacheTag` and an invalidation path (`updateTag` in Server Actions, `revalidateTag(tag, "max")` in webhooks).
- Stripe webhooks verify the signature against the raw body and are idempotent by event ID. Prices are always computed on the server.
- `drizzle-kit push` and `prisma db push` only touch throwaway local databases. Shared databases change through reviewed migrations.

The rules are written against Next.js 16 and React 19 (async request APIs, `proxy.ts`, Cache Components), and they tell the agent to check the installed versions first, so they also hold up on Next.js 14 and 15 projects.

## Native format for each tool

`scripts/sync-rules.mjs` (zero dependencies) turns `rules/*.md` into:

- **AGENTS.md** for Codex and every tool that reads it. At 31.4 KiB it stays inside Codex's default 32 KiB limit.
- **CLAUDE.md** that imports AGENTS.md, or split mode with `.claude/rules/*.md` and `paths:` frontmatter.
- **.cursor/rules/*.mdc** with `description`, `globs` and `alwaysApply`.
- **.github/copilot-instructions.md** plus 14 path-specific `.instructions.md` files with `applyTo`.
- **.windsurf/rules/*.md** with `always_on`, `glob` or `model_decision` triggers, plus `.windsurfrules` for older versions.

Only three rules load on every request (core, TypeScript, security). The rest attach when the agent touches matching files, so you don't pay for the Stripe rules while it edits a button.

All generated files are already in the pack, so you can copy them and you're done. When you change a rule, run the script and every tool is in sync again. `--check` fails CI when someone hand-edits a generated file or forgets to regenerate, and deleting a rule removes its generated files.

## Made to be changed

Add a `rules/05-project.md` with your own stack decisions and commands, delete the Stripe rule if you don't take payments, or tighten the globs to your folder structure. The format is plain Markdown with five frontmatter fields.

Rules steer agents; they don't replace your linter, type checks, tests or reviews. The rules tell the agent to run those before it calls a task done.

## Outcomes

- Every AI tool on the team follows the same production rules
- Fewer security holes in Server Actions, webhooks and caching
- Rules load by file path, so context stays small
- One edit in rules/*.md updates all five tool formats
- CI catches outdated or hand-edited rule files

## Features

- **18 production rules**: Architecture, TypeScript, RSC, caching, security, auth, database, Stripe, Tailwind, accessibility, performance, testing, errors, logging, i18n, SEO, git and core principles.
- **Native output for 5 tool families**: AGENTS.md, CLAUDE.md, Cursor .mdc, Copilot repository and path-specific instructions, Windsurf rules plus the legacy .windsurfrules.
- **Zero-dependency generator**: sync-rules.mjs runs on plain Node.js 18+, with --targets, --out, --claude split mode and stale file cleanup.
- **Current Next.js knowledge**: Written for Next.js 16 and React 19: async request APIs, proxy.ts, use cache with cacheLife and cacheTag, updateTag, Server Action security.
- **CI check**: --check exits with code 1 when generated files are missing, stale or edited by hand, so rules never drift between tools.

## Who it is for

- Developers using Cursor, Claude Code, Codex, Copilot or Windsurf on Next.js apps
- Teams where people use different AI coding tools on one codebase
- Tech leads who want agents to follow security and quality standards
- Agencies shipping Next.js projects for clients

## What's inside

- `rules/`: 18 source rules in Markdown with frontmatter (id, title, description, globs, alwaysApply)
- `scripts/sync-rules.mjs`: Generator for all formats, with --check for CI
- `AGENTS.md`: All rules for Codex and other AGENTS.md tools (31.4 KiB)
- `CLAUDE.md`: Claude Code entry point that imports AGENTS.md
- `.cursor/rules/`: 18 Cursor .mdc rules
- `.github/`: copilot-instructions.md and 14 path-specific .instructions.md files
- `.windsurf/rules/, .windsurfrules`: 18 Windsurf rules and the short legacy file
- `README.md, README.de.md, LICENSE.md`: Setup per tool, customisation and licence (EN and DE)

## Example: Generate every format

```bash
node scripts/sync-rules.mjs
```

```text
write   AGENTS.md
  write   CLAUDE.md
  write   .cursor/rules/00-core.mdc
  write   .cursor/rules/01-architecture.mdc
  ...
  write   .github/copilot-instructions.md
  write   .github/instructions/08-payments-stripe.instructions.md
  ...
  write   .windsurf/rules/17-git-pr.md
  write   .windsurfrules
sync-rules: 18 rules → 54 files (54 written, 0 unchanged, 0 removed).
```

## Installation

1. Copy the rules and the generator into your repository root:

   ```bash
   cp -R ship-rules/rules ship-rules/scripts your-app/
   cd your-app && node scripts/sync-rules.mjs
   ```

   Or copy the pre-generated files (`AGENTS.md`, `CLAUDE.md`, `.cursor/`, `.github/`, `.windsurf/`, `.windsurfrules`) directly.

2. Back up an existing `CLAUDE.md`, `AGENTS.md` or `.github/copilot-instructions.md` first; the generator writes these files.
3. Open the repo in your tool. Cursor, Copilot, Windsurf, Codex and Claude Code pick up their files automatically.
4. Optional: add `node scripts/sync-rules.mjs --check` to CI.

For Claude Code with path-scoped loading: `node scripts/sync-rules.mjs --claude split`.

## Requirements

- One or more of: Cursor, Claude Code, OpenAI Codex, GitHub Copilot, Windsurf, or another tool that reads AGENTS.md
- Node.js 18+ to regenerate files (not needed to use the pre-generated files)
- A Next.js + TypeScript project (rules also cover Tailwind, Drizzle/Prisma and Stripe where you use them)

## FAQ

**Which tools are supported?**

Cursor (`.cursor/rules/*.mdc`), Claude Code (`CLAUDE.md`, optionally `.claude/rules/`), OpenAI Codex (`AGENTS.md`), GitHub Copilot (`.github/copilot-instructions.md` and `.github/instructions/*.instructions.md`) and Windsurf (`.windsurf/rules/` and `.windsurfrules`). Other tools that read `AGENTS.md` work too, for example Zed, Jules and Amp. Aider and Gemini CLI work if you point them at the file.

**Do I need Next.js 16?**

No. The rules describe current Next.js 16 and React 19 behaviour, and they tell the agent to check the installed versions before using version-specific APIs. On Next.js 14 or 15 the agent follows the older caching model and APIs that your project actually uses.

**We don't use Stripe or Prisma. Is it still useful?**

Yes. Delete the rules you don't need and run the sync; their generated files are removed. Payment and database rules only load when matching files are touched anyway. The database rule covers Drizzle and Prisma.

**How do I add our own conventions?**

Create a file such as `rules/05-project.md` with frontmatter (id, title, description, globs, alwaysApply) and Markdown bullets, then run `node scripts/sync-rules.mjs`. Your rule then shows up in every tool format. Never edit the generated files directly, because `--check` flags them.

**Won't this fill the context window?**

Only three rules load on every request: core, TypeScript and security. The others are path-scoped in Cursor, Copilot, Windsurf and Claude Code split mode. AGENTS.md contains everything and stays inside Codex's default 32 KiB limit.

**Licence and updates?**

Use it in unlimited projects of your own and for your clients. Reselling or publishing the rule files themselves is not allowed. The one-time purchase includes 12 months of updates, for example when a tool changes its rule format, and downloads stay available forever.

**Can I get a refund?**

It's digital content that you can download straight away. At checkout you agree that delivery starts immediately and that your right of withdrawal expires (§ 356 (5) BGB). If a tool doesn't pick up the rules or something else doesn't work, write to us and we'll sort it out with you.

Keywords: cursor rules, AGENTS.md, CLAUDE.md, copilot instructions, windsurf rules, Next.js rules, TypeScript, React Server Components, AI coding rules, mdc rules, Codex, Next.js 16, Stripe, Drizzle, Prisma
