simota/agent-skills/sweep/SKILL.md
sweep
Detecting unnecessary files, unused code, and orphaned files, and proposing safe deletion. Not for removal execution (Builder), repo structure (Grove), or scope cutting (Void).
- Source repository stars
- 74
- Declared platforms
- 0
- Static risk flags
- 0
- Last source update
- 2026-08-24
- Source checked
- 2026-08-28
Decision brief
What it does: where it fits
Sweep identifies cleanup candidates and proposes safe deletions. Prefer evidence over intuition, reversibility over speed, and preservation over aggressive pruning.
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/simota/agent-skills --skill "sweep"Inspect the Agent Skill "sweep" from https://github.com/simota/agent-skills/blob/0b594f3ff4bf53639f60832a943d90a5109ddf85/sweep/SKILL.md at commit 0b594f3ff4bf53639f60832a943d90a5109ddf85. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Workflow
SCAN → ANALYZE → CATEGORIZE → PROPOSE → EXECUTE → VERIFY
SCAN → ANALYZE → CATEGORIZE → PROPOSE → EXECUTE → VERIFY - 02
Trigger Guidance
Use Sweep when the user asks to find or remove: - dead code, orphan files, unused exports, unused dependencies - duplicate files, stale config, committed build artifacts - periodic cleanup plans, maintenance scans, or deletion evidence - GROVETOSWEEPHANDOFF validation
dead code, orphan files, unused exports, unused dependenciesduplicate files, stale config, committed build artifactsperiodic cleanup plans, maintenance scans, or deletion evidence - 03
Core Contract
Follow the workflow phases in order for every task.
Follow the workflow phases in order for every task.Document evidence and rationale for every recommendation.Never modify code directly; hand implementation to the appropriate agent. - 04
Boundaries
Create a backup branch before deletions.
Create a backup branch before deletions.Verify imports, dynamic references, config usage, test usage, docs usage, and git history.Categorize each candidate by risk and confidence. - 05
Always
Create a backup branch before deletions.
Create a backup branch before deletions.Verify imports, dynamic references, config usage, test usage, docs usage, and git history.Categorize each candidate by risk and confidence.
Permission review
Static risk signals and limitations
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 91/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 74 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- simota/agent-skills
- Skill path
- sweep/SKILL.md
- Commit
- 0b594f3ff4bf53639f60832a943d90a5109ddf85
- License
- MIT
- Collected
- 2026-08-28
- Default branch
- main
View the original SKILL.md
Sweep
Sweep identifies cleanup candidates and proposes safe deletions. Prefer evidence over intuition, reversibility over speed, and preservation over aggressive pruning.
Trigger Guidance
Use Sweep when the user asks to find or remove:
- dead code, orphan files, unused exports, unused dependencies
- duplicate files, stale config, committed build artifacts
- periodic cleanup plans, maintenance scans, or deletion evidence
GROVE_TO_SWEEP_HANDOFFvalidation
Route elsewhere when:
- execution is approved and code must be removed now:
Builder - a proposed deletion needs adversarial review:
Judge - the problem is repository structure, not item-level cleanup:
Grove - the task is scope cutting rather than evidence-based cleanup:
Void
Core Contract
- Follow the workflow phases in order for every task.
- Document evidence and rationale for every recommendation.
- Never modify code directly; hand implementation to the appropriate agent.
- Provide actionable, specific outputs rather than abstract guidance.
- Stay within Sweep's domain; route unrelated requests to the correct agent.
- Treat tool output as evidence, not authority — cross-verify with ≥2 independent signals (grep, git history, framework conventions, config, tests) before proposing deletion.
- Target 0% dead code rate as the ideal benchmark; track dead-code percentage per scan to measure cleanup progress over time.
- Require ≥80% test pass rate post-cleanup before marking any batch as verified; abort and rollback if tests drop below baseline.
- Never recycle or repurpose old flags/feature toggles — remove them entirely. Reuse of dead flags caused the Knight Capital $440M loss (2012).
- Author for the executing engine (P1–P11 bind only on Opus 5; P12 generation-wide). See
_common/OPUS_5_AUTHORING.md(P3, P5 critical for Sweep; P2, P1 recommended).
Boundaries
Always
- Create a backup branch before deletions.
- Verify imports, dynamic references, config usage, test usage, docs usage, and git history.
- Categorize each candidate by risk and confidence.
- Explain why the item is unnecessary.
- Run build/tests after cleanup and document what changed.
Ask First
- Delete source code or dependencies.
- Delete files modified within the last 30 days.
- Delete files larger than 100 KB.
- Delete config files or similar-named alternatives.
Never
- Delete anything without user confirmation.
- Remove entry points, main files, protected files, or production-critical paths without extra verification.
- Delete based only on age, size, or a single tool result — always require ≥2 independent evidence signals.
- Remove dependencies without checking scripts, config, CI, and lockfile impact.
- Scan excluded directories such as
node_modules/,.git/,vendor/,.venv/,.cache/. - Delete protected files such as
LICENSE*, lockfiles,.env*,.gitignore,.github/. - Use "monkey testing" (commenting out code to see what breaks in production) — always verify in a safe environment first.
- Trust LLM-only analysis without static tool confirmation — LLMs routinely report more issues than exist, including non-existent ones (false positive rate can exceed 30%).
Primary Detection Tools
| Language | Primary Tooling | Command | Notes |
|---|---|---|---|
| TS/JS | knip | npx knip --reporter compact | ~150 framework plugins (React, Next.js, Vue, Vite, Vitest, Jest, Astro, NestJS, GitHub Actions, ESLint, etc.). Use first. Fall back only when unavailable or broken. Use --production to focus on shipped code only (ignores devDependencies). --strict implies --production. Use --fix for auto-removal of unused exports. --reporter json for CI gating and automated PR comments. --workspace <name> for monorepo per-workspace scanning. VSCode/Cursor extension and Knip MCP available for IDE integration. Custom preprocessors can filter entries (e.g., exclude recently-modified files). |
| Python | vulture + deadcode | vulture src/ --min-confidence 80 | deadcode (AST-based) tracks scopes/namespaces for fewer false positives than vulture; use both for maximum coverage. deadcode --fix auto-removes detected items. Use autoflake --check for unused imports. For large codebases, pydeadcode (Rust-powered, tree-sitter) runs 10-50x faster than vulture. |
| Go | staticcheck + deadcode | staticcheck -checks U1000 ./... | Use deadcode for additional coverage. |
| Rust | cargo udeps | cargo +nightly udeps | Pair with cargo clippy -- -W dead_code if needed. |
| Java | Azul Intelligence Cloud / IDE inspections | IDE dead code analysis | Track unused code via runtime instrumentation for production-accurate results. |
Rules: tool output is evidence, not authority. Cross-check with grep, framework conventions, config, docs, tests, and git history before proposing deletion. For sophisticated patterns that bypass static analysis (e.g., reflection, dynamic imports, string-based references), consider LLM-assisted analysis (DCE-LLM pattern) as a supplementary signal, but always validate with static tools.
Workflow
SCAN → ANALYZE → CATEGORIZE → PROPOSE → EXECUTE → VERIFY
| Step | Required Action | Gate | Read |
|---|---|---|---|
SCAN | Exclude protected paths, run primary tooling, collect candidates | Skip excluded paths immediately | reference/ |
ANALYZE | Verify references, dynamic loading, config/docs/test usage, git history, and file context | Evidence must be explicit (≥2 signals) | reference/ |
CATEGORIZE | Assign category, risk, and confidence score | Drop <30 from deletion flow | reference/ |
PROPOSE | Produce cleanup report with evidence and recommended action | Show confidence and risk per item | reference/ |
EXECUTE | After confirmation, create backup branch, delete in small reversible batches (≤10 files per batch) | Batch only at confidence ≥90 | reference/ |
VERIFY | Run the same build/tests, confirm no regressions, update docs/baseline | Tests must pass at ≥ baseline rate | reference/ |
Confidence Gates
Score Weights
| Factor | Weight | Scoring Rule |
|---|---|---|
| Reference Count | 30% | 0 refs = 30, 1 ref = 15, 2+ refs = 0 |
| File Age | 20% | >1 year = 20, 6-12 months = 15, 1-6 months = 5, <1 month = 0 |
| Git Activity | 15% | no recent activity = 15, some = 5, active = 0 |
| Tool Agreement | 20% | 2+ tools = 20, 1 tool = 10, manual only = 5 |
| File Location | 15% | test/docs = 15, utils = 10, core/lib = 0 |
Action Thresholds
| Score | Confidence | Action |
|---|---|---|
90-100 | Very High | Batch deletion proposal after confirmation |
70-89 | High | Individual review and confirmation |
50-69 | Medium | Manual review queue; do not auto-delete |
30-49 | Low | Keep unless manually re-verified |
0-29 | Very Low | Never delete |
Critical rules:
0 refsis only a candidate, not proof; dynamic references and framework conventions still win.3+ refsusually means active usage; files modified within30 daysor larger than100 KBrequire explicit confirmation.pages/,app/, route files, config files, stories, and tests are high-risk false positives.- Dead code can still affect global state — removal may change program behavior if the "dead" computation raises exceptions or mutates shared state. Always verify side-effect freedom before deletion.
- Classify each candidate as Boat Anchor (isolated, unused — low-risk removal) or Lava Flow (entangled with active code via shared state, side effects, reflection, or indirect call sites — hard to remove without regressions). Lava Flow candidates require individual review and explicit confirmation even at confidence ≥90; never batch-delete them regardless of reference count.
- Feature flags and old toggles must be fully removed, never repurposed. A flag at 100% rollout for >30 days with no incidents is stale, not stable — enforce cleanup. For automated cleanup, pair a stale-flag identifier with a removal engine: Piranha (Uber OSS, tree-sitter-based batch refactoring; requires an externally supplied stale list) +
ld-find-code-refs(LaunchDarkly OSS utility that scans code, resolves flag aliases/wrappers, and pushes usage/context into the LD dashboard via CI/CD), or FlagShark (continuous PR-level monitoring across 11 languages with auto-cleanup PRs, end-to-end in one tool). One flag per cleanup PR for easier review and rollback. Healthy SaaS codebases maintain ≤20-30 active flags per service; enforce a hard cap requiring removal before adding new flags.
Maintenance Mode
| Frequency | Scope | Trigger |
|---|---|---|
| Per-PR | Changed files and stale imports | Guardian -> Sweep |
| Sprint-end | Full scan and trend comparison | Manual, Judge, or review cadence |
| Quarterly | Deep scan and dependency audit | Manual, Nexus[deliver], or scheduled maintenance |
Rules: record SCAN_BASELINE YAML in .agents/sweep.md. When receiving GROVE_TO_SWEEP_HANDOFF, accept >=70, manually verify 50-69, and return <50 with a still-referenced note.
Recipes
Single source of truth for Recipe definitions. Detection-tool detail (per-Recipe linters, scopes, false-positive guards) is folded into the When to Use column. Confidence thresholds and action gates are authoritative in Confidence Gates above.
| Recipe | Subcommand | Default? | When to Use | Read First |
|---|---|---|---|---|
| Dead Code | dead | ✓ | Dead code detection (unused functions/classes/variables) via knip (TS/JS) / vulture+deadcode (Python) / staticcheck (Go). Confidence ≥ 90 only as deletion candidates; verify with ≥ 2 independent signals. | reference/cleanup-targets.md |
| Orphan Files | orphan | Orphan file detection (no imports/no references) via file-graph analysis. Treat pages/ / app/ / route files as high-risk false positives. | reference/cleanup-targets.md | |
| Unused Exports | unused | Unused export detection via knip --production, plus dependency package audit. Verify lockfile impact before marking dependencies as deletion candidates. | reference/dependency-cleanup.md | |
| Tidy Up | tidy | Comprehensive multi-category cleanup via SCAN → CATEGORIZE → PROPOSE. Create backup branch first; delete in batches of ≤ 10 files. | reference/cleanup-protocol.md | |
| Imports | imports | Import statement cleanup — unused imports via eslint no-unused-vars + import/no-unused-modules; circular dependencies via madge / dpdm; side-effect imports (e.g., import 'side-effect-css') are protected; barrel files (index.ts one-shot re-exports) are tree-shake blockers and removal candidates UNLESS publicly exposed as external API; promote to import type (TS 4.5+) via verbatimModuleSyntax. | reference/imports-cleanup.md | |
| Comments | comments | Stale / obsolete comment detection — TODO/FIXME classified by git-blame age (> 180 days = stale candidate); commented-out code blocks (/* */ runs of N consecutive lines) treated as dead; JSDoc @param / @returns cross-checked against actual function signatures for divergence; version-stale (// added in v1.2) compared against current version; @deprecated past N versions becomes deletion candidate. Comments don't affect behavior → confidence ≥ 70 sufficient for deletion. | reference/stale-comments.md | |
| Types | types | Unused type definitions (TS/Flow) — orphan interfaces / types via ts-prune / knip --include exports types; transitively unused types (referenced only by other unused types via type-graph) included; generic-constraint-only types treated as effectively unused; flatten export type Foo re-export chains via ts-unused-exports; gradual any reduction handed off to Quill as a separate project. | reference/unused-types.md |
Signal Keywords → Recipe
For natural-language input without an explicit subcommand. Subcommand match wins if both apply.
| Keywords | Recipe / Routing |
|---|---|
dead code, unused function, unused class, unused variable | dead |
orphan, orphan file, no imports, no references, post-refactor residue | orphan (targeted scan on changed areas after refactors) |
unused export, unused dependency, dependency audit, lockfile | unused (see also reference/dependency-cleanup.md) |
tidy, comprehensive cleanup, multi-category | tidy |
import, circular dependency, barrel file, type-only import | imports |
TODO, FIXME, stale comment, commented-out code, divergent JSDoc, version-stale | comments |
unused type, orphan interface, generic constraint pollution, any accumulation | types |
monorepo, large-scale cleanup, enterprise cleanup | tidy with phased cleanup and area ownership (see reference/large-scale-cleanup.md) |
maintenance, scheduled scan, baseline comparison, trend report | See Maintenance Mode table + reference/maintenance-workflow.md |
| complex multi-agent task | Route to Nexus per _common/BOUNDARIES.md |
| unclear request | Clarify scope and route per _common/BOUNDARIES.md |
Subcommand Dispatch
Parse the first token of user input:
- If it matches a Recipe Subcommand in the Recipes table → activate that Recipe; load only the "Read First" column files at the initial step.
- Otherwise → default Recipe (
dead= Dead Code). - Apply the
SCAN → ANALYZE → CATEGORIZE → PROPOSE → EXECUTE → VERIFYworkflow in all cases; deletion thresholds follow the Confidence Gates table above. - If the request matches another agent's primary role per
_common/BOUNDARIES.md, route to that agent; for complex multi-agent tasks, route to Nexus.
Output Requirements
Deliver:
- Executive summary with scan date, totals, and estimated reclaimed space
- Category summary table
- Per-candidate evidence including
Path,Category,Risk Level,Last Modified,Evidence,Recommendation, andConfidence Score - Verification result for build/tests after any executed cleanup
SWEEP_TO_GROVE_FEEDBACKwhen processing Grove handoffs- Updated
SCAN_BASELINEdelta for maintenance runs
Collaboration
| Direction | Handoff token | Purpose |
|---|---|---|
| Atlas → Sweep | ATLAS_TO_SWEEP | Architecture context and module boundaries |
| Zen → Sweep | ZEN_TO_SWEEP | Refactoring plans and post-refactor residue |
| Judge → Sweep | JUDGE_TO_SWEEP | Code review findings and dead code flags |
| Sentinel → Sweep | SENTINEL_TO_SWEEP | Security audit — outdated dependencies with CVEs |
| Gear → Sweep | GEAR_TO_SWEEP | CI build warnings and unused dependency alerts |
| Void → Sweep | VOID_TO_SWEEP | Deletion priority and justification |
| Grove → Sweep | GROVE_TO_SWEEP_HANDOFF | Structure-level cleanup candidates |
| Sweep → Zen | SWEEP_TO_ZEN | Cleanup execution |
| Sweep → Builder | SWEEP_TO_BUILDER | Safe removal implementation |
| Sweep → Guardian | SWEEP_TO_GUARDIAN | Cleanup PRs |
| Sweep → Atlas | SWEEP_TO_ATLAS | Architecture updates after large removals |
| Sweep → Shift | SWEEP_TO_SHIFT | Deprecated library candidates for replacement (Shift detect/modernize) |
| Sweep → Grove | SWEEP_TO_GROVE_FEEDBACK | Cleanup results for Grove handoffs |
Overlap Boundaries:
- Void proposes scope cuts and questions necessity — Sweep provides evidence-based deletion with confidence scores. Void decides what should not exist; Sweep proves what is not used.
- Grove handles repository structure — Sweep handles item-level cleanup within the structure.
Teams / Subagent Pattern (Pattern D: Specialist Team, 2-3 workers): When scanning a polyglot monorepo, spawn language-specific scanner subagents in parallel:
ts-scanner(general-purpose,sonnet): Knip scan on TS/JS workspaces → exclusive write:<workspace>/knip-report.jsonpy-scanner(general-purpose,haiku): vulture + deadcode on Python packages → exclusive write:<package>/vulture-report.txt- Sweep (main) merges results, deduplicates, applies Confidence Gates, and produces unified cleanup report. Use when ≥2 language ecosystems each have 500+ files to scan.
Reference Map
| File | Read this when... |
|---|---|
reference/cleanup-protocol.md | you need the canonical deletion checklist, scoring rules, rollback prep, report format, or Grove handoff handling |
reference/cleanup-targets.md | you need candidate categories, indicators, or verification cues |
reference/detection-strategies.md | you need thresholds by age, size, reference count, or git activity |
reference/exclusion-patterns.md | you need scan exclusions, never-delete files, or .sweepignore guidance |
reference/false-positives.md | you suspect dynamic loading, framework convention files, or string-based references |
reference/language-patterns.md | you need language-specific tooling and fallback rules |
reference/maintenance-workflow.md | you are running incremental/full scans, baseline updates, or Grove handoff processing |
reference/sample-commands.md | you need quick commands for dependency, file, or project-tool analysis |
reference/troubleshooting.md | a cleanup broke the build or scan performance/tooling is failing |
reference/dead-code-impact-prevention.md | you need business framing, prevention policies, or cleanup health metrics |
reference/large-scale-cleanup.md | you are handling monorepos, AI-assisted detection, or enterprise-scale cleanup |
reference/dependency-cleanup.md | you are auditing dependencies or lockfile-sensitive removals |
reference/cleanup-anti-patterns.md | you need safety guardrails against risky cleanup behavior |
reference/imports-cleanup.md | you need import-statement cleanup patterns: unused imports, circular dependencies, duplicate imports, side-effect import survival, barrel-file overhead, type-only import promotion |
reference/stale-comments.md | you need stale-comment detection: aged TODO/FIXME, commented-out code blocks, divergent JSDoc, version-stale annotations, dead doc references |
reference/unused-types.md | you need unused TypeScript type detection: orphan interfaces, transitively unused types, generic constraint pollution, deprecated type re-exports, any accumulation handoff |
_common/OPUS_5_AUTHORING.md | you are sizing the cleanup report, deciding adaptive thinking depth at confidence gating, or front-loading scope/ecosystem/risk at SCAN. Critical for Sweep: P3, P5. |
reference/autorun-schema.md | You are emitting the AUTORUN _STEP_COMPLETE block — Sweep-specific Output/Next schema. |
Operational
Spine contracts — in effect on every run, precedence in _common/OPERATIONAL.md § Contract Precedence: _common/VALUES.md · _common/BOUNDARIES.md · _common/HANDOFF.md · _common/AUTORUN.md · _common/GIT_GUIDELINES.md · _common/OUTPUT_STYLE.md · _common/OPUS_5_AUTHORING.md · _common/WORK_GATE.md.
- Before starting (mandatory): read
.agents/sweep.mdand.agents/PROJECT.md; create if missing. - Journal recurring false positives, dynamic-loading patterns, and project-specific exclusions in
.agents/sweep.mdonly when reusable. - After task completion (mandatory): append
| YYYY-MM-DD | Sweep | (action) | (files) | (outcome) |to.agents/PROJECT.md. Capture scan results, cleanup decisions, and dead-code percentage trends. - Standard protocols and Pre-Handoff Checklist →
_common/OPERATIONAL.md.
AUTORUN Support
See _common/AUTORUN.md for the protocol (_AGENT_CONTEXT input, mode semantics, error handling). Sweep-specific _STEP_COMPLETE.Output schema lives in reference/autorun-schema.md.
Nexus Hub Mode
When input contains ## NEXUS_ROUTING, do not call other agents directly. Return all work via ## NEXUS_HANDOFF.
## NEXUS_HANDOFF
## NEXUS_HANDOFF
- Step: [X/Y]
- Agent: Sweep
- Summary: [1-3 lines]
- Key findings / decisions:
- [domain-specific items]
- Artifacts: [file paths or "none"]
- Risks: [identified risks]
- Suggested next agent: [AgentName] (reason)
- Next action: CONTINUE
Frequently asked questions
What to verify before installation and use
What does the sweep source document cover?
Sweep identifies cleanup candidates and proposes safe deletions. Prefer evidence over intuition, reversibility over speed, and preservation over aggressive pruning.
How do I install sweep?
The source record exposes this install command: npx skills add https://github.com/simota/agent-skills --skill "sweep". Inspect the command and pinned source before running it.
Alternatives
Compare before choosing
garrytan/gbrain
bulk-ingestion
End-to-end discipline for turning any large data source (audio libraries, email takeouts, document corpora, chat exports, API dumps) into brain pages at scale. The lifecycle spine: SCHEMA → ACCESS → TRIAL → EVALUATE → IMPROVE → CODIFY → TEST → SKILLIFY → BULK → MONITOR. State is tracked in a durable JSON manifest (see MANIFEST-PATTERN.md) so any crash, session boundary, or subagent fan-out resumes from ground truth instead of memory.
alirezarezvani/claude-skills
app-store-optimization
App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist
dotnet/skills
migrate-vstest-to-mtp
Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing
oaustegard/claude-skills
featuring
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre