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
.cursor/rules/one-component-per-file.mdcWhat 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
*.tsxfiles and separate components declared together.
How to install one-component-per-file
Manually: put the files in place
.cursor/rules/one-component-per-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/one-component-per-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/one-component-per-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/one-component-per-file.mdManually: put the files in place
.clinerules/one-component-per-file.mdStep 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.