agentleFS
rikvanrielrikvanriel/code-hygiene/skills/code-structure/SKILL.md

code-structure

Skill0 starsChanged 2 months agoMITView on GitHub

Use when a function is too long, nests too deep, or mixes themes. Extracts helpers that earn their names.

8 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use evidence-driven-testing, greploop-apps and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • kellykampenSkill

    evidence-driven-testing

    Records visual proof while testing UI behavior — screen recording with structured test/assertion annotations — then posts the video and a results summary to the PR and tracker issue. Use whenever a UI change needs verifiable evidence that it works, instead of prose claims.

    Also in 4 projects that use this

  • michaelshimelesSkill

    greploop-apps

    Iteratively improves a PR (GitHub), MR (GitLab), or shelved changelist (Perforce) until Greptile gives it a 5/5 confidence score with zero unresolved comments. Identical to greploop, but triggers reviews by tagging @greptile-apps, which bypasses Greptile's file-count limit on huge PRs that the plain @greptile mention refuses to review. Use when the user wants to fully optimize a large PR/MR/CL against Greptile's code review standards.

    Also in 3 projects that use this

  • VercelSkill

    before-and-after

    Add existing screenshots or screen recordings to a GitHub pull request as a before/after or preview block. Use when a PR needs visual media attached to its description. Browser navigation and capture belong to agent-browser.

    Also in 3 projects that use this

  • undeadlistSkill

    new-feature

    Develop new features with test-first approach (TDD)

    Also in 3 projects that use this

  • MicrosoftSkill

    unslop

    Cut AI tells from any writing. Must always apply.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If split introduced a dep chain, order: preparatory helper before patch that needs it, or split to separate commit with "No change in …

    line 21
  2. Distinctive:

    When a hunk unrelated to patch's purpose rides along, split it out: "this doesn't affect any functionality before nor after the core of …

    line 22
  3. Distinctive:

    If series grows a function across patches without anyone acting because "already long before this patch", that series still owns growth — …

    line 28
  4. Very specific:

    Prefer intent-revealing local name over generic tmp, ret2.

    line 41
  5. Very specific:

    Run: git log --oneline -- <file> | head -n 20 + grep same file for sister pattern.

    line 51

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

<!-- GC-40 --> Prefer minimal obvious fix. Do not duplicate to rename; rename is its own change when safe.

GC-41 — Extract by logical theme, helper has intent name

  • One helper = one theme. Name by what it means, not how it's implemented.
  • If split introduced a dep chain, order: preparatory helper before patch that needs it, or split to separate commit with "No change in behavior" or "Prepare for..." if upstream allows preparatory trailers.
  • When a hunk unrelated to patch's purpose rides along, split it out: "this doesn't affect any functionality before nor after the core of this patch" — separate commit.

GC-42 — Function length signal (not hard gate)

  • Aim: majority functions ≤20 lines. Hard smell: >40 lines → examine for extractable logical pieces.
  • Size alone doesn't reveal seam; look for: mechanical conversion vs behavioral change; moved unchanged vs rewritten; case already correct just needing result reported differently vs genuinely new algorithm; helper extracted vs its first caller.
  • If series grows a function across patches without anyone acting because "already long before this patch", that series still owns growth — extract at point of addition, not retrofit later (retrofit forces re-derivation of every later patch and introduces resolution errors).

GC-43 — Guard early return over goto-ladder, bare {} scoping

  • Flatten via early returns. Exception: real cleanup path that goto out; genuinely unifies — keep when saves duplication.
  • Bare {} blocks to limit scope → declare at function top instead, or extract helper.

GC-44 — Predicate bools should_ / is_ / has_ / can_ / needs_ / try_

static bool helper that only tests state (even with guard flag) should use should_/is_/etc, not action verbs like drain/claim/flush/schedule. Bad: bool flush_cache(), Good: bool should_flush_cache().

GC-45 — Locals naming, MIN macro over ternary

  • Prefer intent-revealing local name over generic tmp, ret2.
  • Clamp → use language's min/MIN/clamp macro or stdlib, not hand-rolled ternary. Avoids future bugs.

GC-46 — Ownership + caller clear, bool ownership intent explicit

  • Who allocates → who frees? If ownership transfers, comment at transfer point and at definition, not just at call site.
  • Functions that conditionally take ownership use name + bool/param that makes intent obvious, or separate try/ensure helpers.

GC-47 — When in doubt, check existing codebase style first

Run: git log --oneline -- <file> | head -n 20 + grep same file for sister pattern. Match whatever codebase already does over "textbook ideal".

GC-48 — One literal, one home

When the same list, path set, or magic value appears in two or more places, hoist it to a single named definition and reference it. Duplicated literals diverge silently — copies added to one site but not the others, with no gate complaining. Applies to data (paths, IDs, thresholds), not just logic; if two copies cannot share a definition, that is a seam worth naming, not an excuse for two copies.

Related — what belongs elsewhere

  • Security invariants in comment: see comment-quality GC-22.
  • Numbers/perf deltas: see factual-integrity.
  • Multi-file splitting and bisectable units: see change-splitting GC-30..GC-35.
  • Strict-project worked example: references/kernel-style-as-example.md.

Verification checklist

  • Every new function has one theme + intent name.
  • Bool helper is predicate-named (GC-44) or renamed in same commit.
  • No bare {} block unless justified.
  • Function >40 lines: seams named + reason to keep together if not split.
  • Early return flattened where possible, goto kept only when cleanup truly unified.
  • No hand-rolled a < b ? a : b.

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.