agentleFS
metratonmetraton/gaia/skills/code-standards/SKILL.md

code-standards

Skill4 starsChanged 4 months agoMITView on GitHub

Use when writing, modifying, reviewing, or refactoring code — any language or stack, application, infrastructure, or configuration. Also when asked to apply, audit, or clean up the code standards of a file or module.

  • Commits and pushes

17 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write code so that its behavior, responsibility, and intent can be understood from the implementation itself.

    line 21
  2. Distinctive:

    Before adding code, identify the responsibility being implemented and the existing pattern it belongs to.

    line 35
  3. Distinctive:

    Treat external input, configuration, network responses, persisted data, and other trust boundaries explicitly.

    line 74
  4. Distinctive:

    Default to no comment. Each one is optional and justified on its own: it earns its line only by carrying a fact the code cannot state — why …

    line 82
  5. Distinctive:

    When a file changes or is explicitly reviewed, reassess every comment in that file: each one must earn its line again, warrant correction, …

    line 95
  6. Distinctive:

    Keep interface contracts, licenses, and tool directives distinct from explanatory comments.

    line 110
  7. Distinctive:

    When reading existing code, use comments as navigation and historical context.

    line 115
  8. Distinctive:

    Never write a comment beside code on the same line.

    line 150
  9. Distinctive:

    When a declaration is long enough that its header leaves the target ambiguous, name the field — "retention_policy is deliberately unlocked: …

    line 154
  10. Distinctive:

    When behavior changes, verify the observable behavior rather than only the shape of the implementation.

    line 161
  11. Distinctive:

    Run only those tests locally, never a whole folder or suite.

    line 175

“Common” is measured: kept by at least 6 in 10 of the 14 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.

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

Code Standards

Code Standards governs how code is expressed — clarity, simplicity, safety, and maintainability — not which architectural pattern should exist. Use the applicable domain or pattern guidance to determine the design; use these standards to implement that design clearly and safely.

Load and apply this discipline before generating a change, then check the result against it as well as the behavioral checks before calling the change done. Ordinary coding includes coherent local improvement and verification, not an automatic multi-reviewer audit. For an explicitly requested review, use code-review to organize the examination; this skill remains the owner of the quality criteria.

Iron Law

Write code so that its behavior, responsibility, and intent can be understood from the implementation itself. Prefer code that explains itself over explanations surrounding unclear code.

Mental Model

A good implementation lets another engineer — or another agent — determine what assumptions it relies on and where to look when behavior must change. Clarity reduces the amount of inference required to safely modify the system.

Rules

1. Make responsibility visible

Before adding code, identify the responsibility being implemented and the existing pattern it belongs to; names, boundaries, and structure should reveal that responsibility. Follow the local pattern when one exists — it settles the form of what you write, never whether it was warranted, and matching what surrounds you is no evidence that what surrounds you earned its place. A new abstraction or pattern should exist because the problem requires it, not because the current implementation can be made more elaborate.

2. Prefer the simplest complete implementation

Implement the behavior required by the current problem. Additional abstractions, configuration, indirection, branches, or extensibility added for hypothetical future cases increase the number of assumptions a reader must understand and the number of places a future change can fail. Safety comes from making current assumptions and boundaries explicit, not from anticipating every possible implementation.

3. Make behavior explicit

Important behavior should be visible in code rather than hidden behind unexpected side effects, implicit state, or unrelated abstractions. Inputs, transformations, state changes, and failure paths should be traceable from the implementation.

4. Keep changes local

A change should touch the smallest coherent surface that correctly implements the behavior; a small blast radius makes it easier to reason about, verify, and revert. Include coupled declarations, callers, schemas, and tests when they must change together to preserve an invariant; the smallest diff is not necessarily coherent. Identify those dependencies before editing and verify the relationship afterwards.

A normal modification is not permission to restructure its neighbors. Reassess the touched file without treating existing debt as approved; fix within the agreed coherent surface and report unrelated debt separately. If correctness requires a wider scope, explain the dependency and obtain agreement before expanding. An explicit review examines its declared scope without editing; a transformation or refactor beyond the modification requires a separate assignment.

5. Protect boundaries

Treat external input, configuration, network responses, persisted data, and other trust boundaries explicitly. Validate where data enters a trusted part of the system rather than spreading defensive assumptions throughout the implementation. Sensitive values should not become source code, logs, error messages, or other persistent output.

6. A comment is the exception, not the default

Default to no comment. Each one is optional and justified on its own: it earns its line only by carrying a fact the code cannot state — why a non-obvious decision exists, an invariant that must hold, an external constraint, a compatibility requirement, a surprising consequence of changing the code. A comment that narrates the implementation carries no such fact and leaves a second description to drift from the first. One comment is not optional: the contract the caller reads, description or docstring, one sentence saying what the unit promises.

Size a comment to its facts, never to the size of what it heads: one fact rarely needs more than about two lines, and four chained facts are four entries in a dry list of about a line each. Neither figure is a count to satisfy — padding one fact to two lines and truncating a real chain to look short fail the same way.

When a file changes or is explicitly reviewed, reassess every comment in that file: each one must earn its line again, warrant correction, or warrant removal. Apply corrections only within the authorized modification; a read-only review reports them, and unrelated cleanup remains declared debt rather than a silent scope increase. Existing volume is not precedent — every comment already in the file faces the same justification as one written today. A pass that leaves a commented file carrying as much comment as it found owes an account of why each line survived, whatever route it took to get there.

Zero is valid where code carries the facts, and the limit is measured, not argued: over the diff against its merge-base, NET comment lines (added minus removed; #/// and docstring lines, tests included) may not exceed max(2, 2% of added code lines). One-line docstrings on public units are free; multi-line and private-unit ones count. Banners and comment blocks over two lines are refused at any count. Check with gaia lint comments; a git push over the limit is refused. A fact that no longer fits goes to the PR body. Keep interface contracts, licenses, and tool directives distinct from explanatory comments; do not delete their obligations to improve a count.

7. Comments are context, not evidence

When reading existing code, use comments as navigation and historical context. Verify claims about behavior against the implementation, tests, configuration, or other executable source of truth before relying on them. A stale comment should not override what the system actually does: treating it as truth makes an agent reason about behavior that no longer exists.

This is descriptive precedence: executable evidence establishes what happens, not what ought to happen. Requirements, safety constraints, and applicable standards govern the latter. Existing code or a passing test does not excuse a defect or poor practice; name the disagreement instead of turning observed behavior into a norm.

8. Route each fact to the declaration that owns it

Who reads a fact decides where it lives. A fact the caller needs goes in the slot that renders at the call site. Concepts, workflows, architecture, and usage spanning units belong in shared documentation, where one statement serves every file instead of drifting per-file copies. The turn's reasoning belongs in its report, not automatically in the artifact. Do not repeat a fact already expressed by an interface or data field.

A synchronization invariant can belong at the declaration that must preserve it, even when it names another unit. State what must remain aligned, why divergence is harmful, and the stable counterpart that must be checked when changing it; verify both sides and protect the relationship with a meaningful check where feasible. That is a maintenance obligation, not a claim that the other file currently behaves a certain way. A bare "keep in sync" or "see elsewhere" leaves the reader to recover the constraint and does not earn a line. Keep the rule in one owning place rather than copying implementations or scattering reciprocal explanations.

A fact only a maintainer needs belongs to the declaration whose constraint produces it, not to the line where the value happens to sit. Ask whose change would make it false: if changing how the resource iterates falsifies the comment, the fact is the resource's, and the map it consumes is merely where the value lives. The fact travels up to that declaration's header, and bodies — argument lists, value maps, local blocks — stay data a reader can scan with no prose in the way.

Never write a comment beside code on the same line. Whatever the column limit, the margin left over fits a fragment, and a fragment of a why is a description: the form manufactures the narration every other rule here exists to prevent.

When a declaration is long enough that its header leaves the target ambiguous, name the field — "retention_policy is deliberately unlocked: locking is irreversible." Naming a field of the declaration being read is a coordinate, not a pointer outward; reordering cannot break what does not depend on position.

9. Verify behavioral changes

When behavior changes, verify the observable behavior rather than only the shape of the implementation. Tests should protect meaningful behavior and invariants, especially where a future refactor could accidentally change them. Exercise relevant failure paths and boundaries, and assert externally meaningful outcomes or cross-file relationships. A test should fail for the regression it claims to prevent, not merely confirm an implementation string or echo its own fixture. For non-behavioral changes, show preservation of behavior rather than manufacturing tests for prose. State what ran, what it establishes, and what remains unverified; loading this skill or passing a linter is not evidence of its application.

How much to run, and when, follows five steps:

  1. Find the tests that exercise the change and read what they assert, before editing.
  2. Make the change.
  3. Run only those tests locally, never a whole folder or suite.
  4. Push; CI runs the whole suite.
  5. Collect every CI failure and fix them all in one round, re-running locally only the failing tests, then push again.

A change in a central path is done only when CI on the pushed branch is green. A verifier re-runs only the gates and probes the producer declared, never a wider run.

10. Write everything versioned in English

Identifiers, comments, docstrings, CHANGELOG entries, commit messages, pull request titles and bodies, and branch names are written in English. A concept a brief names in Spanish enters the code as its English term. A client project that declares another language wins.

Traps

TrapWhy it fails
Copying a nearby pattern without understanding its responsibilityStructural similarity can hide different assumptions and failure modes.

Anti-Patterns

Clever compression

Code minimizes lines at the cost of making state changes, conditions, or data transformations harder to see; behavior hidden behind convenience helpers makes the code shorter while the actual control flow becomes harder to trace. Optimize for understanding rather than line count.

Pointer without an obligation

"See above", "handled below", or a copied assertion about another module's current state can go stale without any reason to revisit the comment. Naming another unit is not itself the defect: making the reader reconstruct the relationship, or copying a fact owned elsewhere, is. Preserve a verified synchronization obligation under Rule 8; remove redundant navigation rather than deleting the invariant it obscures.

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.