AgentSkillsCN

deslop

清理代码中的 AI 生成冗余——删除不必要的注释、死代码、重复逻辑,并重命名以增强自文档性。适用于用户说“清理一下”、“去冗余”、“去除冗余”、“清理代码”、“删除不必要的注释”、“简化”、“代码卫生”、“打磨一下”、“去除噪音”或在代理生成的代码需要清理时。

SKILL.md
--- frontmatter
name: deslop
description: >
  Clean AI-generated slop from code — remove unnecessary comments, dead code,
  redundant logic, and rename for self-documentation. Use when the user says
  "clean this up", "deslop", "remove slop", "clean code", "remove unnecessary
  comments", "simplify", "code hygiene", "polish this", "remove noise", or
  after an agent has generated code that needs cleanup.
disable-model-invocation: true
allowed-tools: Read, Edit, Write, Glob, Grep
argument-hint: [file-or-directory]

Deslop

Strip AI-generated noise. Make code speak for itself.

1. Scope

If $ARGUMENTS specifies files or directories, use those. Otherwise, target files changed since last commit:

bash
git diff --name-only HEAD

If no uncommitted changes, use the last commit:

bash
git diff --name-only HEAD~1

Read every in-scope file before making any edits.

2. Remove

  • Comments restating what the code does ("what" comments, not "why" comments)
  • Outdated comments that no longer match the code
  • Comments masking unclear code -- fix the code instead of keeping the comment
  • Commented-out code blocks
  • Stale TODOs with no actionable context
  • Unused imports, variables, functions, types
  • Redundant type assertions the compiler already infers

3. Transform

  • Rename variables/functions for self-documentation instead of adding comments
  • Extract well-named functions instead of commenting code blocks
  • Flatten nesting with early returns
  • Make implicit behavior explicit

4. Preserve (DO NOT TOUCH)

  • "Why" comments explaining non-obvious decisions
  • External constraints, business rules, regulatory notes
  • Edge case warnings
  • Public API docs (godoc, JSDoc, docstrings)
  • License headers

5. Language-specific

  • Go: stale godoc restating the signature, // handle error noise, unjustified // nolint directives
  • Python: # type: ignore without reason, stale docstrings that contradict the signature
  • JS/TS: // eslint-disable without reason, @ts-ignore without reason
  • Rust: #[allow(dead_code)] on items that are actually used

6. Idempotency

Running deslop on already-clean code produces zero edits. Do not reformat, reorder, or restructure code that has no slop.

7. Arguments

$ARGUMENTS -- files or directories to clean. Default: uncommitted changed files.