agentleFS
jinhuang712jinhuang712/claude-code-broom/skills/clean/SKILL.md

clean

Skill0 starsChanged yesterdayMITView on GitHub

Clean up the code smells broom finds across a repo or an area - long functions, files and types, high complexity, deep nesting, duplicate and dead code, magic numbers and the like - worst first, in small verified batches. Use for /broom:clean, when broom's session note reports smells and the user agrees to a cleanup, when the user asks to clean up, refactor or pay down tech debt, or before reworking an area that `broom smells` ranks as a hotspot.

21 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use expressive, friendly 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.
  • bergsideSkill

    expressive

    Vibrant, personality-driven design with bold colors, playful graphics, and dynamic layouts that balance creativity with structure.

    Also in 4 projects that use this

  • bergsideSkill

    friendly

    Approachable, intuitive design with rounded elements, ample whitespace, and soft pastel color palettes.

    Also in 4 projects that use this

  • +10 more from bergside

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep behavior. Run the project's tests before and after.

    line 28
  2. Very specific:

    Run broom smells on the same scope again: the batch's smells are gone and nothing new is past a limit.

    line 58
  3. Very specific:

    Stop when the scope is clean, the user says so, or after the batches they agreed to.

    line 63
  4. Very specific:

    If the user doesn't want a cleanup now, run broom smells --dismiss: the session note stays quiet until the repo's count of smells past the …

    line 66

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

1. Rank

broom smells [paths] --top 10

It lists the hotspot files (most smells past the hard limit first) and the worst smells (furthest past their limit first), --top of each, and says how many more there are. Add --json to read it as data. With no paths it covers the repo; with paths, only those.

Pick the scope with the user: an area (src/layout), a file, or a kind of smell ("the long functions", "dead code"). When the request already names it, use that.

2. Plan

Propose batches, worst first: one file, or one kind of smell in a few files, per batch. Say for each what changes: extract functions, split a file, name constants, delete dead code, merge duplicates. Wait for the user's go-ahead unless they already asked for the cleanup itself.

3. Clean one batch

  • Keep behavior. Run the project's tests before and after; a failing test stops the batch. If some tests fail before you start, note which and compare by name: only a new failure stops a batch.
  • Refactor the smell away, not the metric: no splitting a function at an arbitrary line, no smells_off to silence something fixable.
  • A smell that is deliberate (a long lookup table, a protocol's fixed parameter list, code loaded dynamically) stays: say so, and offer .broom.json exclude, limits (test_limits for tests that are long because they list cases), legacy (code a migration is replacing) or smells_off instead of contorting the code.

How each kind is usually put right:

SmellThe fix
function_lines, complexity, nestingExtract the steps the function takes into functions named for what they do; return early to flatten
file_lines, type_linesSplit by area, not by size. Move what the parts share into a module of its own first, so they don't import one another
params, bool_paramsGroup related parameters in one object; make a flag keyword-only (*, flag in Python) or an enum
unused_paramsRemove it and the callers' argument. Where a shared signature fixes it (a callback table, a command handler), name it _name
magic_numbersA named constant that says what the number means, with its unit
nested_ternaryPlain if statements, or early returns
duplicate_linesExtract the shared block; where the copies differ, a function with a parameter for the difference
dead_code, commented_codeDelete it; git keeps it
import_cycleMove what the files share into a third module both import. An import inside a function is the last resort
globalsPass the state in, or hold it in an object
debug_outputDelete it, or use the project's logger
type_escapeNarrow the type with a check instead of casting or unwrapping
suppression, swallowed_errorGive the suppression its rule and a reason; handle or log the error
todoDo it, or write it down as an issue and drop the comment
broad_test_assertsAssert on the message or the exact error

4. Check and commit

Run broom smells on the same scope again: the batch's smells are gone and nothing new is past a limit. Commit the batch on its own (broom checks the commit as usual), then go on to the next batch.

5. Stop

Stop when the scope is clean, the user says so, or after the batches they agreed to. Report what is left with the counts from broom smells.

If the user doesn't want a cleanup now, run broom smells --dismiss: the session note stays quiet until the repo's count of smells past the hard limit grows.

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.