agentleFS
sblueminsbluemin/fleet-harness/.claude/skills/clean-code/SKILL.md

clean-code

Skill17 starsChanged 3 days agoMITView on GitHub

Diagnose excessive file splitting, proxies, and duplicate logic in a named package, then perform approved structural consolidation and deduplication. Not for general bug fixes, feature development, or cosmetic formatting.

108 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use intelligent-routing, nextjs-react-expert and 10 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.
  • SKB3002Skill

    intelligent-routing

    Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.

    Also in 5 projects that use this

  • SKB3002Skill

    nextjs-react-expert

    React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.

    Also in 3 projects that use this

  • xfstudioSkill

    bash-pro

    Master of defensive Bash scripting for production automation, CI/CD

    Also in 4 projects that use this

  • xfstudioSkill

    code-refactoring-tech-debt

    You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti

    Also in 4 projects that use this

  • flying-diceSkill

    clean-code-review

    Multi-agent clean code audit — each principle gets its own agent

    Also in 3 projects that use this

  • goca-seSkill

    batch-operations

    Apply a change safely across many files — refactors touching more than 5 files, library or API migrations, project-wide renames of symbols/imports/paths, or adding boilerplate to many files. Use when "do it all at once" risks context overflow or silent failures.

    Also in 3 projects that use this

  • +4 more from xfstudio

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 101 edited versions we read keep these.

  • 2

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

    After approval, work from dependencies outward: relocate → update imports → remove absorbed files → verify.

    line 28
  2. Distinctive:

    Check the consolidated result against actual consumer paths:

    line 32
  3. Distinctive:

    Run each package script explicitly per wave:

    line 43

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

Clean Code

Simplify structure around domain boundaries while preserving behavior and public APIs. File/line reductions are supporting evidence, not the objective.

Inputs and approval scope

<target_path> is required; resolve it from the request. Confirm optional <public_surface> through declared package exports/barrels and actual external consumers. A diagnosis-only request ends at the report.

Present structural consolidation and functional deduplication diagnoses separately; implement only the approved scope. Do not ask again for an already-approved exact transformation. Return new API or behavioral trade-offs to the user.

1. Structural diagnosis and consolidation

Inventory target files/sizes and trace real dependencies and external consumers. Read merge candidates and affected consumers rather than requiring a ceremonial read of unrelated packages.

These are candidate signals, not automatic deletion rules:

  • Multiple tiny single-function/type files in one domain, duplicated types, simple re-export chains.
  • Factory-to-singleton-to-forwarding-proxy layers unused by runtime callers.
  • Module-level mutable state bypassing test isolation or explicit dependencies.

Present a domain-based before/after map, preserved exports, affected consumers, and checks. Files under roughly 50 lines or merges over 800 lines are investigation clues; do not remove barrels/boundaries solely by file count. Preserve create*(deps) test isolation and public export boundaries.

After approval, work from dependencies outward: relocate → update imports → remove absorbed files → verify. Up to two independent merge groups can form one batch; larger or intertwined changes use meaningful waves. Verify the current wave before continuing.

2. Functional deduplication

Check the consolidated result against actual consumer paths:

  • Does repeated logic have identical semantics, literal-only differences, or necessary caller-specific exceptions?
  • Does a reshape/forward wrapper own an API, permission, or lifecycle contract?
  • Can parallel types/builders share a discriminant without erasing domain meaning?
  • Is an apparently dead export public API or dynamically referenced?

Present the diagnosis, estimated savings, and preserved contracts; deduplicate only within approval. Place shared helpers at an allowed common dependency owner, never reaching back into hosts. Do not merge semantically different functions just to reduce lines.

Verification and completion

Run each package script explicitly per wave:

cd <absolute-worktree> && pnpm --filter <pkg> typecheck && pnpm --filter <pkg> test && pnpm --filter <pkg> build

Disclose missing scripts or blocked checks. Repair task-induced regressions and repeat verification.

Finish when approved consolidation/deduplication and relevant checks are complete. Do not expand into general refactoring. Report before/after, API preservation, changed files, checks/results (every count taken from output re-run after the last edit), and unverified scope. Deliver approved repository changes through pr-workflow under the root CLAUDE.md standing authorization, unless the request is local-only or otherwise narrows delivery.

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.