with one click
cursor-usage
How to write and manage Cursor rules - invoke with @cursor-usage
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
How to write and manage Cursor rules - invoke with @cursor-usage
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | cursor-usage |
| description | How to write and manage Cursor rules - invoke with @cursor-usage |
Source Cursor rule: .cursor/rules/cursor-usage.mdc.
Original file scope: .cursor/rules/*.mdc.
Original Cursor alwaysApply: false.
Cursor rules provide system-level instructions to the AI to maintain code consistency, quality, and adherence to project standards. They are stored in the .cursor/rules/ directory as .mdc (Markdown with frontmatter) files.
Each .mdc rule file consists of two parts:
---
description: Brief overview of what this rule enforces
globs: **/*.{ts,tsx}
alwaysApply: true
---
Frontmatter Fields:
description: A clear, concise explanation of the rule's purposeglobs: Glob pattern to match files where this rule should apply (plain string, no quotes or arrays)
**/*.tsx - All TSX files**/*.{ts,tsx} - All TS and TSX filesapps/*/components/**/*.tsx - All TSX files in any app's components directory**/trigger/**/*.ts - All TS files in trigger directoriesalwaysApply: Boolean indicating if the rule should always be active
true: Rule is always active when working on matching filesfalse: Rule can be selectively invoked with @rule-nameThe body of the rule file contains the actual guidelines, examples, and instructions written in Markdown format.
Rules with alwaysApply: true are automatically loaded when:
globs patternYou can reference specific rules in your prompts:
@design-system create a new button component
This explicitly tells Cursor to apply the design-system rule.
Always include:
// ✅ Good: Use semantic tokens
<div className="bg-background text-foreground">Content</div>
// ❌ Bad: Hardcoded colors
<div className="bg-white text-black">Content</div>
Organize content with descriptive headers:
## Core Principles
## Rules
## Examples
## Exceptions
## Common Mistakes
If there are cases where rules don't apply, state them clearly:
## Exceptions
The ONLY time you can pass className to a design system component is for:
1. Width utilities: `w-full`, `max-w-md`
2. Responsive display: `hidden`, `md:block`
Provide actionable checklists for validation:
## Code Review Checklist
Before committing:
- [ ] Uses semantic color tokens
- [ ] Works in both light and dark mode
- [ ] Fully responsive
.mdc file in .cursor/rules/.mdc fileRecommended structure:
.cursor/rules/
├── design-system.mdc # Component usage, variants, composition
├── code-standards.mdc # General code quality rules
├── typescript-rules.mdc # TypeScript type safety
├── react-code.mdc # React patterns and conventions
├── data-fetching.mdc # Server/client data patterns
└── cursor-usage.mdc # This file - how to use rules
# All TypeScript/TSX files
globs: **/*.{ts,tsx}
# Only TSX files (React components)
globs: **/*.tsx
# Only trigger task files
globs: **/trigger/**/*.ts
# Prisma schema files
globs: **/*.prisma
# All JSON and TypeScript files
globs: **/*.{ts,tsx,json}
** for recursive directory matching* for single-level wildcard{ts,tsx} for multiple extensionsglobs pattern matches your filealwaysApply is set appropriately@ruleNameglobsUse alwaysApply: false for rules that should only apply in specific contexts:
---
description: Performance optimization guidelines
globs: **/*.ts
alwaysApply: false
---
Invoke with: @performance-optimization refactor this component
More specific globs take precedence:
design-system.mdc with globs: **/*.tsx (broad)trigger.basic.mdc with globs: **/trigger/**/*.ts (specific)The specific rule will have more weight for trigger files.
touch .cursor/rules/my-new-rule.mdc
---
description: What this rule enforces
globs: **/*.{ts,tsx}
alwaysApply: true
---
# Rule Title
## Guidelines
- Point 1
- Point 2
globs pattern@my-new-rule in your promptglobs patternRemember: Rules are here to help, not hinder. If a rule doesn't make sense for a specific case, discuss with the team and update the rule accordingly.
How to reuse ANY integration check's results in a feature via the universal CheckResultsService (apps/api integration-platform). Use whenever a feature needs data produced by an integration check — "show 2FA status on People", "surface AWS S3 findings in X", "reuse a check's results", "per-user/per-resource results from a connected integration", "which integrations feed task T". Read this BEFORE writing your own IntegrationCheckResult / CheckRunRepository query — don't hand-roll it.
MANDATORY for any UI work in apps/app, apps/portal, or packages/design-system — every component, page, or layout change must work on mobile (~375px), tablet (~768px), desktop (~1280px), and large desktop (~1920px) BY DEFAULT, without being asked. Read this before writing or editing any JSX/TSX that renders visible UI. Triggers on: new component, page, layout, table, toolbar, form, modal/sheet, dashboard, "build UI", "add a column", "add a filter", any styling change.
Use when building or editing frontend UI components, layouts, styling, design system usage, colors, dark mode, or icons.
The contract every new or modified API endpoint must follow so it is correct for the public OpenAPI spec, the MCP server (npm @trycompai/mcp-server), the ValidationPipe, and the docs. Triggers on "new endpoint", "add API", "new DTO", "@Body", "@RequirePermission", "MCP tool", "edit controller in apps/api", "OpenAPI", or whenever editing controllers under apps/api/src/.
Use when SDK generation failed or seeing errors. Triggers on "generation failed", "speakeasy run failed", "SDK build error", "workflow failed", "Step Failed", "why did generation fail"
Use when generating an MCP server from an OpenAPI spec with Speakeasy. Triggers on "generate MCP server", "MCP server", "Model Context Protocol", "AI assistant tools", "Claude tools", "speakeasy MCP", "mcp-typescript"