跳到正文
Skillpedia
通用编程48k · #5784

simplify-code

它能做什么

这个工具会检查刚修改过的代码片段。它会寻找简化代码、让代码更易读、并确保代码正确运行的方法,并且只应用安全的修改。

适用场景

  • ✓当你想简化刚刚改动过的代码时。
  • ✓当你希望确保代码修改清晰且安全时。
  • ✓当你想检查或整理某一段特定代码时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/simplify-code/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/simplify-code/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查这段代码,如果可以的话进行简化。”

每周 5 个新技能,1 分钟读完。

工作原理

该工具会使用多个较小的“人工智能”从不同角度分析代码,包括复用性、质量、效率和清晰度。然后,它只会提出或应用最安全的修改,确保不改变原有功能。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Simplify Code

Review changed code for reuse, quality, efficiency, and clarity issues. Use Codex sub-agents to review in parallel, then optionally apply only high-confidence, behavior-preserving fixes.

When to Use

  • When the user asks to simplify, clean up, refactor, or review changed code.
  • When you want high-confidence, behavior-preserving improvements on a scoped diff.

Modes

Choose the mode from the user's request:

  • review-only: user asks to review, audit, or check the changes
  • safe-fixes: user asks to simplify, clean up, or refactor the changes
  • fix-and-validate: same as safe-fixes, but also run the smallest relevant validation after edits

If the user does not specify, default to:

  • review-only for "review", "audit", or "check"
  • safe-fixes for "simplify", "clean up", or "refactor"

Step 1: Determine the Scope and Diff Command

Prefer this scope order:

  1. Files or paths explicitly named by the user
  2. Current git changes
  3. Files edited earlier in the current Codex turn
  4. Most recently modified tracked files, only if the user asked for a review but there is no diff

If there is no clear scope, stop and say so briefly.

When using git changes, determine the smallest correct diff command based on the repo state:

  • unstaged work: git diff
  • staged work: git diff --cached
  • branch or commit comparison explicitly requested by the user: use that exact diff target
  • mixed staged and unstaged work: review both

Do not assume git diff HEAD is the right default when a smaller diff is available.

Before reviewing standards or applying fixes, read the repo's local instruction files and relevant project docs for the touched area. Prefer the closest applicable guidance, such as:

  • AGENTS.md
  • repo workflow docs
  • architecture or style docs for the touched module

Use those instructions to distinguish real issues from intentional local patterns.

Step 2: Launch Four Review Sub-Agents in Parallel

Use Codex sub-agents when the scope is large enough for parallel review to help. For a tiny diff or one very small file, it is acceptable to review locally instead.

When spawning sub-agents:

  • give each sub-agent the same scope
  • tell each sub-agent to inspect only its assigned review role
  • ask for concise, structured findings only
  • ask each sub-agent to report file, line or symbol, problem, recommended fix, and confidence

Use four review roles.

Sub-Agent 1: Code Reuse Review

Review the changes for reuse opportunities:

  1. Search for existing helpers, utilities, or shared abstractions that already solve the same problem.
  2. Flag duplicated functions or near-duplicate logic introduced in the change.
  3. Flag inline logic that should call an existing helper instead of re-implementing it.

Recommended sub-agent role: explorer for broad codebase lookup, or reviewer if a stronger review pass is more useful than wide search.

Sub-Agent 2: Code Quality Review

Review the same changes for code quality issues:

  1. Redundant state, cached values, or derived values stored unnecessarily
  2. Parameter sprawl caused by threading new arguments through existing call chains
  3. Copy-paste with slight variation that should become a shared abstraction
  4. Leaky abstractions or ownership violations across module boundaries
  5. Stringly-typed values where existing typed contracts, enums, or constants already exist

Recommended sub-agent role: reviewer

Sub-Agent 3: Efficiency Review

Review the same changes for efficiency issues:

  1. Repeated work, duplicate reads, duplicate API calls, or unnecessary recomputation
  2. Sequential work that could safely run concurrently
  3. New work added to startup, render, request, or other hot paths without clear need
  4. Pre-checks for existence when the operation itself can be attempted directly and errors handled
  5. Memory growth, missing cleanup, or listener/subscription leaks
  6. Overly broad reads or scans when the code only needs a subset

Recommended sub-agent role: reviewer

Sub-Agent 4: Clarity and Standards Review

Review the same changes for clarity, local standards, and balance:

  1. Violations of local project conventions or module patterns
  2. Unnecessary complexity, deep nesting, weak names, or redundant comments
  3. Overly compact or clever code that reduces readability
  4. Over-simplification that collapses separate concerns into one unclear unit
  5. Dead code, dead abstractions, or indirection without value

…

常见问题

什么是“diff”?

“diff”是一种对比,用来显示两个版本文件或文件集之间的差异。你可以把它理解为能看到具体做了哪些改动。

“应用安全修改”是什么意思?

意思是该工具只会做出很可能不会破坏任何功能、也不会改变程序预期行为的代码修改,它会避开有风险的改动。

为什么这个工具要使用“子智能体”?

使用子智能体后,不同的“专家”可以并行进行代码审查,同时覆盖代码的多个方面,因此过程更快,也更全面。

详情

作者的原始描述

Review a diff for clarity and safe simplifications, then optionally apply low-risk fixes.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5784
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能