From agents-library
Survey a target — the whole repository, a path/glob, or the current branch diff — for behavior-preserving simplification opportunities, then optionally apply them. Orients on the project (AGENTS.md, README, conventions), builds and shards a scan surface, fans out parallel sub-agents across four simplification lenses (redundancy & dead code, complexity & structure, clarity & idiom, docs), consolidates and ranks their findings, presents them for you to pick from, and then either applies a chosen subset or runs an autonomous improve-until-converged loop — every applied fix gated on the project's lint and tests and behavior-preserving by construction. Use this whenever the user wants to simplify the codebase, find code or docs that can be simplified, reduce complexity, declutter or tidy a repo, find duplication / dead code / over-engineering, or survey the whole project (not just a diff) for cleanup opportunities — even if they don't say the word "skill". Works on the local branch; no `gh` or remote required.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agents-library:simplify-sweepThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are the **orchestrator** of a simplification survey. The user wants to find
You are the orchestrator of a simplification survey. The user wants to find code and docs that can be made simpler — across a target they choose: the whole repository, a path or glob, or the current branch diff. Your job is to orient on the project, build and shard a scan surface, fan out specialized sub-agents across four simplification lenses, consolidate what they find, and help the user act on it behind a lint/test gate.
Two properties frame everything below:
gh, no remote required.A single reader skimming a whole codebase for "things to simplify" misses most of it, because "is this duplicated?", "is this too nested?", "is this name clear?", and "is this doc stale?" are different mental modes that compete for attention. Focused sub-agents, each holding exactly one lens over a bounded shard of files, find more and find it more sharply. You then merge their findings into one ranked list so the user sees signal, not a pile of reports.
The sub-agents only analyze — they never edit. Implementation happens later, under your control, behind a lint/test gate. Keeping analysis separate from action is what makes the findings trustworthy and the applied changes safe.
Build an accurate map of the project, gathered once and bundled into every sub-agent so they don't each re-derive it.
AGENTS.md, README, CLAUDE.md,
CONTRIBUTING, and architecture notes. Capture the layering, conventions,
code-style bars, commit format, and confidence-indicator rules verbatim — the
clarity/idiom and docs lenses are judged against exactly these.main — detect it
(git symbolic-ref refs/remotes/origin/HEAD, or fall back to whichever of
main/master exists). Call it <main>.--diff → the current branch diff
(git diff <main>...HEAD) plus working-tree changes (git diff,
git status)
If it's ambiguous which they meant, ask before scanning.This is what lets the survey scale to a whole repository instead of a small diff.
.gitignore
and skip the usual non-source directories (node_modules, dist, build,
vendor, etc.).4 lenses × shards) stays at or under ~24. If the surface is larger than
that allows, cap it and report what was left out — never truncate
silently. For a --diff target the surface is usually small (one shard).If the target is empty after filtering, say there's nothing to scan and stop.
Dispatch one sub-agent per (lens, shard) pair, all in parallel — issue the
Agent/Task calls in a single message so they run concurrently (the
superpowers:dispatching-parallel-agents pattern). If the pair count is large,
dispatch in batches to respect the concurrency limit.
Each sub-agent's prompt is assembled from three parts:
domains/ and
include it verbatim — plus this agent's shard file list.The four lenses and their files:
| Lens | Emoji | File | Looks for |
|---|---|---|---|
| Redundancy & dead code | 🌲 | domains/redundancy-deadcode.md | Duplicated logic extractable to a helper; unused/unreachable code; redundant boolean logic. |
| Complexity & structure | 🔧 | domains/complexity-structure.md | Deep nesting → early returns; long mixed-responsibility functions; needless indirection / over-abstraction. |
| Clarity & idiom | ✨ | domains/clarity-idiom.md | Vague names; verbose constructs with a simpler idiom; over-broad/redundant types. |
| Docs simplification | 📝 | domains/docs.md | Duplicate docs; docs drifted from code; over-long prose; comments made redundant by clear code. |
If a sub-agent fails or returns nothing, note it and continue with the others — never block the whole survey on one shard or lens.
Merge all findings into one list:
<lens>-<n> (e.g. redundancy-1, docs-2).Render a grouped, ID'd list to the user, one finding per line:
[redundancy-1] 🟡 redundancy · src/auth.ts:40 — token-decode block duplicated in
session.ts:88 — extract a decodeToken() helper — small
Then summarize: how many findings at each severity, which lenses were quiet, and the surface stats from Phase 1 — files scanned, shard count, and anything skipped or capped. Keep it skimmable; the user is choosing what to act on, not reading four reports.
Ask the user to choose one path:
For each accepted finding, in order:
<type>(<scope>): <subject>, e.g. refactor(auth): …,
docs(readme): …), scoped to the finding's lens.Docs-only findings still run the gate (docs build/lint if the project has one); behavior preservation is trivial for them. If you couldn't find the lint/test commands in Phase 0, ask the user whether to proceed without the gate — don't silently skip verification.
Each sub-agent emits findings as records with these fields:
id: <lens>-<n> e.g. redundancy-1
severity: critical | important | nice-to-have (🔴 | 🟡 | 🟢)
lens: redundancy | complexity | clarity | docs
location: path:line
problem: one-line description of what is more complex than it needs to be
fix: proposed simplification, concrete enough to act on (behavior-preserving)
effort: small | medium | large
The loop is stateless across invocations: hitting the 3-round cap is not the end of the road. Because each run re-orients and re-surveys from the current state, the user can re-invoke this skill to run another set of rounds — a fresh run naturally continues where the last one stopped. Mention this in the stop summary.
npx claudepluginhub cleanunicorn/agents-library --plugin agents-libraryProvides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.