agentleFS
dafthunk-comdafthunk-com/dafthunk/.cursor/rules/04-code-implementation-guidelines.mdc

dafthunk / rules

Cursor rule133 starsChanged 9 months agoMITView on GitHub

Coding standards, naming, testing & style rules

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
  1. Distinctive:

    Write correct, DRY, bug-free code — leave no TODOs.

    line 9
  2. Distinctive:

    Prefer functional components and hooks.

    line 10
  3. Distinctive:

    Use early returns to reduce nesting.

    line 11
  4. Very specific:

    Use strict TypeScript: avoid any, unknown, and implicit any.

    line 15
  5. Very specific:

    Prefer interface over type aliases, unless a type cannot be expressed with an interface.

    line 16
  6. Very specific:

    Use utility types like Partial, Pick, Omit thoughtfully to improve clarity and type safety.

    line 24
  7. Distinctive:

    Use Tailwind CSS exclusively — do not use external CSS or styled-components.

    line 27
  8. Very specific:

    Use the cn utility from @/utils/utils for conditional class names.

    line 28
  9. Distinctive:

    Avoid ternaries in className strings.

    line 29
  10. Distinctive:

    Write tests using Vitest.

    line 37
  11. Distinctive:

    Use headers or tokens to communicate user context, not prior API calls.

    line 55

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
04-code-implementation-guidelines.mdc
---
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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.