cursorrules

A set of code-style and project-structure rules for a TypeScript monorepo, meaning a repository that contains multiple related applications and packages. It covers naming, modular code, authentication, UI placement, database schemas, and server actions.

In plain words
What is it for?
It is for writing TypeScript, organizing UI components, adding authentication, defining database schemas with DrizzleORM, creating server actions, and generating or applying database migrations.
Why use it?
It gives contributors consistent conventions for where code belongs and how common full-stack tasks should be implemented. This reduces mismatched patterns across the project.

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/madarco/ragrabbit/cursorrules
Clone the repo
git clone --depth 1 https://github.com/madarco/ragrabbit

Made for: Cursor.

Per session 1,453 This file is loaded in full into every session.
When invoked 1,453 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.01453 $0.01453
Opus 5 $0.00727 $0.00727
Sonnet 5 $0.00291 $0.00291
Haiku 4.5 $0.00145 $0.00145

Measured yesterday against content hash a6ed2b85df43, 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.

.cursorrules · 168 lines

How it starts

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

Code Style and Structure:

  • Write concise, technical TypeScript code with accurate examples
  • Prefer iteration and modularization over code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)

Fullstack development:

  • The main app is saas/app
  • Use the packages/auth package for authentication, which exposes an auth function, eg: const session = await authOrLogin(); const email = session.user.email
  • Put the components for the UI in the packages/design package: put them in packages/design/components/section name/
  • Put the data schema in the packages/db package using DrizzleORM and PostgreSQL. The db can be acquired with import db from "@repo/db", the schema with import { usersTable } from "@repo/db/schema", the DrizzleOrm utilities with import { eq } from "@repo/db/drizzle"
  • When updating the db schema, run cd apps/saas && pnpm drizzle-kit generate to generate the new migrations while pnpm drizzle-kit migrate to apply them to the db.
  • For API routes prefer using Server Actions in the apps/saas app directly, inside the same folder as the page and route
  • For Server Actions, uses the this uses next-safe-action package and prefer using the authActionClient from the packages/actions package, eg: const result = await authActionClient.schema(mySchema).metadata({ name: "myAction" }).action(async ({ parsedInput, ctx }) => { ... });
  • Calling a Server Action from a page can be done directly eg: const { data: result } = await myAction({}); or const { executeAsync} = useAction(myAction); const { data } = await executeAsync();

Naming Conventions:

  • Use lowercase with dashes for directories (e.g., components/auth-wizard)
  • Favor named exports for components

TypeScript Usage:

  • Use TypeScript for all code; prefer interfaces over types
  • Avoid enums; use maps instead
  • Use functional components with TypeScript interfaces, eg export default function MyComponent({ myProp }: { myProp: string }) { ... }

Syntax and Formatting:

  • Use the "function" keyword for pure functions
  • Use declarative JSX

Error Handling and Validation:

  • Prioritize error handling: handle errors and edge cases early
  • Use early returns and guard clauses
  • Implement proper error logging and user-friendly messages
  • Use Zod for form validation (use z.coerce... with number values)
  • Model expected errors as return values in Server Actions
  • Use error boundaries for unexpected errors

UI and Styling:

  • Use Shadcn UI, Radix, and Tailwind Aria for components and styling
  • Implement responsive design with Tailwind CSS; use a mobile-first approach
  • Put the components for the UI in the @repo/design/ package
  • Use the cn function for tailwind classes from @repo/design/lib/utils
  • Use the import "@repo/design/..." always instead of @/, eg import { Button } from "@repo/design/shadcn/button"
  • To import design components, use the path: "@repo/design/components/...". For Shadcn components, use the path: "@repo/design/shadcn/..."
  • To add a missing Shadcn component, run cd packages/design && shadcn add ...
  • To import icons, use the path: "@repo/design/base/icons" this exposes lucide-react icons.
  • Always generate also a Storybook story for each component, put it next to the component file.
  • For Forms, use the EasyForm component from the @repo/design/components/form package.

An Example Storybook story:

import { Meta, StoryObj } from "@storybook/react";
import { Badge } from "../badge";

const meta: Meta<typeof Badge> = {
  title: "UI/Custom/Badge",
  component: Badge,
  argTypes: {
    variant: {
      control: "select",
      options: ["default", "primary", "secondary", "success", "warning", "danger"],
    },
  },
};

export default meta;
type Story = StoryObj<typeof Badge>;

export const Default: Story = {
  args: {
    children: "Default Badge",
  },
};

And example of an EasyForm:

const form = useForm<IndexFormValues>({
  resolver: zodResolver(addIndexSchema),
  defaultValues: { urls: [{ value: "" }] },
  mode: "onChange",
});

// Multi field array:
const urlsFieldArray = useFieldArray({
  name: "urls",
  control: form.control,
});

<EasyForm form={form} onSubmit={onSubmit} message="Form submitted successfully">
  <EasyFormFieldText
    form={form}
    name="name"
    title="Name"
    description="Please enter your full name"
    placeholder="John Doe"
  />
  <EasyFormFieldText
    form={form}
    name="email"
    title="Email"
    description="Enter your email address"
    placeholder="[email protected]"
  />
  <EasyFormMultiTextField
    form={form}
    field={field}
    name="multiField"
    title="Multi Field"
    description="This is a multi EasyFormFieldText component"
    placeholder="Enter some text"
  />
  <EasyFormFieldNumber form={form} field={field} name="multiField" title="Multi Field" />
  <EasyFormFieldSwitch form={form} name="switch" title="Switch" label="Switch Label" />
  <EasyFormSubmit form={form} isExecuting={false} />
</EasyForm>

Read the full file on GitHub · 168 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 · 168 lines · 1,453 tokens per session scan A a6ed2b85df43

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository madarco/ragrabbit (135 stars, last pushed 7mo ago), licensed MIT. It adds 1,453 tokens to every session, about $0.0073 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-30.