home / skills / davila7 / claude-code-templates / deslop

This skill removes AI-generated code slop from a branch by diffing with main and cleaning up comments, checks, and style inconsistencies.

npx playbooks add skill davila7/claude-code-templates --skill deslop

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1000 B
---
name: deslop
description: Remove AI-generated code slop from a branch. Use when cleaning up AI-generated code, removing unnecessary comments, defensive checks, or type casts. Checks diff against main and fixes style inconsistencies.
---

# Remove AI Code Slop

Check the diff against main and remove all AI-generated slop introduced in this branch.

## What to Remove

- Extra comments that a human wouldn't add or are inconsistent with the rest of the file
- Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase (especially if called by trusted/validated codepaths)
- Casts to `any` to get around type issues
- Inline imports in Python (move to top of file with other imports)
- Any other style that is inconsistent with the file

## Process

1. Get the diff against main: `git diff main...HEAD`
2. Review each changed file for slop patterns
3. Remove identified slop while preserving legitimate changes
4. Report a 1-3 sentence summary of what was changed

Overview

This skill removes AI-generated code slop from a feature branch to restore code quality and consistency. It inspects the diff against main and automatically or manually removes noisy comments, redundant defensive checks, bad type casts, and style inconsistencies. The goal is to preserve legitimate logic while cleaning up artifacts AI assistants often introduce.

How this skill works

It computes the git diff between main and the current branch and scans changed files for common slop patterns: excessive comments, unnecessary try/catch blocks, casts to permissive types, inline imports, and style deviations. For each finding it either applies a corrective change (moving imports, deleting redundant checks, fixing casts) or flags it for reviewer confirmation. It then outputs a concise 1–3 sentence summary describing the edits made.

When to use it

  • After adding AI-generated code or running an AI assistant on a task
  • Before opening a pull request where AI contributed changes
  • When a reviewer notices unusual comments, defensive code, or type workarounds
  • When style inconsistencies appear between the branch and existing codebase

Best practices

  • Run git diff main...HEAD before and after to verify only intended changes remain
  • Prefer minimal edits: remove slop but avoid rewriting legitimate logic
  • Move inline imports to the top and follow project import ordering rules
  • Replace casts to permissive types with precise types or runtime checks only when necessary
  • Document any behavioral changes briefly in the edit summary

Example use cases

  • Clean up a branch where an AI assistant inserted multiple explanatory comments and try/except blocks
  • Remove casts to any or permissive typing introduced to silence errors in a TypeScript or Python typing transition
  • Normalize import placement after an AI added inline imports inside functions
  • Eliminate redundant null checks where callers already guarantee non-null arguments
  • Prepare a branch for review by removing style and idiom inconsistencies introduced by code generation

FAQ

Will this change program behavior?

The skill aims to preserve behavior; it only removes redundant checks and comments. Any change that could affect behavior is flagged for manual review.

How does it detect slop?

It uses heuristics for common patterns: repetitive explanatory comments, unusual defensive constructs, casts to permissive types, inline imports, and deviations from project style. Flagged items can be confirmed before applying edits.