---
name: slop-d6902b6ec27e
description: "Remove AI-generated code slop from git diffs to maintain code quality"
license: MIT
compatibility: cline, claude, opencode, amp, codex, gemini, cursor, pi
hint: Use when cleaning up AI-generated code slop in git diffs
user-invocable: true
metadata:
  audience: all
  workflow: code-quality
---

# Remove AI Code Slop

Check the diff against a branch and remove all AI-generated slop introduced in this branch. Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality.

## Usage

`/slop [branch-name]`

- If no branch is provided, compare against main: `/slop main`

## What is AI Code Slop?

This includes:

- Extra comments that a human wouldn't add or is inconsistent with the rest of the file
- Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase
- Casts to `any` to get around type issues
- Any other style that is inconsistent with the file

## Core Principles

### 1. Preserve Functionality

Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.

### 2. Apply Project Standards

Follow the established coding standards from `@CLAUDE.md` or conventions:

- Use proper import sorting and file organization
- Follow language-specific patterns (ES modules, proper TypeScript types, etc.)
- Maintain consistent naming conventions
- Use proper error handling patterns

### 3. Enhance Clarity

Simplify code structure by:

- Reducing unnecessary complexity and nesting
- Eliminating redundant code and abstractions
- Improving readability through clear variable and function names
- Consolidating related logic
- Removing unnecessary comments that describe obvious code
- **IMPORTANT**: Use switch statements or if/else chains over nested ternary operators
- Choose clarity over brevity - explicit code is often better than overly compact code

### 4. Maintain Balance

Preserve necessary complexity — over-simplification can:

- Reduce code clarity or maintainability
- Create overly clever solutions that are hard to understand
- Combine too many concerns into single functions
- Remove helpful abstractions that improve code organization
- Prioritize "fewer lines" over readability

## Process

### 1. Get the diff

```bash
# Compare against main branch
git diff main...HEAD --stat

# Or against specific branch
git diff $1 --stat
```

### 2. Review each changed file

For each changed file:

- Read the current content
- Compare with original (before changes)
- Identify AI-generated slop patterns
- Check for opportunities to improve elegance and consistency

### 3. Remove slop and refine

- Remove unnecessary comments
- Simplify overly defensive code
- Remove `any` casts where possible
- Restore natural code style
- Apply project-specific best practices
- Ensure all functionality remains unchanged

### 4. Verify

```bash
# Show remaining changes
git diff --stat

# Check tests still pass
npm test
```

## Common Slop Patterns

1. **Over-commenting**: Comments explaining obvious code
2. **Verbose error handling**: Try/catch blocks where not needed
3. **Unnecessary type casts**: `x as any` to bypass TypeScript
4. **Defensive programming**: Checks for already-validated inputs
5. **Redundant validation**: Duplicate null/undefined checks
6. **Nested ternaries**: Complex nested ternary operators
7. **Overly compact code**: Dense one-liners that sacrifice readability

## Refinement Guidelines

When refining code:

1. **Identify the modified sections** - Only refine code that changed in the diff
2. **Analyze for improvement opportunities** - Look for ways to enhance elegance and consistency
3. **Apply project standards** - Follow established conventions and patterns
4. **Preserve functionality** - Ensure behavior remains unchanged
5. **Verify improvements** - The refined code should be simpler and more maintainable
6. **Document significant changes** - Only document changes that affect understanding

### Code Style Preferences

- Prefer explicit over compact - readable code beats clever code
- Use descriptive names - clarity over brevity
- Flatten deep nesting with early returns and guard clauses
- Remove redundant code - eliminate duplicates
- Use language-appropriate patterns - follow idiomatic practices


---
Source attribution: jellydn
Original project: https://github.com/jellydn/my-ai-tools/blob/920edf11fefa249af3bce8750625d4ca92ed8364/skills/slop/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

The MIT License (MIT)

Copyright (c) 2026 Dung Huynh Duc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: jellydn
Original project: https://github.com/jellydn/my-ai-tools/blob/920edf11fefa249af3bce8750625d4ca92ed8364/skills/slop/SKILL.md
Attribution basis: Source repository record

Fields of work: Content & Media, Development & Engineering
Roles: Backend Developer, DevOps / SRE, Full-Stack Developer, QA / Test Engineer, Technical Writer
Specialties: Backend, Cross Platform, Git
Tools: Tool not specified
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 1556320fd162d0be58736f5c138f6a3102b0520d32a80d3f14ccad3f4b63fd67
