Skip to main content
rule CX Codex

one-component-per-file — Claude Code rule for React files

The one-component-per-file Claude Code rule keeps each React component in its own file. It applies to *.tsx files.

AGPL-3.0 ★ 1,120 updated 2026-11-16

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/one-component-per-file.mdc
Open on GitHub

What one-component-per-file does

The rule tells the agent to split React components that share a file, including small child components. Related components can stay together in one folder, while each gets a separate file.

For Claude Code, save the rule as .claude/rules/one-component-per-file.md. Its *.tsx glob targets TypeScript React files, and alwaysApply: false means the rule is not applied universally.

What it helps with

  • split several React components from one file
  • move a small child component into its own file
  • keep related component files in one folder

Example prompts for the agent

  • Split the React components in this file into separate files.
  • Move the scene card header and actions into their own components.
  • Check the *.tsx files and separate components declared together.

How to install one-component-per-file

Manually: put the files in place

.cursor/rules/one-component-per-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about one-component-per-file

How do I install one-component-per-file in Claude Code?

Create .claude/rules/one-component-per-file.md and add the rule there.

What does one-component-per-file do?

It requires each React component to have a separate file, including small child components.

Which files does one-component-per-file cover?

The rule targets files matching *.tsx.

Similar IDE rules

All IDE rules for Frontend and UI →
web-component-design Seth Hobson The web-component-design skill helps design reusable components for React, Vue, and Svelte. Use it for UI libraries, design systems, or legacy component refactors. CX Codex +1 13,167installs shadcn-component-boundaries purrfold shadcn-component-boundaries sets architectural boundaries for shadcn UI components. It prevents mixing product logic into registry primitives and enforces one-way imports. CX Codex +1 5,700installs react-component-generator OneWave-AI react-component-generator — a skill for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode that produces React components with typed props, hooks, and accessibility attributes. CX Codex +1 338installs react-component-architecture aj-geddes react-component-architecture — a skill that tells your coding agent how to structure React components: function components, hooks, composition and TypeScript. Useful once a shared component library starts growing. CX Codex +1 687installs component-template-generator curiositech component-template-generator is a Claude Code skill that creates React, Vue, and Svelte component templates using design tokens. It runs for component-library work and design-system implementation. CX Codex +1 139installs animated-component-libraries Claude Design Skillstack animated-component-libraries is a Claude Code plugin that helps choose ready-made animated React components from Magic UI and React Bits for interfaces where animations would otherwise be built by hand. ★ 1,428repo stars

From the same set25

The whole set →
server-actions This Claude Code rule guides the choice between Server Actions and API routes for reading or changing data. It applies when an agent writes server-side application logic. CX Codex +1 ★ 1,120repo stars input-label The input-label Claude Code rule sets how fields get their captions through the Input component. It applies to *.tsx files and disallows a separate caption above the field. CX Codex +1 ★ 1,120repo stars supabase-typed-mutations The supabase-typed-mutations Claude Code rule adds Database types to Supabase insert, update, and upsert calls. It applies while an agent works with these mutations. CX Codex +1 ★ 1,120repo stars use-shadcn This rule for Claude Code, Codex, and Cursor guides agents to reuse shadcn/ui components. When building UI, it directs them to look for existing project components first. CX Codex +1 ★ 1,120repo stars realtime This Claude Code rule sets the pattern for Supabase Realtime subscriptions. It directs component code to useRealtimeSubscription instead of calling supabase.channel() directly. CX Codex +1 ★ 1,120repo stars dialog-trigger-pattern The dialog-trigger-pattern Claude Code rule defines how dialog components receive their trigger. It applies to .tsx files. CX Codex +1 ★ 1,120repo stars ai-sdk This Claude Code rule covers structured data generation with the Vercel AI SDK. It applies to TypeScript and TSX files. CX Codex +1 ★ 1,120repo stars trigger.basic trigger.basic is a Claude Code rule for writing Trigger.dev tasks. It applies to TypeScript files matching **/trigger/**/*.ts. CX Codex +1 ★ 1,120repo stars

Project sponsors

Companies that keep this analytics open