agentleFS
kennguyen887kennguyen887/agent-foundation/skills/rules-code-style/SKILL.md

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.

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
  1. Very specific:

    Prefer map/filter/reduce/find/some/every/flatMap.

    line 13
  2. Distinctive:

    Before new persistent state or logic layer, reuse an existing field/mechanism (self-healing diffs, existing timestamps, one-off script).

    line 19

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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...of for side effects or sequenced awaits (never forEach + 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; no any on 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.