AgentSkillsCN

code-simplifier

在保留全部功能的前提下,简化并优化代码,提升其清晰度、一致性与可维护性。

SKILL.md
--- frontmatter
name: code-simplifier
description: Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality
allowed-tools: Read, Write, Edit, Glob, Grep
version: 1.0
priority: MEDIUM

Code Simplifier

Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.


Core Rules

RuleDescription
Preserve FunctionalityNever change what the code does — only how it does it
Clarity Over BrevityExplicit, readable code beats overly compact solutions
Minimal ScopeOnly refine recently modified code unless told otherwise
No Over-SimplificationDon't remove helpful abstractions or combine too many concerns

Project Standards

StandardConvention
ModulesES modules with proper import sorting
FunctionsPrefer function keyword over arrow functions for top-level
Return TypesExplicit return type annotations for top-level functions
React ComponentsExplicit Props types, proper component patterns
Error HandlingAvoid try/catch when possible, prefer Result patterns
NamingClear, consistent naming conventions

Simplification Targets

TargetAction
Unnecessary complexityReduce nesting, flatten logic
Redundant codeEliminate dead code and duplicate abstractions
Unclear namingImprove variable and function names
Scattered logicConsolidate related code
Obvious commentsRemove comments that describe what code already says
Nested ternariesReplace with switch or if/else chains
Dense one-linersExpand for readability when clarity suffers

Anti-Patterns (DON'T)

Don'tWhy
Reduce clarity for fewer linesReadability > line count
Create clever one-linersOthers must understand it
Remove helpful abstractionsGood abstractions aid maintenance
Combine too many concernsSingle responsibility matters
Auto-fix without contextUnderstand intent first
Touch untouched codeStay scoped to recent changes

Refinement Process

  1. Identify recently modified code sections
  2. Analyze for clarity, consistency, and simplification opportunities
  3. Apply project-specific best practices and coding standards
  4. Verify all functionality remains unchanged
  5. Confirm refined code is simpler and more maintainable

Self-Check Before Completing

CheckQuestion
Functionality intact?Does the code still do exactly the same thing?
More readable?Is the refined code easier to understand?
Standards followed?Does it match project conventions?
Scope respected?Did I only touch recently modified code?
No regressions?Are imports, types, and dependencies still correct?