home / skills / adibfirman / dotfiles / deslop-simply-ai-code

deslop-simply-ai-code skill

/claude/.claude/skills/deslop-simply-ai-code

This skill helps you simplify AI-generated code by removing noise patterns in diffs, ensuring readability while preserving exact functionality.

npx playbooks add skill adibfirman/dotfiles --skill deslop-simply-ai-code

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

Files (1)
SKILL.md
4.8 KB
---
name: deslop-simplify-ai-code
description: Remove LLM-generated code patterns that add noise without value. Use when reviewing diffs, PRs, or branches to clean up AI-generated code. Triggers include requests to "remove slop", "clean up AI code", "review for AI patterns", or checking diffs against main for unnecessary verbosity, redundant checks, or over-engineering introduced by LLMs. Language-agnostic.
---

# Deslop: Simplify AI Code

Expert code simplification focused on clarity, consistency, and maintainability while preserving exact functionality. Analyze code for unnecessary complexity, redundant patterns, and opportunities to make code more readable and idiomatic. Apply project-specific best practices—match existing code style, naming conventions, and patterns already established in the codebase.

## Workflow

1. **Understand project context**: Review existing code style, patterns, and conventions in the codebase
2. **Get the diff**: `git diff main...HEAD` or `git diff main`
3. **Identify slop patterns** in changed lines
4. **Simplify**: Remove or refactor each instance to match project idioms
5. **Verify**: Ensure functionality unchanged, code aligns with existing style

## Slop Patterns

### Comments

**Rule: Comments explain WHY, not WHAT.**

Remove:

- Comments restating what code does: `// increment counter` above `counter++`
- Section dividers: `// ========== VALIDATION ==========`
- Redundant docstrings documenting self-evident parameters
- "Note:" or "Important:" prefixes that add nothing
- Comments explaining language basics

Transform WHAT → WHY:

```
# SLOP: describes what
# Check if user is active
if user.is_active:

# CLEAN: explains why
# Inactive users can't access billing portal
if user.is_active:
```

```
// SLOP: restates the code
// Loop through all items and process each one
for item in items:
    process(item)

// CLEAN: no comment needed, or explain why this approach
// Process sequentially - parallel causes rate limit errors
for item in items:
    process(item)
```

### Null/Error Handling

Remove redundant checks:

```
# SLOP: checking what's already guaranteed
if user is not None and user is not empty and is_valid_type(user):
    if user.name is not None and user.name is not empty:

# CLEAN: trust the type system or add one meaningful check
if user and user.name:
```

Simplify excessive try-catch:

```
# SLOP: catch-log-rethrow adds nothing
try:
    do_thing()
catch error:
    log("Error doing thing:", error)
    throw error

# CLEAN: let it propagate or handle meaningfully
do_thing()
```

### Abstractions

Flatten unnecessary layers:

- Single-use helper functions that obscure rather than clarify
- Wrapper classes around simple operations
- "Manager", "Handler", "Service" suffixes on thin wrappers
- Config objects for 1-2 values

### Verbosity

```
# SLOP
is_user_valid = user.is_active == true
if is_user_valid == true:
    return true
else:
    return false

# CLEAN
return user.is_active
```

Common patterns:

- `== true` / `== false` comparisons
- Intermediate variables used once
- `if x: return true; else: return false` → `return x`
- Unnecessary destructuring then reassembly

### Naming

Fix over-descriptive names:

- `userDataResponseObject` → `user`
- `isCurrentlyProcessingData` → `processing`
- `handleOnClickButtonEvent` → `onClick`

### Structure

Remove:

- Empty constructors
- Getters/setters that just proxy fields
- Interfaces implemented by one class
- Abstract classes with one child
- Enums with one value

### Logs/Debug

Remove:

- Debug print/log statements
- Verbose entry/exit logging: `Entering function X with params...`
- Success logs that spam output: `Successfully processed item 1 of 10000`

Keep: error logging with context, audit logs for important operations.

## Review Checklist

For each changed file, ask:

1. Does this comment explain WHY, not WHAT?
2. Is this null check protecting against something that can actually happen?
3. Does this abstraction earn its complexity?
4. Could this be expressed more directly?
5. Is this name proportional to the scope?
6. Does this match existing patterns in the codebase?
7. Would a maintainer find this clearer or more confusing?

## Guiding Principles

- **Preserve behavior**: Never change what the code does, only how it's expressed
- **Match the codebase**: New code should look like it belongs—follow existing conventions
- **Simplify, don't clever**: Prefer obvious solutions over clever ones
- **Earn complexity**: Every abstraction, check, or layer must justify its existence
- **Readable > short**: Clarity beats brevity when they conflict

## Edge Cases

Don't remove:

- Defensive checks at API boundaries (external input)
- Comments required by linters or documentation generators
- Abstractions that enable testing or future extension (if justified)
- Explicit type annotations in ambiguous contexts

Overview

This skill removes AI-generated "slop" from code diffs and pull requests to improve clarity, consistency, and maintainability while preserving exact behavior. It focuses on eliminating redundant patterns, over-verbosity, and needless abstractions so changes match the existing codebase style. Use it as part of code review to make LLM-produced edits review-ready.

How this skill works

The skill scans changed lines (git diff against main or a provided diff) and detects common LLM noise: redundant guards, verbose logging, single-use helpers, and explanatory comments that restate code. For each finding it proposes a minimal refactor or removal that preserves behavior and aligns with project idioms, and it verifies the change does not alter functionality. It highlights exceptions where defensive checks, linter-required comments, or justified abstractions must stay.

When to use it

  • Reviewing PRs with AI-generated changes or suggested patches
  • Cleaning up branch diffs before merging to main
  • Running a focused pass after an LLM refactor to remove verbosity
  • Checking a codebase for redundant checks and single-use wrappers
  • Preparing commits for maintainability and code review readiness

Best practices

  • Start by matching the existing code style and naming conventions in the repo
  • Use git diff main...HEAD or provide a focused diff to limit scope
  • Prefer removing or collapsing noise over replacing with clever abstractions
  • Always run tests or basic verification after each simplification to preserve behavior
  • Keep defensive checks at external boundaries and maintain required linter/documentation comments

Example use cases

  • Remove repetitive == true/== false comparisons and simplify conditionals
  • Replace single-use helper functions with inline code or direct calls
  • Remove debug prints and verbose entry/exit logs introduced by LLMs
  • Collapse redundant null/empty checks that the type system or prior validation already guarantees
  • Shorten over-descriptive identifiers and rename to match project naming style

FAQ

Will this change program behavior?

No. The rule is preserve behavior: simplifications only restructure or remove redundant code. Every change should be validated by tests or manual verification before merge.

What patterns are never removed?

Defensive checks at API boundaries, linter-required comments, essential logs for auditing, and abstractions justified for testing or future extension are preserved.

How do you ensure changes match the codebase?

The process begins by inspecting existing files for style, idioms, and naming. Proposals follow those conventions and aim to make new code look like it belongs to the project.