0-folder-size — Claude Code rule: folder file limit
The 0-folder-size rule keeps directories from growing past ten direct .ts files. It also records why an oversized directory exists instead of encouraging file shuffling.
MIT ★ 571 updated 2026-10-29
.claude/rules/0-folder-size.mdWhat 0-folder-size does
The rule targets files under src/**/*.ts and sets a ceiling of ten direct .ts files in one directory. When a directory goes beyond that count, record its size and the reason it has grown.
Remove that record once the underlying defect is fixed. Do not move files merely to hit the number; the rule is meant to expose duplicated helpers and explain exceptions. For Claude Code, put the file at .claude/rules/0-folder-size.md.
What it helps with
- count direct
.tsfiles in each directory - record why a directory exceeds the limit
- spot directories where helpers may be duplicated
- remove an exception after the defect is fixed
- avoid reshuffling files to meet a threshold
Example prompts for the agent
- Review
src/**/*.tsagainst the0-folder-sizerule and list directories with more than ten direct.tsfiles. - For every oversized directory, record its file count and the reason for its size.
- Remove the directory entry after the defect that caused it has been fixed.
How to install 0-folder-size
Manually: put the files in place
.claude/rules/0-folder-size.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/0-folder-size.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/0-folder-size.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/0-folder-size.mdManually: put the files in place
.clinerules/0-folder-size.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about 0-folder-size
How do I install 0-folder-size in Claude Code?
Place the rule file at .claude/rules/0-folder-size.md.
What does 0-folder-size do?
It limits a directory to ten direct .ts files and asks for the count and reason when that limit is exceeded. It also rejects moving files solely to satisfy the threshold.
Which files does the 0-folder-size rule cover?
It applies to files matched by src/**/*.ts.
Source text
0-folder-size.md · MIT
--- description: Apply when a directory grows; ten direct source files is the limit. paths: - "src/**/*.ts" --- # Folder Size - Ten direct `.ts` files per directory (`folder-size.arch.test.ts`). - Past that, helpers get written twice. - Baseline an oversize directory with its count and reason. - An entry leaves when the defect is fixed. - Never shuffle files to satisfy a number.
© ai-driven-dev · MIT · ai-driven-dev/framework