clean-code-law
Skill2 starsChanged 53 days agoMITView on GitHub
The Atelier Clean Code Law — 250-word-per-file budget, DRY via the graph, ponytail minimalism, and the comment policy. Load before writing or refactoring any source code.
In this repository28 other files it gives its agents.
- anime-jsSkill
- apple-designSkill
- asset-pipelineSkill
- atelier-bootstrapSkill
- atelier-buildSkill
- atelier-clarifySkill
- atelier-doctorSkill
- atelier-learnSkill
- atelier-planSkill
- atelier-promoteSkill
- atelier-reviewSkill
- atelier-shipSkill
- atelier-statusSkill
- atelier-updateSkill
- auth-lawSkill
- deploy-advisorSkill
- design-lawSkill
- docs-siteSkill
- gatewaySkill
- living-graphicsSkill
- loop-engineSkill
- mcp-makerSkill
- principal-mindSkill
- security-lawSkill
- stack-guidesSkill
- structure-lawSkill
- web-3dSkill
- web-qualitySkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
If a file resists splitting, the design is wrong — fix the design.
- Very specific: line 32
Before writing anything, check it doesn't already exist: code-review-graph (semantic_search_nodes) or repo search.
- Distinctive: line 47
If a class needs "and" to describe it, split it.
- Distinctive: line 53
Prefer plain functions over a class with one method.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clean Code Law
Small files, no repetition, no speculation. Any developer must be able to edit the codebase without going mad in thousand-line files.
The 250-word rule
- Budget: ≤250 words per source file (whitespace-separated tokens, code and comments). Hard cap: 350 when splitting would genuinely harm cohesion.
- Enforced by the
file-size-gatehook — an oversized write comes back to you with instructions; split before continuing. - Exempt: docs (
*.md), lockfiles, generated files, migrations, JSON/YAML data, vendored code. Config lives inrules(domaincode) and can be tuned. - Why: small files are readable, reviewable, independently testable, cheap for agents to load, and force real module boundaries.
How to split (in preference order)
- Extract pure helpers into a sibling module the file imports.
- Split by responsibility (parsing vs validation vs IO), never by line count.
- Component files: one component per file; hooks into
hooks/; variants into avariants.ts. - If a file resists splitting, the design is wrong — fix the design.
DRY (never repeat yourself)
Before writing anything, check it doesn't already exist: code-review-graph
(semantic_search_nodes) or repo search. If it exists, import it. If it almost
exists, extend it where it lives. A bug fix goes in the shared function all
callers route through — never patched per-caller.
Ponytail alignment (the ladder is law here too)
Does it need to exist? → reuse in-repo → stdlib → native platform → installed dep → one line → only then minimal new code. No interfaces with one implementation, no config for constants, no scaffolding "for later".
Classes & modules (one job each)
- Single responsibility: a class/service does one thing — a
UserServicefetches/mutates users, it doesn't also send emails or format API responses. If a class needs "and" to describe it, split it. - Dependency injection over globals: pass a db session/client into a constructor or function param — never import a singleton connection deep in business logic. Makes testing and swapping impls trivial.
- No god objects: a class that grows a new method for every feature is a design smell — extract collaborators instead of adding methods.
- Prefer plain functions over a class with one method; reach for a class only when you need to hold state across calls (a service with a shared client, a stateful parser) — ponytail applies to OOP too.
Comments
Premium and sparse: only constraints the code cannot show (invariants, gotchas,
external contracts, ponytail: ceiling notes). Never narrate what the next
line does. No dead code, no commented-out blocks.
Every non-trivial file leaves one check
A branch/loop/parser/money/security path ships with the smallest runnable check
that fails if the logic breaks (an assert self-check or one tiny test). No
frameworks unless the project already has one.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

