sweep-code
Skill5 starsChanged 3 days agoMITView on GitHub
Scan the code for bugs and dead code, prove each finding, then fix the approved bugs with regression tests and remove the approved dead code.
- Reads credentials
2 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- jabbott-iii/Tidepooledited, first seen Nov 29, 2026
- jabbott-iii/Grimoireedited, first seen Nov 29, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- jabbott-iii/Grimoire★ 290% same
- jabbott-iii/Tidepool★ 190% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- build-courseSkill
- set-up-githubSkill
- build-courseSkill
- set-up-githubSkill
- build-courseSkill
- build-language-packsSkill
- build-roadmap-and-docsSkill
- draw-diagramsSkill
- fix-doc-driftSkill
- next-taskSkill
- phase-gatesSkill
- security-sweepSkill
- set-up-githubSkill
- simplify-codeSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. About 0 are common, 19 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 40
"bugs" or "dead code": after the scope: look for that kind only.
- Distinctive: line 42
Leave out generated code, vendored third-party code, and the Never commit paths.
- Distinctive: line 45
Run git status before you start.
- Distinctive: line 52
Before you change anything, run the Check commands (or the Test tools) and the
- Distinctive: line 60
Run the tools: Run the project's own checks at the strictest settings it uses, then the tools in "Tools by language" that the project …
- Distinctive: line 77
Read the code: Look for what tools miss, hardest where input enters, where errors are handled, and where work runs at the same time:
- Distinctive: line 164
Dead: no path reaches it in any build, and the compiler or a tool agrees where one can tell.
- Distinctive: line 166
Probably dead: no use found, but a way in from the list above can't be ruled out.
- Distinctive: line 196
Write a test that fails because of the bug, where the Test layout puts tests.
- Distinctive: line 199
Never make a bug go away by suppressing a warning, discarding the error, or loosening a test.
- Distinctive: line 200
Run the test again, and watch it pass.
- Distinctive: line 201
Look for the same mistake elsewhere, because copied code copies its bugs.
- Distinctive: line 204
If no test can show the bug, as with a race that rarely happens or a device you don't have, say so, and tell the user how to confirm the …
- Very specific: line 209
Delete all of it: the code, its tests, the docs and comments that mention it, and the resources, config, and dependencies only it used.
- Very specific: line 212
Remove a dependency with the package manager's own command where it has one (cargo remove, npm uninstall, dart pub remove), so the lock …
- Distinctive: line 215
Leave the code around it as it is: don't refactor, reformat, or rename it in the same change.
- Distinctive: line 217
Stop and ask if a fix grows bigger than its finding described, or needs a decision the user hasn't made.
- Distinctive: line 222
Run the Check commands (or the Test tools) and the Done checks again, and compare each result with the baseline: nothing newly failing, and …
- Distinctive: line 225
After removing dead code, build and test every platform, target, build variant, and feature combination the project has, because code that …
- Distinctive: line 229
Search once more for every name you deleted, in the docs, config, and scripts too.
- Very specific: line 230
Do the checks in "Before finishing" in writing.md for each comment and document you changed.
- Very specific: line 237
If roadmap-and-docs.md is adopted, offer to add the ones the user wants to keep to the roadmap's backlog.
- Very specific: line 245
Follow the Git access level in commits.md, and leave the changes uncommitted unless the user asked for a commit and that level allows it.
- Distinctive: line 268
Use the tools the project already has first.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Sweep the code for bugs and dead code
Requested: $ARGUMENTS (empty means the whole repository, and both kinds).
This skill looks for two kinds of problems, and fixes the ones the user approves:
- Bugs: code that does the wrong thing, or will for some input, timing, or platform.
- Dead code: code, files, and dependencies that no build the project ships ever reaches.
It proves each finding before it reports it, changes nothing until the user approves, and makes each fix a change of its own. Bold names are values from the "Project details" of the adopted rules:
- Git access, Done checks, Never commit, and Breaking changes from
commits.md; - Check commands, Test layout, Dependency policy, Public API, and
Published crates, Published modules, Published rocks, or Published packages from
the language rules (
rust.md,kotlin.md,java.md,android.md,kotlin-multiplatform.md,swift.md,flutter.md,lua.md,python.md, andtypescript.md), Exported components fromandroid.md, and Test tools fromweb-front-end.md; - the Docs folder and the Decision log from
roadmap-and-docs.md, where it is adopted.
Where a value doesn't exist because a rule isn't adopted, work from what the repository has, and
say so in the report. Ask before each change that a rule's "Decisions that are the user's"
section lists, and where pair-programming.md is adopted, work with the user as it describes.
1. Set the scope
- A path or an area: the code there, its tests, and the files only it uses.
- A Git range: the code the range changed (
git diff --stat <range>) and the code that calls it. New bugs most often sit in new code, and new dead code in what the new code replaced. - Empty: the whole repository, one module, crate, or package at a time. If there are more than a few, report after each one.
- "bugs" or "dead code" after the scope: look for that kind only.
Leave out generated code, vendored third-party code, and the Never commit paths. Report a bug found there, but fix it at its source: the generator's input, or the upstream project.
Run git status before you start. If the tree has uncommitted changes you didn't make, leave
them alone and tell the user, because a fix mixed into them can't be reviewed or reverted on its
own. Then tell the user in one or two sentences what you will scan and in what order, and make a
task list whose last item is "Verify and report".
2. Record a baseline
Before you change anything, run the Check commands (or the Test tools) and the Done checks, and record each result: what passes, what fails, and how many warnings each tool prints. A check that already fails is a finding, not something your work broke. If the code doesn't build, report that first, and look for findings only by reading until the user decides what to do.
3. Look for bugs
Run the tools. Run the project's own checks at the strictest settings it uses, then the tools
in "Tools by language" that the project already has. Read every warning, including the ones the
project has learned to ignore. Don't install a tool, or run a command that downloads one (such
as npx or dart pub global activate), without asking the user first.
Question every suppression. Each one hides a possible finding: #[allow(…)], @Suppress,
@SuppressWarnings, @SuppressLint, a lint baseline, // ignore:, // swiftlint:disable,
eslint-disable, @ts-ignore, @ts-expect-error, # noqa, # type: ignore,
-- luacheck: ignore, and ---@diagnostic disable. Check that its reason still holds. In Rust,
#[expect(…)] in place of #[allow(…)] makes the compiler warn (unfulfilled_lint_expectations)
when the lint no longer fires, so it shows which suppressions hide nothing. In Python, mypy's
warn_unused_ignores and Ruff's RUF100 do the same for # type: ignore and # noqa comments. In
TypeScript, tsc reports an @ts-expect-error with no error left to expect, and ESLint's
reportUnusedDisableDirectives reports an eslint-disable comment that suppresses nothing. In
Java, javac never reports a @SuppressWarnings that suppresses nothing, so remove each one and
compile again to see whether it still hides a warning.
Read the code. Look for what tools miss, hardest where input enters, where errors are handled, and where work runs at the same time:
| Kind | What to look for | ||
| Errors | Errors caught and dropped (an empty catch, let _ =, try?, .ok(), runCatching with its result ignored); errors logged and then ignored; a crash on bad input (unwrap, !!, a force unwrap, an unchecked index) | ||
| Edges | Off-by-one errors; empty and one-item input; integer overflow and narrowing casts; division by zero; NaN (not a number); == on floating-point numbers | ||
| Untrusted input | Sizes and counts used without a limit; path traversal (../ in a file name); input pasted into SQL, a shell command, or HTML | ||
| Concurrency | Data races; check-then-act on shared state (acting on a value another thread may have changed since it was read); a lock held across an await; work that is never canceled; futures, promises, and tasks never awaited | ||
| Resources | Files, connections, listeners, subscriptions, and timers never closed or removed; reference cycles that keep objects alive | ||
| State | A cache that is never invalidated; state left half-updated after a failure; writes that belong in one transaction but aren't | ||
| Logic | Inverted conditions; the wrong operator; a copied branch with one name left unchanged; a shadowed variable; a switch case that falls through; identity compared where equality was meant; in Lua, a method called with . instead of :, and # on a table that can have holes; in Python, a mutable default argument that every call shares, and a closure that reads a loop variable after the loop has moved on; in JavaScript and TypeScript, sort() on numbers without a compare function, which sorts them as strings, and ` | where??was meant, which replaces a valid0or""; in Java, BigDecimal.equalswherecompareTowas meant, sinceequalsalso compares the scale, so1.0doesn't equal1.00` | |
| Time and place | Time zones and daylight saving time; clocks that can go backward; parsing and formatting that depend on the device's locale | ||
| Contracts | Code that disagrees with its doc comment, its spec, its test's name, or the decision record that set it; a TODO or FIXME that describes a known bug |
Prove each one. Give every suspected bug a proof before you report it, and say which kind:
- Confirmed: a test or a run fails because of it. Write that test now when you can; it becomes the fix's regression test.
- Traced: an input, timing, or platform that reaches the bug, followed step by step through the code, but not run.
- Suspected: a pattern that is often a bug, with no path to it found yet. Report it as a question, never as a bug.
4. Look for dead code
What counts:
- Unreachable code: statements after a
returnor athrow, and branches whose condition can't be true. - Unused private and internal declarations: functions, types, fields, constants, parameters, imports, and local variables.
- Unused public declarations in an application. A library's are different: see "Libraries" below.
- Feature flags that are always on or always off, and the branches they hide.
- Compatibility code the project no longer needs, such as a check for an OS version below the lowest one it supports.
- Commented-out code.
- Unused files: resources, assets, strings, styles, scripts, config, and fixtures.
- Unused dependencies, and build targets and scripts that nothing runs.
- Tests of dead code only. They are dead too, and go with it.
Prove it dead. A search that finds no caller isn't proof. Before you call something dead, rule out every way code is reached without a direct call:
- Reflection, serialization, and dependency injection: names in annotations, JSON fields, and dependency injection modules.
- Names looked up as text: Android resources by name, platform channel and method names, routes,
event names, CSS classes that JavaScript builds, registries keyed by strings, in Lua, module
names built as strings for
requireand functions looked up by name (M[name]), in Python, names passed togetattrorimportlib.import_modulethat the code builds at run time, and in JavaScript and TypeScript,import()of a path built at run time and properties read with a computed name (handlers[name]), and in Java,Class.forNameand method lookups by reflection with names built at run time. - Entry points the platform calls: the components in the Android manifest (the
Exported components),
Info.plistentries on Apple platforms,mainfunctions, scheduled jobs, command-line subcommands, the callbacks a Lua host calls by name, and in Python, the entry points inpyproject.toml([project.scripts]and[project.entry-points]), the fixtures and hooks that pytest finds by name, and special methods, such as__eq__and__enter__, that the interpreter calls itself. In JavaScript and TypeScript, they include the entry points inpackage.json(bin,main, and each path inexports) and the files a framework loads by where they sit, such as page and route files. In Java, they include the service providers thatServiceLoaderfinds, whichMETA-INF/services/or aprovidesclause inmodule-info.javanames, and the classes a framework finds by their annotations, such as Spring's@Componentor JUnit's@Test. - Symbols exported to another language:
#[no_mangle]andextern "C", Java Native Interface (JNI) functions,@objc,@JvmStatic, the framework API that Kotlin Multiplatform exports to Swift, Dart's@pragma('vm:entry-point'), and C functions registered with Lua (aluaL_Regarray). - Code that only some builds use: platforms, targets, build variants, and features
(
#[cfg(…)], Cargo features,expectandactual,#if os(…), Gradle product flavors and Maven profiles,kIsWeb, Lua's checks ofjitor_VERSION, and Python's checks ofsys.version_infoorsys.platform, and itsif TYPE_CHECKING:blocks, which only type checkers read; and in JavaScript, checks ofprocess.env.NODE_ENVortypeof window, and the conditions inpackage.json'sexports). - Code generators, build scripts, macros, templates, and other repositories that call or copy this code.
- Work the roadmap plans: code written ahead for a planned task isn't dead. Check the roadmap in the Docs folder and the Decision log, and ask the user.
Libraries. Code you can't see uses a library's public items, so never call one dead because this repository doesn't use it. The Public API and the Published crates, Published modules, Published rocks, or Published packages say what is published. Removing a published item falls under Breaking changes and is the user's decision; suggest deprecating it first.
Classify each finding:
- Dead: no path reaches it in any build, and the compiler or a tool agrees where one can tell.
- Probably dead: no use found, but a way in from the list above can't be ruled out. Report it with what you checked.
Compilers find only part of the dead code. "Tools by language" says what each one misses.
5. Report the findings, then ask
Show every finding in one table before you change anything:
| # | Kind | Where | What's wrong | Proof | Proposed fix | Risk |
| 1 | Bug, confirmed | src/header.rs:88 | A header over 255 bytes wraps its u8 length to 0 | rejects_long_header fails | Reject lengths above 255 | Low: one function |
| 2 | Dead code, dead | src/legacy.rs | Nothing has called the v1 parser since v2.0.0 | No reference in any target or feature; the compiler warns | Delete the file and its tests | Low |
List the bugs first, the worst first: data loss and security, then wrong results, then crashes on rare input. Then the dead code. Then ask the user which findings to fix. Offer to fix every confirmed bug and every dead private item under one approval, and ask about each of these by its number:
- a traced or suspected bug;
- a probably-dead item;
- a fix that changes public API, a file format, stored data, or behavior a user can see;
- deleting a whole file, module, or dependency.
6. Fix one finding at a time
Make each fix a complete change that one commit can describe.
A bug:
- Write a test that fails because of the bug, where the Test layout puts tests. Run it, and watch it fail for the reason you expect.
- Fix the cause, not the symptom: the code that let the bad value in, not the place it crashed. Never make a bug go away by suppressing a warning, discarding the error, or loosening a test.
- Run the test again, and watch it pass.
- Look for the same mistake elsewhere, because copied code copies its bugs. Add each one you find to the findings, and fix it only once the user approves it.
If no test can show the bug, as with a race that rarely happens or a device you don't have, say so, and tell the user how to confirm the fix.
Dead code:
- Delete all of it: the code, its tests, the docs and comments that mention it, and the
resources, config, and dependencies only it used. Don't comment it out, rename it
_unused, or hide it behind a flag; Git keeps the history. - Remove a dependency with the package manager's own command where it has one (
cargo remove,npm uninstall,dart pub remove), so the lock file stays right, and follow the Dependency policy. - Leave the code around it as it is: don't refactor, reformat, or rename it in the same change.
Stop and ask if a fix grows bigger than its finding described, or needs a decision the user hasn't made. If a finding proves wrong while you fix it, drop it, and say so in the report.
7. Verify
- Run the Check commands (or the Test tools) and the Done checks again, and compare each result with the baseline: nothing newly failing, and no new warnings.
- Confirm that each bug's regression test failed before its fix and passes now.
- After removing dead code, build and test every platform, target, build variant, and feature
combination the project has, because code that only one of them uses fails only there. For
example, in Rust run
cargo check --all-targetswith--all-featuresand with--no-default-features. - Search once more for every name you deleted, in the docs, config, and scripts too.
- Do the checks in "Before finishing" in
writing.mdfor each comment and document you changed.
8. Record what's left
- List the findings you didn't fix, and why: not approved, waiting for a decision, or outside the scope.
- If
roadmap-and-docs.mdis adopted, offer to add the ones the user wants to keep to the roadmap's backlog. Don't open issues in a tracker unless the user asks. - For each kind of finding that turned up more than once, suggest a check that would catch it next time: a lint to turn on, a stricter compiler setting, a test, or a tool in continuous integration (CI). Don't add one unless the user agrees.
9. Commit only as the project allows
Follow the Git access level in commits.md, and leave the changes uncommitted unless the user
asked for a commit and that level allows it. Either way, end the report with copy-ready commit
messages, as commits.md describes, one for each fix. A bug fix is a fix; removing dead code
without changing behavior is a refactor; removing only an unused dependency is a build
change.
10. Report
End with a summary that contains:
- Scope: what you scanned, and what you left out and why.
- Baseline: each check's result before you started.
- Fixed: each finding fixed, with its regression test, or the proof that the code was dead.
- Not fixed: each finding left, by its number, and why.
- Dropped: each finding that proved wrong.
- Checks: each check after the fixes, with its real result compared with the baseline, and each one you couldn't run, and why.
- Questions: each decision the user still has to make.
- Prevention: the checks you suggest in step 8.
- Commit messages: in
textblocks, ascommits.mddescribes, with no attribution lines.
Tools by language
Use the tools the project already has first. This table says what each compiler reports on its own, what it misses, and the tools that cover the rest. The compiler columns held for rustc 1.99, Kotlin 2.4.21, javac 25.0.5, Swift 6.4.3, Dart 3.14.1, TypeScript 7.0.2, Lua 5.1.5, 5.4.9, and 5.5.1, and LuaJIT 2.1.
| Language | What the compiler reports | What it misses, and the tools that find it |
| Rust | dead_code for items nothing in the crate uses, and unused_imports, unused_variables, and unreachable_code. An item that only tests use counts as unused in cargo check. | The pub items a library exports. Clippy (cargo clippy --all-targets --all-features) for likely bugs; Miri (cargo +nightly miri test) for undefined behavior in unsafe code, though it can't run most foreign function interface (FFI) calls; cargo machete (fast but imprecise) or cargo +nightly udeps for unused dependencies; cargo audit or cargo deny check advisories for dependencies with known vulnerabilities |
| Kotlin and Android | With -Wextra only: unused local variables and unreachable code. The experimental -Xreturn-value-checker=full reports ignored return values. | Unused private functions, properties, and parameters, and unused imports: detekt's Unused… rules in its style rule set, some of them off by default. Android Lint's UnusedResources, and ObsoleteSdkInt for version checks that minSdk makes always true. The Dependency Analysis Gradle Plugin's buildHealth task for unused dependencies |
| Java | Nothing about unused code: -Xlint:all stays silent about unused imports, private fields and methods, parameters, local variables, and a @SuppressWarnings that suppresses nothing. A statement after a return is a compile error, but an if (false) block compiles without a warning, because the language allows it for conditional compilation. | Error Prone's UnusedVariable and UnusedMethod checks; PMD's UnusedPrivateField, UnusedPrivateMethod, UnusedLocalVariable, and UnusedFormalParameter rules; SpotBugs for likely bugs; and mvn dependency:analyze, which lists dependencies the code declares but doesn't use, or uses without declaring. For Gradle, the Dependency Analysis Gradle Plugin in the Kotlin row |
| Swift | Unused local constants and variables, ignored results of functions without @discardableResult, and, in a full build but not with -typecheck, code after a return | Unused functions, types, properties, and parameters: Periphery (periphery scan), now a commercial product, which on Linux scans only Swift packages. The sanitizers for bugs: swift test --sanitize=thread, address, or undefined |
| Dart and Flutter | unused_import, unused_local_variable, unused_field, dead_code, and unused_element for private declarations (names that start with _) | Unused public declarations, which no analyzer diagnostic reports: search for them, and rule out the ways in above. dependency_validator for unused packages |
| JavaScript and TypeScript | TypeScript with noUnusedLocals, noUnusedParameters, allowUnreachableCode: false, and noFallthroughCasesInSwitch; ESLint's no-unused-vars, no-unreachable, and no-fallthrough, which its recommended config turns on | Unused exports, files, and dependencies: knip. Conditions that the types show are always true or always false, and so guard dead branches: typescript-eslint's no-unnecessary-condition. CSS and JavaScript a page never runs: the Coverage panel in Chrome DevTools. npm audit for dependencies with known vulnerabilities |
| Python | No compile step reports unused code | Ruff's F401 (unused imports) and F841 (unused local variables), which it checks by default; Vulture for unused functions, classes, and variables, with --min-confidence, and a --make-whitelist file for its false positives; mypy's --warn-unreachable, which --strict doesn't turn on, for code its type analysis shows can never run; deptry for dependencies that pyproject.toml declares and no code imports; pip-audit for dependencies with known vulnerabilities |
| Lua | Nothing: luac -p and LuaJIT's compiler check syntax only. The exception is Lua 5.5: after a global declaration, an undeclared name, such as a misspelled global, is a compile error. | luacheck's warnings 211 (unused local variable), 212 (unused argument), 213 (unused loop variable), 311 (a value assigned to a local is never used), 511 (unreachable code), and 111 and 113 (setting and reading an undefined global). lua-language-server's unused diagnostics, such as unused-local, unused-function, and unreachable-code. selene's unused_variable. Each checks one file at a time, so finding a module or a public function that no other file uses takes a search |
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
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.

