Note: This is the local fallback version. During installation, it will automatically attempt to fetch the latest version from the official Anthropic repository.
Overview
Code Simplifier is a skill focused on code quality optimization, helping you improve your code'sclarity、consistencyandmaintainability, without changing functional behavior.
Use Cases
This skill applies to the following situations:
- Code review and refactoring
- Improving code readability
- Unifying code style
- Simplifying complex logic
- Improving code organization
5 Core Principles
1. Keep functionality unchanged
- Focus: Optimize code quality only, do not change business logic
- Verification: Ensure behavior after refactoring is exactly the same as the original code
- Testing: Recommend running tests to verify after refactoring
2. Apply project standards
- Reference: Prioritize following the project's
CLAUDE.mdcoding standards - Consistency: Keep consistent with the existing codebase style
- Flexibility: If the project has no explicit standards, use general best practices
3. Enhance clarity
- Naming: Use meaningful variable names and function names
- Structure: Reduce nesting levels, use guard clauses
- Conciseness: Eliminate redundant code and unnecessary complexity
4. Maintain balance
- Moderate optimization: Avoid over-engineering
- Performance considerations: Do not sacrifice significant performance for minor readability gains
- Pragmatism: Find a balance between ideal and reality
5. Focus scope
- Clear boundaries: Only optimize the explicitly specified code portions
- Avoid spreading: Do not proactively refactor code not involved
- Incremental improvement: Support gradual optimization rather than one-time large-scale refactoring
Workflow
Step 1: Understand the context
- Read the project's
CLAUDE.md(if it exists) to learn the coding standards - Analyze the style and patterns of the existing code
- Identify the tech stack and frameworks used by the project
Step 2: Identify optimization points
Scan the code for the following issues:
- Deeply nested conditional statements
- Complex ternary expressions
- Vague variable naming
- Duplicated code logic
- Overly long functions or components
- Inconsistent code style
Step 3: Evaluate impact
Evaluate each potential optimization:
- Benefit: The degree of improvement in readability and maintainability
- Risk: The likelihood of introducing bugs
- Cost: The complexity and scope of impact of the changes
Step 4: Propose improvement plans
- Clearly explain the goals and rationale of the improvement
- Provide before-and-after code comparisons
- Explain how the improvement conforms to project standards
- Flag any potential impacts that need attention
Step 5: Implement optimizations
Implement in order of priority:
- Safe improvements: Zero-risk obvious optimizations (such as variable renaming)
- Structural optimization: Reduce nesting, extract functions
- Style consistency: Align with project coding standards
Step 6: Verify results
- Confirm code functionality is unchanged
- Check conformity with project standards
- Recommend running relevant tests
Auto-trigger
This skill activates automatically in the following situations:
- The user requests "simplify code", "optimize code", "refactor code"
- The user mentions "improve readability", "improve code quality"
- The user requests "code review" or "code cleanup"
- Explicitly invoke the
/code-simplifiercommand
Reference resources
The skill package provides the following supplementary resources (located in the references/ directory):
- CLAUDE.md-example.md: Example project coding standards configuration
- coding-standards.md: General coding standards reference
- simplification-examples.md: Collection of real-world code simplification cases
It is recommended to review these resources before using this skill to better understand best practices.
Usage examples
User: "Help me simplify this code"
function getUserStatus(user) {
if (user) {
if (user.isActive) {
if (user.isPremium) {
return 'premium-active';
} else {
return 'basic-active';
}
} else {
return 'inactive';
}
} else {
return 'unknown';
}
}
Code Simplifier: I will use guard clauses to reduce nesting levels and improve readability:
function getUserStatus(user) {
if (!user) return 'unknown';
if (!user.isActive) return 'inactive';
return user.isPremium ? 'premium-active' : 'basic-active';
}
Improvement points:
- Use guard clauses to return early and reduce nesting
- Keep functionality completely identical
- Code is more concise and readable
License
This skill is based on the official Anthropic code-simplifier plugin and follows its license agreement.
More information
- Upstream source: anthropics/claude-plugins-official
- Package homepage: @adonis0123/code-simplifier