code-rules
Skill1 starsChanged 24 days agoMITView on GitHub
General rules for writing production code in any project: conventions, reuse, structure, comments, scope, errors, tests. Use when implementing or changing code, and when judging whether written code follows them.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- zedarvates/frugal-skillstheir own version, first seen Nov 8, 2026
- LNSD/lorecrafttheir own version, first seen Oct 27, 2026
- FrankieeW/agent-skillstheir own version, first seen Mar 19, 2026
- claude-office-skills/claude-office-plugintheir own version, first seen Mar 9, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- claude-office-skills/claude-office-plugin★ 9same name
- zedarvates/frugal-skills★ 1same name
- FrankieeW/agent-skills★ 0same name
- LNSD/lorecraft★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 10 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
10
Distinctive
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 10
When sources disagree, the higher one wins:
- Distinctive: line 25
When you see a better way than the project's, build it the project's way and put the alternative in your report as a suggestion, with what …
- Distinctive: line 30
Write new code the way the surrounding code is written: naming, file layout, syntax, error handling, test style.
- Distinctive: line 32
Use the project's formatter and linter settings.
- Distinctive: line 36
Search before writing: an existing helper, component, service, query or type that does the job is used or extended, not duplicated.
- Distinctive: line 37
When you extend something shared, check its other callers still work.
- Distinctive: line 47
Write the simplest code that meets the acceptance criteria: clear names, early returns, no flags or options nobody asked for.
- Very specific: line 48
Leave no dead code, commented-out code or debug output (console.log, dd(), var_dump, print).
- Distinctive: line 49
Add a dependency only when the plan includes it.
- Distinctive: line 61
Leave version control to the developer: no commits, branches, stashes or pushes.
- Distinctive: line 70
Test behaviour through the public interface, derived from the acceptance criteria.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code rules
Priority
When sources disagree, the higher one wins:
- What the developer said for this task, and the approved plan.
- The project's written rules:
CLAUDE.md,AGENTS.md,docs/, ADRs,REVIEW.md. - The project's existing code: its architecture, conventions and syntax.
- These rules and the
fe-rules/be-rulesthat add to them. - The best practices of the language and framework in use.
Applying the rules
Apply a rule where its subject exists in the task; the rest do not apply.
Architecture
- Build inside the project's architecture: its layers, module boundaries, patterns and data flow. A new feature looks like the features already there.
- When you see a better way than the project's, build it the project's way and put the alternative in your report as a suggestion, with what it would buy.
- In a new project, the architecture comes from the approved plan.
Conventions
- Write new code the way the surrounding code is written: naming, file layout, syntax, error handling, test style. Before writing a new kind of file, read two or three existing files that do the same job and match them.
- Where the project is silent, follow the idioms and best practices of the language and framework (their standard library, error handling and type conventions).
- Use the project's formatter and linter settings; leave formatting of lines you did not change as it is.
Reuse
- Search before writing: an existing helper, component, service, query or type that does the job is used or extended, not duplicated.
- When you extend something shared, check its other callers still work.
Structure
- Split by responsibility, not by length: one unit does one job. Split a unit when it does two jobs; keep it whole when it does one, even if it is long.
- A reader understands a unit without jumping through more than a couple of files. Thin wrappers and one-line indirections that add a file without adding meaning are folded back in.
- An abstraction earns its place with a second real use or a clearly separate responsibility, never "for later".
Simplicity
- Write the simplest code that meets the acceptance criteria: clear names, early returns, no flags or options nobody asked for.
- Leave no dead code, commented-out code or debug output (
console.log,dd(),var_dump,print). - Add a dependency only when the plan includes it.
Comments
- Comment the why that the code cannot say: a constraint, a workaround and its reason, an invariant, a non-obvious consequence. One or two lines.
- Let names and structure say what the code does; a comment that narrates the code is deleted.
- Changes and their history belong to version control, not to comments.
Scope
- Change what the plan or the task asks for, and what that change requires (a caller that must follow a new signature, a spec that must match a new response).
- Anything outside that scope you think should change (a bug you noticed, a cleanup, a better structure) goes to your report as a suggestion with its reason. It is never changed without the developer's approval.
- Leave version control to the developer: no commits, branches, stashes or pushes.
Errors
- Validate and handle errors at system boundaries: user input, requests, files, network, external services. Trust internal code and framework guarantees.
- Fail loudly with context; an error is never swallowed or turned into a silent default.
Tests
- Test behaviour through the public interface, derived from the acceptance criteria. Follow the project's test conventions and location.
- A new test fails before the change and passes after it; run it red first when the change makes that feasible.
- Mock only at boundaries the project already mocks (network, time, external services), never the unit under test.
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.

