# Code Simplifier

> Use when code has excessive complexity, deep nesting, unused abstractions, or violates YAGNI/KISS/DRY principles and needs simplification or cleanup

- **Type:** Skill
- **Install:** `agentstack add skill-unix2dos-skills-code-simplifier`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [unix2dos](https://agentstack.voostack.com/s/unix2dos)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [unix2dos](https://github.com/unix2dos)
- **Source:** https://github.com/unix2dos/skills/tree/main/code-simplifier

## Install

```sh
agentstack add skill-unix2dos-skills-code-simplifier
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Code Simplifier

简化和优化代码，在保持功能不变的前提下降低复杂度、提升可维护性。适用于任何编程语言。

## When to Use
- 代码嵌套过深、圈复杂度过高
- 存在明显的 YAGNI 违规（为"可能"的需求写的代码）
- 重复代码、冗余检查、未使用的抽象
- 需要"减法"：删代码、砍抽象、inline 只用一次的函数

## When NOT to Use
- 需要改接口签名、拆模块、引入设计模式 → 用 **code-refactor**
- 需要审查安全/并发问题 → 用 **go-code-review**
- 代码结构没问题，只是需要扩展新功能 → 直接写代码

## Core Principles

### YAGNI (You Aren't Gonna Need It)
- Remove features not explicitly required now
- Eliminate extensibility points without clear use cases
- Question generic solutions for specific problems
- Remove "just in case" code

### KISS (Keep It Simple, Stupid)
- Prefer simple solutions over clever ones
- Replace complex logic with straightforward implementations
- Make the common case obvious
- Avoid premature optimization

### DRY (Don't Repeat Yourself)
- Identify and consolidate duplicate code patterns
- Extract common logic into reusable functions
- Eliminate redundant error checks and validations

### Cyclomatic Complexity Control
- Keep function cyclomatic complexity ≤ 10
- Break down complex functions into smaller, focused units
- Use early returns to reduce nesting depth
- Simplify conditional logic wherever possible

## Operating Modes

### Analysis Mode (分析模式)
When asked to review or analyze code, provide a structured assessment:
- Identify the core purpose of the code
- List complexity issues and potential simplifications
- Highlight YAGNI violations
- Estimate potential lines of code reduction
- Prioritize recommendations by impact

### Execution Mode (执行模式)
When asked to simplify or refactor code, directly make changes:
- Preserve all original functionality
- Apply simplifications based on analysis
- Ensure code remains readable and maintainable
- Document only significant changes

## Simplification Strategies

1. **Reduce Nesting**
   - Use early returns/guard clauses
   - Flatten deeply nested conditionals
   - Extract complex conditions into named functions

2. **Simplify Logic**
   - Replace nested ternaries with switch/if-else
   - Break down complex conditionals
   - Use table-driven logic when appropriate

3. **Remove Redundancy**
   - Eliminate duplicate error checks
   - Consolidate repeated patterns
   - Remove commented-out code
   - Delete unused imports/variables

4. **Challenge Abstractions**
   - Question every interface and abstraction layer
   - Inline code that's only used once
   - Remove over-engineered solutions
   - Suggest removing premature generalizations

5. **Optimize for Readability**
   - Use descriptive names over comments
   - Prefer explicit code over clever shortcuts
   - Simplify data structures to match actual usage
   - Make intent clear through naming

## Language-Specific Guidance

When working with **Go**:
- Follow Effective Go principles
- Adhere to Uber Go Style Guide recommendations
- Use idiomatic Go patterns (error handling, interfaces, etc.)
- Prefer simplicity and explicit code

For other languages:
- Adapt to the language's established idioms
- Follow community-accepted style guides
- Respect project-specific conventions when present

## 工作流程

1. **理解**：识别代码的实际职责
2. **分析**：找出复杂度、冗余和 YAGNI 违规
3. **排优先级**：按影响大小排序简化机会
4. **执行**：分析模式给建议，执行模式直接改
5. **验证**：确保功能不变、代码更简单

输出使用中文。

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [unix2dos](https://github.com/unix2dos)
- **Source:** [unix2dos/skills](https://github.com/unix2dos/skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-unix2dos-skills-code-simplifier
- Seller: https://agentstack.voostack.com/s/unix2dos
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
