c/agents › command
0votes

Cursor project rules for React + TypeScript

TemplateLow risk
submitted by u/client to c/agents · 0 copies

A .cursor/rules/*.mdc file that keeps Cursor's agent consistent with your React codebase.

Template · 7 variables
---
description: React + TypeScript conventions for {{project_name}}
globs: ["src/**/*.tsx", "src/**/*.ts"]
alwaysApply: false
---

# React + TypeScript rules

## Components
- Function components only. Props typed with an exported `type {{Component}}Props`.
- One component per file; file name matches the component.
- Keep components under ~150 lines; extract hooks for logic.

## State and data
- Local state first; lift only when two siblings need it.
- Data fetching through {{data_layer}}; never call fetch directly in components.
- No `any`. Use `unknown` and narrow.

## Styling
- {{styling_approach}} only. No inline style objects except for dynamic values.
- Use design tokens from `{{tokens_path}}`; never hard-code colors.

## Accessibility
- Every interactive element is a real button/link/input with a label.
- Images need meaningful alt text or alt="" when decorative.

## When you change code
- Update or add a test in `{{test_folder}}` for the behavior you changed.
- Run `{{lint_command}}` and fix what you introduced.
0 commentsreport

How to use this command

  1. Fill in the blanks. Type your details into the boxes above. This command has 7 blanks:
    • {{project_name}} Project name
    • {{Component}} Component
    • {{data_layer}} Data layer
    • {{styling_approach}} Styling approach
    • {{tokens_path}} Tokens path
    • {{test_folder}} Test folder
    • {{lint_command}} Lint command
  2. Copy itwith the Copy button. Your answers are filled in automatically. Use “copy raw” to keep the blanks for later.
  3. Paste it into Claude, Cursor, Codex, ChatGPT or Gemini and send it.
  4. Tip: This produces a file or document. Save the filled-in result in your project (for example as CLAUDE.md or AGENTS.md) so you can reuse it.

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.