rules-code-style
Skill1 starsChanged 5 months agoMITView on GitHub
Binding personal rules for writing or refactoring code — load before writing handlers/helpers/async code, adding a helper, new state or a layer (KISS, reuse-first, pre-write gate), or reviewing code for anti-patterns.
In this repository40 other files it gives its agents.
- authoring-project-skillsSkill
- background-jobs-and-cachingSkill
- code-conventionsSkill
- containerize-and-ship-a-serviceSkill
- database-migrationsSkill
- design-an-error-modelSkill
- git-flowSkill
- handle-files-frontendSkill
- import-data-from-csvSkill
- integrate-external-servicesSkill
- integrate-identity-providersSkill
- integrate-internal-servicesSkill
- keep-service-memory-leanSkill
- operate-ecs-services-safelySkill
- prevent-secret-and-pii-leaksSkill
- release-safetySkill
- render-transactional-emailsSkill
- rules-backendSkill
- rules-debuggingSkill
- rules-gitSkill
- rules-infraSkill
- rules-pr-reviewSkill
- rules-shippingSkill
- rules-workflowSkill
- schedule-effective-dated-changesSkill
- secure-a-frontend-appSkill
- security-auditSkill
- send-slackSkill
- serve-realtime-with-websocketsSkill
- structure-a-backend-serviceSkill
- structure-a-frontend-appSkill
- structure-a-shared-backend-libSkill
- structure-a-shared-ui-libSkill
- tdd-http-firstSkill
- use-feature-flagsSkill
- write-cross-cutting-codeSkill
- write-frontend-codeSkill
- write-frontend-testsSkill
- write-service-codeSkill
- write-unit-testsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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
- Very specific: line 13
Prefer map/filter/reduce/find/some/every/flatMap.
- Distinctive: line 19
Before new persistent state or logic layer, reuse an existing field/mechanism (self-healing diffs, existing timestamps, one-off script).
≈ “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
rules-code-style
These rules are binding (moved verbatim from ~/.claude/CLAUDE.md). Each heading names its full-text file in ~/.claude/rulebook/: Read that file before acting in its area — the one-liners are the trigger, not the whole rule.
Code Style — 14-…, 15-…, 16-…, 17-…
- Handlers read in one screenful; split 3+ concerns into verb-led single-purpose private helpers; ≤2 nesting levels; extract inline try/catch branches; refactors preserve behaviour exactly.
- DRY parallel flows: extract a config-driven shared helper before shipping the second copy; grep siblings/open PRs first; listener factories; repeated parse snippets (3+) → util.
- Prefer
map/filter/reduce/find/some/every/flatMap;for...offor side effects or sequenced awaits (neverforEach+ async); pure callbacks; name intermediate stages. - Independent awaits →
Promise.all(comment when order matters non-obviously); skip calls whose result a branch discards; moved/ported code gets no exemption; self-check the diff for consecutive awaits before commit.
KISS / STOP-BEFORE-WRITING / Lean Design — 24-…, 25-…, 26-…
- Smallest change that fully solves the actual problem; size to severity both ways; no permanent tax for rare problems; YAGNI; layer/scope is co-owned with the user. Applies to this rulebook too.
- Pre-write gate for any non-business-logic helper: name the problem generically → a library exists; check the tree (often a transitive dep); search the problem domain; state the package used or why none fits. Helper crossing ~40 lines / extra error branch / custom timeout / retry loop → stop and re-search. Measure the perf trade-off; cheap deterministic check first.
- Before new persistent state or logic layer, reuse an existing field/mechanism (self-healing diffs, existing timestamps, one-off script); weigh permanence vs frequency; ship the smaller thing.
Anti-patterns — 27-anti-patterns-to-avoid.md
- No
NODE_ENV === 'production'business gating (use flags/config); no assuming third parties are up; noanyon config/DTOs from external data; new integrations get a config key with staging-safe default; never swallow errors silently (+ Sentry for money/contract/sync); no per-request state in module scope/static fields.
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.

