deslop-simplify-ai-code
Deslop: Simplify 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. Match existing code style, naming conventions, and patterns in the codebase.
Workflow
- Understand project context: Review existing code style, patterns, and conventions in the codebase
- Get the code to review: via
git diff, PR review, file selection, or paste — don't assume branch naming or tooling - Identify slop patterns across the entire file if it's been touched
- Simplify: Remove or refactor each instance to match project idioms
- Verify: Run tests if available. If not, review the diff carefully and manually verify behavior. For frontend code, visually verify UI still renders correctly. Provide a summary report of what changed and why.
Slop Patterns
Comments
Rule: Prefer WHY over WHAT.
Remove:
- Comments restating what code does:
// increment counterabovecounter++ - Section dividers:
// ========== VALIDATION ========== - Redundant docstrings documenting self-evident parameters
- "Note:" or "Important:" prefixes that add nothing
- Comments explaining language basics
Carve-out: WHAT comments are acceptable for:
- Complex regex patterns
- Non-obvious bit manipulation
- Mathematical formulas where the code IS the implementation
- Cases where the logic genuinely can't be simplified further
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()
Also watch for:
- Swallowed errors:
try { ... } catch { }— at minimum log it, ideally handle or propagate - Generic error messages:
catch (e) { throw new Error("Something went wrong") }— preserves no context; include the original error or relevant details - Error string parsing: checking
error.message === "not found"instead of using error types, codes, or structured error objects
Abstractions
Flatten unnecessary layers — but match the codebase's testing patterns:
- In Python/JS/TS: prefer direct calls; use monkey-patching or test fixtures for mocking
- In Java/C#: interfaces and wrapper classes are idiomatic for testability via DI — keep if they serve that purpose
- In Go: keep if it implements an interface for testing; flatten otherwise
General rule: remove abstractions that do nothing AND aren't required by the language/framework. Keep if there are 2+ callers or a test that depends on it.
Watch for:
- 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/== falsecomparisons- Intermediate variables used once
if x: return true; else: return false→return x- Unnecessary destructuring then reassembly
- Unused imports, wildcard imports (
import *), importing entire libraries for one function
Naming
Fix over-descriptive names:
userDataResponseObject→userisCurrentlyProcessingData→processinghandleOnClickButtonEvent→onClick
Structure
Remove:
- Constructors that do nothing AND aren't required by the language/framework
- Getters/setters that just proxy fields
- Interfaces implemented by one class
- Abstract classes with one child
- Enums with one value
Logs/Debug
Remove:
- Bare
print()/console.log()/System.out.println()debug statements - Verbose entry/exit logging:
Entering function X with params... - Success logs that spam output:
Successfully processed item 1 of 10000
Keep:
- Structured logging with levels (
logger.debug(...)) — these are controlled by log level config and useful for ops/debugging - Error logging with context
- Audit logs for important operations
Review Checklist
Must Fix
- Does this comment explain WHY, not WHAT? (with carve-outs for complex logic)
- Is this null check protecting against something that can actually happen?
- Could this be expressed more directly?
Should Fix
- Does this abstraction earn its complexity? (consider language context)
- Is this name proportional to the scope?
Nice to Have
- Does this match existing patterns in the codebase?
- 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, including testing patterns
- 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 there's a concrete existing use case — not hypothetical)
- Explicit type annotations in ambiguous contexts
- Structured debug-level logging (
logger.debug(...))
More from adibfirman/dotfiles
react-native-best-practices
Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.
20js-ts-fp
Write TypeScript and JavaScript code like a top engineer using functional programming principles. Use when writing new code, reviewing existing code, or refactoring TS/JS projects. Applies pure functions, immutability, function composition, higher-order functions, declarative style, and avoiding shared state using native patterns only (no external libraries). Always analyzes the existing codebase first to understand patterns and conventions before making changes or suggestions.
17ui-engineer
Act as a UI engineer to iterate on design details and produce production-grade frontend interfaces. Use when the user provides a PRD (Product Requirements Document) or an existing concept app and wants to refine the UI through clarifying questions before implementation. Outputs HTML/CSS with Tailwind, optional vanilla JS. Focuses on minimalist aesthetics, semi-bold typography, responsive design, and avoids generic AI look, excessive icons, or emojis.
14grill-me
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
1golang-samber-hot
In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports github.com/samber/hot, or when the project repeatedly loads the same medium-to-low cardinality resources at high frequency and needs to reduce latency or backend pressure.
1context7-mcp
This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.
1