# one-component-per-file

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

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1120 repo stars
- Author: rerun-build
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/one-component-per-file.mdc
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/one-component-per-file

## What it 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.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/one-component-per-file.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/one-component-per-file.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/one-component-per-file.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/one-component-per-file.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/one-component-per-file.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/one-component-per-file.mdc

## When to use it
- 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
- 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.

## Similar
- [web-component-design](https://affpapa.org/en/nevibecode/skills/web-component-design.md) — skill · 13167 installs
- [shadcn-component-boundaries](https://affpapa.org/en/nevibecode/skills/shadcn-component-boundaries.md) — skill · 5700 installs
- [react-component-generator](https://affpapa.org/en/nevibecode/skills/react-component-generator.md) — skill · 338 installs
- [react-component-architecture](https://affpapa.org/en/nevibecode/skills/react-component-architecture.md) — skill · 687 installs
- [component-template-generator](https://affpapa.org/en/nevibecode/skills/component-template-generator.md) — skill · 139 installs
- [animated-component-libraries](https://affpapa.org/en/nevibecode/plugins/animated-component-libraries.md) — plugin · ★ 1428 repo stars

From the same set: [rerun-build/rerun](https://affpapa.org/en/nevibecode/by/rerun-build/rerun.md) — 25 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
