dafthunk / rules
Cursor rule133 starsChanged 9 months agoMITView on GitHub
Coding standards, naming, testing & style rules
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/00-persona.mdcCursor rule
- .cursor/rules/01-software-design-guidelines.mdcCursor rule
- .cursor/rules/02-development-environment.mdcCursor rule
- .cursor/rules/03-project-structure.mdcCursor rule
- .cursor/rules/05-web-development.mdcCursor rule
- .cursor/rules/06-api-development.mdcCursor rule
- .cursor/rules/07-database-development.mdcCursor rule
- .cursor/rules/08-web-routes.mdcCursor rule
- integration-generatorSkill
- node-generatorSkill
- template-generatorSkill
The file
We split this 04-code-implementation-guidelines.mdc into the rules it gives an agent
11 rules. About 0 are common, 7 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Write correct, DRY, bug-free code — leave no TODOs.
- Distinctive: line 10
Prefer functional components and hooks.
- Distinctive: line 11
Use early returns to reduce nesting.
- Very specific: line 15
Use strict TypeScript: avoid any, unknown, and implicit any.
- Very specific: line 16
Prefer interface over type aliases, unless a type cannot be expressed with an interface.
- Very specific: line 24
Use utility types like Partial, Pick, Omit thoughtfully to improve clarity and type safety.
- Distinctive: line 27
Use Tailwind CSS exclusively — do not use external CSS or styled-components.
- Very specific: line 28
Use the cn utility from @/utils/utils for conditional class names.
- Distinctive: line 29
Avoid ternaries in className strings.
- Distinctive: line 37
Write tests using Vitest.
- Distinctive: line 55
Use headers or tokens to communicate user context, not prior API calls.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- description: Coding standards, naming, testing & style rules globs: alwaysApply: true --- # Development Guidelines ## General - Write **correct, DRY, bug-free** code — leave **no TODOs**. - Prefer **functional components** and **hooks**; use **TypeScript** types/interfaces consistently. - Use **early returns** to reduce nesting. - Choose **descriptive names** for variables, functions, and components. ## Typing - Use **strict TypeScript**: avoid `any`, `unknown`, and implicit `any`. - Prefer `interface` over `type` aliases, unless a type cannot be expressed with an interface. - Always type: - Props - State - Event handlers - Returned values - Favor **`readonly`** and **`as const`** assertions for immutability and safety. - Narrow types when possible (e.g., `'small' | 'medium' | 'large'` instead of `string`). - Use utility types like `Partial`, `Pick`, `Omit` thoughtfully to improve clarity and type safety. ## Styling - Use **Tailwind CSS** exclusively — do not use external CSS or styled-components. - Use the `cn` utility from `@/utils/utils` for conditional class names. - Avoid ternaries in className strings. ## Naming Conventions - **kebab-case** for file names (e.g., `my-component.tsx`). - **camelCase** for hooks and utility functions (e.g., `useMyHook`, `formatDate`). - Prefix event handlers with `handle` (e.g., `handleSubmit`, `handleClick`). ## Testing & QA - Write tests using **Vitest**. - Cover critical paths, edge cases, and user-facing logic. - Provide fallback UI and error boundaries where appropriate. ## REST API Best Practices ### Shared Types - Define shared types in: `packages/types/src/index.ts` - Use them: - To serialize data in API routes (backend). - To deserialize and validate data on the frontend. - This ensures **type safety and consistency** across backend and frontend. ### Statelessness - REST APIs must be **stateless**: - Each request must be self-contained. - The server must not depend on in-memory or session state. - Clients manage session (e.g., cookies, auth headers, tokens). - Use headers or tokens to communicate user context, not prior API calls. #### Benefits - Enables better scalability and server independence. - Reduces bugs and improves debuggability by avoiding implicit state.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

