nextjs-codes

nextjs-codes is a cursor rule for Cursor from sebastien-le-paris/project-rules. It costs 0 tokens per session (753 once invoked), scanned A, original, Apache-2.0.

A set of instructions for building maintainable web applications with TypeScript, React, Next.js, and common interface libraries. It covers code structure, performance, security, validation, and styling.

In plain words
What is it for?
It helps build or refactor Next.js pages, React components, data-fetching features, forms, and styled interfaces.
Why use it?
It gives the coding agent consistent rules for organizing components and avoiding unnecessary browser-side work, while still accounting for loading, errors, and accessible interfaces.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sebastien-le-paris/project-rules/nextjs-codes
Clone the repo
git clone --depth 1 https://github.com/sebastien-le-paris/project-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nextjs-codes

README.md
[![agentmods](https://agentmods.dev/badge/rules/sebastien-le-paris/project-rules/nextjs-codes.svg)](https://agentmods.dev/rules/sebastien-le-paris/project-rules/nextjs-codes)
Your own site
<a href="https://agentmods.dev/rules/sebastien-le-paris/project-rules/nextjs-codes"><img src="https://agentmods.dev/badge/rules/sebastien-le-paris/project-rules/nextjs-codes.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 753 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00753
Opus 5 $0.00000 $0.00377
Sonnet 5 $0.00000 $0.00151
Haiku 4.5 $0.00000 $0.00075

Measured 2d ago against content hash 8e9bc8b29796, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

nextjs-codes scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/nextjs-codes.mdc · 64 lines

How it starts

The opening of the file, as written. The whole thing — 64 lines — stays where its author put it; the contents beside it link to each section on GitHub.


description: globs:

You are an expert full-stack developer proficient in TypeScript, React, Next.js, and modern UI/UX frameworks (e.g., Tailwind CSS, Shadcn UI, Radix UI). Your task is to produce the most optimized and maintainable Next.js code, following best practices and adhering to the principles of clean code and robust architecture.

Objective

  • Create a Next.js solution that is not only functional but also adheres to the best practices in performance, security, and maintainability.

Code Style and Structure

  • Write concise, technical TypeScript code with accurate examples.
  • Use functional and declarative programming patterns; avoid classes.
  • Favor iteration and modularization over code duplication.
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
  • Structure files with exported components, subcomponents, helpers, static content, and types.
  • Use lowercase with dashes for directory names (e.g., components/auth-wizard).

Optimization and Best Practices

  • Minimize the use of 'use client', useEffect, and setState; favor React Server Components (RSC) and Next.js SSR features.
  • Implement dynamic imports for code splitting and optimization.
  • Use responsive design with a mobile-first approach.
  • Optimize images: use WebP format, include size data, implement lazy loading.

Error Handling and Validation

  • Prioritize error handling and edge cases:
    • Use early returns for error conditions.
    • Implement guard clauses to handle preconditions and invalid states early.
    • Use custom error types for consistent error handling.

UI and Styling

  • Use modern UI frameworks (e.g., Tailwind CSS, Shadcn UI, Radix UI) for styling.
  • Implement consistent design and responsive patterns across platforms.

State Management and Data Fetching

  • Use modern state management solutions (e.g., Zustand, TanStack React Query) to handle global state and data fetching.
  • Implement validation using Zod for schema validation.

Read the full file on GitHub · 64 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 64 lines · 0 tokens per session scan A 8e9bc8b29796

Subscribe to this mod's changes

nextjs-codes is a cursor rule published in the GitHub repository sebastien-le-paris/project-rules (0 stars, last pushed 1y ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 753 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.