cursorrules

A set of project rules for building a Next.js web application with TypeScript, Tailwind CSS, a database layer, tests, and common deployment tools. Next.js is a framework for creating web applications with React.

In plain words
What is it for?
Use it while editing this application so new pages, components, database code, tests, and deployment-related changes follow the project’s conventions.
Why use it?
It gives the coding agent consistent rules for routing, server and browser code, data fetching, styling, testing, and project structure.

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/whenlabs-org/when/cursorrules
Clone the repo
git clone --depth 1 https://github.com/WhenLabs-org/when

Made for: Cursor.

Per session 964 This file is loaded in full into every session.
When invoked 964 The same file — it is already loaded in full.
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.00964 $0.00964
Opus 5 $0.00482 $0.00482
Sonnet 5 $0.00193 $0.00193
Haiku 4.5 $0.00096 $0.00096

Measured yesterday against content hash a26a958f6cf1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cursorrules 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 yesterday.

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.

packages/aware/tests/fixtures/nextjs-app/.cursorrules · 48 lines

How it starts

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

You are working on nextjs-app.

Tech stack: Next.js (App Router), TypeScript, Tailwind CSS, Drizzle ORM, postgres, Vitest + playwright + testing-library, ESLint + Prettier, pnpm, Vercel, NextAuth.js, tRPC

Rules:

  • Use the app/ directory; every route folder needs a page.tsx to be publicly accessible
  • Add 'use client' at the top of a file only when the component needs interactivity, browser APIs, hooks (useState, useEffect), or event handlers
  • Never import a Server Component into a Client Component — pass it as children instead
  • Use fetch() with Next.js extended options: { cache: 'force-cache' } (default, static), { cache: 'no-store' } (dynamic), or { next: { revalidate: N } } for ISR
  • Use utility classes directly in markup — avoid writing custom CSS unless absolutely necessary
  • Never use @apply in component styles — it defeats the purpose of utility-first CSS and increases bundle size
  • Dark mode: use dark: variant; configure strategy (class or media) as needed
  • Use design tokens from the theme for consistency — avoid arbitrary values like w-[137px] unless truly one-off
  • Use the dialect-specific column builders: pgTable, mysqlTable, or sqliteTable
  • Use $inferSelect and $inferInsert to derive TypeScript types from table definitions — never manually duplicate types
  • Use the query builder API (db.select().from(users).where(eq(users.id, id))) for most operations
  • Use the relational query API (db.query.users.findMany({ with: { posts: true } })) for nested/related data
  • Use publicProcedure for unauthenticated endpoints; create protectedProcedure with auth middleware for authenticated ones
  • Use .query() for read operations (GET-like); .mutation() for write operations (POST/PUT/DELETE-like)
  • Use .subscription() for real-time WebSocket-based data streams
  • Use middleware (.use()) for cross-cutting concerns: auth checks, logging, rate limiting
  • Use useSession() hook in Client Components for session data and status
  • Use getServerSession(authOptions) in getServerSideProps or API routes for server-side session checks
  • Use callbacks.jwt to enrich the JWT token with custom claims (role, userId)
  • Use callbacks.session to expose token data to the client session object
  • Use describe() to group related tests; it() or test() for individual cases
  • Use expect() assertions — prefer specific matchers (toEqual, toContain, toThrow) over generic toBeTruthy
  • Use vi.mock('module') at the top of the file to mock entire modules — it is hoisted automatically
  • Use vi.spyOn(object, 'method') to observe calls without replacing implementation
  • Use test.describe() to group related scenarios; test() for individual cases
  • Use test.beforeEach for common setup (navigation, auth state)
  • Prefer accessible locators in this order: page.getByRole() > page.getByText() > page.getByLabel() > page.getByTestId()
  • Never use CSS/XPath selectors for dynamic content — they break on refactors
  • Use extends for shared configs; overrides for file-specific rules
  • Never disable a rule without a justifying comment: // eslint-disable-next-line rule-name -- reason
  • Prefer configuring rules in the config file over scattering inline disables
  • Use error for rules that indicate bugs; warn for stylistic issues being adopted incrementally
  • Prettier handles all code formatting — do not manually format or argue about style
  • Use eslint-config-prettier to disable ESLint rules that conflict with Prettier
  • Never use eslint-plugin-prettier (runs Prettier as an ESLint rule) — it's slow; run them separately
  • Use vercel.json for redirects, rewrites, headers, and function configuration
  • Set environment variables in the Vercel dashboard (Settings > Environment Variables) — never hardcode secrets
  • Use different env var values per environment: Production, Preview, and Development
  • Use Edge Runtime (export const runtime = 'edge') for latency-sensitive API routes and middleware

Read the full file on GitHub · 48 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. yesterday First seen · 48 lines · 964 tokens per session scan A a26a958f6cf1

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository WhenLabs-org/when (3 stars, last pushed 8d ago), licensed MIT. It adds 964 tokens to every session, about $0.0048 per session on Opus 5. 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.