Clean AI slop out of the code a branch changed, and leave behavior unchanged. Use it before every commit, and on /deslop, "deslop it", "clean the diff", or "strip the slop". It cleans code only. The unslop skill owns prose, and the no-comments skill owns the comment review.
Scope
Use the caller's files or diff. Otherwise diff against the branch this one builds on, including the working tree and untracked files (git status --short): the pull request's base when one is open (gh pr view <branch> -R <owner>/<repo> --json baseRefName, with <owner>/<repo> from origin's fetch URL), else the branch it was cut from (git branch -vv or git reflog show <branch>), else main. On a stacked branch, main would pull the parent's commits into the diff. Edit only inside the hunks the branch added or changed. Read whatever the rules need to judge them: callers, types, existing helpers, and the rest of the file. Slop you notice elsewhere goes in the report and stays untouched.
Process
- Read the diff hunk by hunk and name the task each hunk serves. A hunk that serves none is rule 17.
- Apply the rules below in order. Make the smallest edit. Delete before you rewrite.
- Stop at a cut that needs a new shape, such as a type, a helper, or a state model. Flag it for the Refactoring playbook. Deslop never adds abstraction to remove slop.
- Prove behavior unchanged on the real artifact. Run the tests the diff touches and the type check. A test that must change to pass means behavior changed. Revert that cut.
- Hand what remains to the neighbors. A comment that rules 1 to 3 do not settle needs the comment review before you report. Use the no-comments skill on those comments. If its review changes code, run step 4 again. Then use the unslop skill on names, messages, and kept comments.
- Report in the format below.
Rules
Rule numbers are stable ids that other skills cite. A removed rule leaves a gap. Each rule names the target, its tell, and the fix.
Comments
- Narrating comments. The comment restates the line below it or names a phase (
// increment count,// Phase 1: add cards). Delete it. - Commented-out code and removal markers. Code behind comment markers, or a
// removednote. Delete it. - Keep list. License headers. Non-obvious behavior forced by an external dependency, platform, vendor, or protocol you cannot reshape.
prettier-ignore. Doc comments that define a public API contract. Issue or RFC links that explain a constraint code cannot express. A kept comment is still prose, so step 5 sends it to the unslop skill.
Guards
- Guard on an impossible state. A null check on a value the types or the boundary never leave null,
instanceofon an already narrowed type, a length check on a tuple, a default for an argument every caller passes. Delete it. Trust the type. - Defensive wrapping on a trusted path. A
try/catchor a fallback around an internal call that cannot fail the way the handler expects, or a handler that swallows the error. Remove the wrapper, or let it throw. A silent fallback that hides an unclear invariant is rule 4, and the report names the invariant. - Repeated validation. A check that re-parses or re-validates data the boundary already parsed. Delete the inner copy.
A guard at a system boundary (user input, network, file, environment, external API) stays. A guard a test demands stays, and the test is the proof.
Dead paths
- Compatibility shims. An old path kept beside the new one, an alias or re-export kept "for callers" with no caller, a deprecation notice for code this branch replaced. Delete a shim with no caller. When every caller sits inside the branch's hunks, migrate them and delete the shim in the same change. A shim with a caller outside those hunks stays, and the report names it, because migrating that caller would edit outside Scope.
- Unused parameters, exports, and flags. A parameter nothing passes, an export nothing imports, an option with one value, a flag with one reachable branch, a branch marked temporary. Delete it.
- Debug residue. Debug logs and prints, tagged or not, throwaway prototypes, variant switchers. Delete them.
A symbol on the package's public surface (an entry-point export, a documented API) stays even with no caller in the repository, because its callers live outside it. Delete it only when the task removes it from the public API. Otherwise list it under "Did not touch".
Types
- Checker silencers. A cast to
anyorunknown, anasassertion, or a suppression comment whose only job is to make the type checker pass. Fix the type or delete the cast.
Shape
- One-caller wrappers. A function, helper, or adapter with one caller that passes its arguments through. Inline it.
- Speculative generality. An abstraction, parameter, hook, or seam with one implementation and no second use in the task. Inline it back until a real need shows.
- Re-implemented helpers. Code that does what a helper in the codebase already does. Call the existing one.
- Nesting an early return flattens. A guard clause whose body is the rest of the function. Return early and dedent.
- Copy-paste with variation. The same shape twice inside the diff with small differences. Extract only when the codebase already names the shared shape. Otherwise three similar lines stay.
- Structure the diff cannot fix. A new conditional bolted onto an unrelated flow, a one-off boolean or nullable mode, repeated conditionals on one shape. Flag it for the Refactoring playbook under principle-model-the-domain. Do not fix it here.
Scope
- Unrelated edits. Formatting churn, renames, import reorders, or syntax modernizing in code the task did not need to touch. Revert the hunks git can restore: those committed on the branch, and those you wrote this session. An uncommitted hunk you did not write stays, and the report names it, because reverting it would destroy work no commit holds.
git diff <base>...HEADshows the committed hunks andgit diff HEADthe uncommitted ones. Revert hunk by hunk, never by restoring a whole file, so an uncommitted hunk in the same file survives. To revert a committed hunk, edit its lines back by hand, or reverse only that hunk taken fromgit diff <base>...HEAD -- <file>. Reversing that whole diff also undoes the file's task work, andgit diff <base> -- <file>also carries the file's uncommitted hunks. - A behavior change inside cleanup. A hunk that changes what the code does under a cleanup label. Split it out and name it in the report.
- Style against the file. A pattern the surrounding file does not use. Match the file.
Report
One to three sentences, then:
- Counts by rule id, and the files touched.
- Hunks reverted under rule 17, and the uncommitted unrelated hunks left in place.
- Flags handed to the Refactoring playbook (step 3, rule 16).
- The comments step 5 gave the no-comments skill, and what it did with each.
- A "Did not touch" list of slop outside the scope.
- The test and type-check commands with their results.
CREDITS.md names the sources this skill drew on and the sentences it carried over.