← 返回 Skills 市场
iliaal

ia-simplifying-code

作者 Ilia Alshanetsky · GitHub ↗ · v3.0.4 · MIT-0
cross-platform ✓ 安全检测通过
282
总下载
0
收藏
0
当前安装
11
版本数
在 OpenClaw 中安装
/install compound-eng-simplifying-code
功能描述
Simplifies, polishes, and declutters code without changing behavior. Use when asked to simplify, clean up, refactor, declutter, remove dead code or AI slop,...
使用说明 (SKILL.md)

Simplifying Code

Principles

Principle Rule
Preserve behavior Output must do exactly what the input did -- no silent feature additions or removals. Specifically preserve: async/sync boundaries (do not convert sync to async or reverse), error propagation paths (do not alter strategy), logging/telemetry/guards/retries that encode operational intent, and domain-specific steps (do not collapse into generic helpers that hide intent)
Explicit over clever Prefer explicit variables over nested expressions. Readable beats compact
Simplicity over cleanliness Prefer straightforward code over pattern-heavy "clean" code. Three similar lines beat a premature abstraction
Surgical changes Touch only what needs simplifying. Match existing style, naming conventions, and formatting of the surrounding code
Surface assumptions Before changing a block, identify what imports it, what it imports, and what tests cover it. Edit dependents in the same pass

Process

  1. Read first -- understand the full file and its dependents before changing anything. Apply Chesterton's Fence: if you see code that looks unnecessary but don't understand why it's there, check git blame before removing it. First understand the reason, then decide if the reason still applies.
  2. Identify invariants -- what must stay the same? Public API, return types, side effects, error behavior
  3. Identify targets -- find the highest-impact simplification opportunities. Impact = readability and maintainability; prioritize: control flow -> naming -> duplication -> types (see Smell -> Fix table)
  4. Apply in order -- control flow → naming → duplication → data shaping → types. Structural changes first, cosmetic last
  5. Verify -- confirm no behavior change: tests pass, types check, imports resolve
  6. Pre-submit scope audit -- walk every changed line and ask "does the requested task explicitly require this line?" If no, revert it and list it as a follow-up under Residual Risks. Drive-by edits belong in a separate change, not the current patch. For the pre-edit complement on ambiguous-scope requests ("simplify my project"), see ia-verification-before-completion's Scope Confirmation gate.

Smell → Fix

Smell Fix
Deep nesting (>2 levels) Guard clauses with early returns
Long function (>20 lines) Extract into named functions by responsibility
Too many parameters (>3) Group into an options/config object
Duplicated block (3+ occurrences) Extract shared function. Two copies = leave inline; wait for the third
Magic numbers/strings Named constants
Complex conditional Extract to descriptively-named boolean or function
Dense transform chain (3+ chained methods) Break into named intermediates for debuggability
Dead code / unreachable branches Delete entirely -- no commented-out code
Unnecessary else after return Remove else, dedent

AI Slop Removal

When simplifying AI-generated code, specifically target:

  • Redundant comments that restate the code (// increment counter above counter++) -- delete them
  • Unnecessary defensive checks for conditions that cannot occur in context -- remove the guard
  • Gratuitous type casts (as any, as unknown as T) -- fix the actual type or use a proper generic
  • Over-abstraction (factory for 2 objects, wrapper around a single call, util file with 1 function) -- inline the code
  • Inconsistent style that drifts from the file's existing conventions -- match the file
  • Placeholder stubs (// ..., // rest of code, // similar to above, // continue pattern, // add more as needed) -- leave unsimplified code as-is rather than replacing it with stubs
  • Redundant error wrapping (catch(e) { throw e; }, catch(e) { throw new Error(e.message); }) that strips the original stack for no reason -- remove the try/catch entirely and let errors propagate
  • Verbose stdlib reimplementations (hand-rolled loops that replicate array_filter, Array.from, Collection::pluck(), itertools) -- replace with the stdlib/framework one-liner

Stop Conditions

Stop and ask before proceeding when:

  • Simplification requires changing a public API (function signatures, return types, exports)
  • Behavior parity cannot be verified (no tests exist and behavior is non-obvious)
  • Code is intentionally complex for domain reasons (performance-critical, protocol compliance)
  • Scope implies a redesign rather than a simplification

Constraints

  • Only simplify what was requested -- do not add features, expand scope, or introduce new dependencies
  • Leave unchanged code untouched -- do not add comments, docstrings, or type annotations to lines that were not simplified
  • Do not bundle unrelated cleanups into one patch -- each simplification should be a coherent, reviewable unit
  • Do not introduce framework-wide patterns while simplifying a small local change
  • Do not replace understandable duplication with opaque utility layers -- three similar lines are better than a premature abstraction
  • Keep comments that explain intent, invariants, or non-obvious constraints. Remove comments that restate obvious code behavior.
  • If a simplification would make the code harder to understand, skip it
  • Watch for over-simplification: inlining too aggressively removes names that gave concepts meaning; combining unrelated logic into one function hides distinct responsibilities; removing abstractions that exist for testability breaks the test suite
  • When unsure whether a block is dead code, ask instead of deleting

Verify

  • Tests pass and types check after changes
  • No behavior change (same inputs produce same outputs)
  • Scope limited to requested files -- no drive-by cleanups

Orchestrator Mode (When Chained With Other Skills)

When this skill is invoked by an orchestrator that also runs ia-code-review, ia-writing-tests, or ia-verification-before-completion on the same scope, each sub-skill re-resolving scope independently wastes tokens and risks drift. Avoid this by resolving scope exactly once and passing a canonical block to every sub-skill.

Resolved scope format — the orchestrator builds this once, before dispatching any sub-skill:

## Resolved scope
Files:
- path/to/file-a.ts
- path/to/file-b.ts

Commit range: HEAD~3..HEAD (or "uncommitted")

Intent: [one-sentence description pulled from the user request or PR description]

Constraints:
- Preserve public API
- No behavior change
- [other constraints specific to this run]

Every chained sub-skill receives this block verbatim in its prompt and uses it as the source of truth — no re-running git diff --name-only, no re-parsing the user request, no independent scope resolution. Sub-skills accept --no-verify --no-report flags when chained so verification and reporting happen once at the end of the chain, not per-skill. The last sub-skill in the chain runs verification; the orchestrator trusts that result rather than re-verifying.

This prevents two failure modes: scope drift (sub-skill A simplifies one set of files, sub-skill B reviews a different set) and double work (every sub-skill rediscovers the same facts).

Integration

  • ia-code-simplicity-reviewer agent -- analysis-only pass producing a simplification report (no code changes). Use before refactoring to identify targets.

Output

After simplifying, report:

  • Scope touched: files and functions modified
  • Key simplifications: what changed and why (one line each)
  • Verification: tests pass, types check, no behavior change
  • Residual risks: assumptions made, areas not touched that may need attention
安全使用建议
This skill appears coherent and focused on code simplification. Before installing or invoking it: (1) ensure the agent will only be given access to repositories you want analyzed/modified (it expects to read code, run tests, and use git blame), (2) confirm no secrets or private tokens are present in the code you supply, and (3) review diffs produced by the agent (it includes stop conditions for public-API changes but you should still review any changes before committing).
功能分析
Type: OpenClaw Skill Name: compound-eng-simplifying-code Version: 3.0.4 The skill bundle (compound-eng-simplifying-code) provides a structured framework for an AI agent to refactor and simplify code. The instructions in SKILL.md emphasize behavior preservation, surgical changes, and the removal of 'AI slop' without introducing new features or dependencies. SPEC.md includes explicit security constraints against storing secrets, credentials, or PII, and the overall logic is strictly aligned with its stated purpose of code maintenance.
能力评估
Purpose & Capability
The name/description (simplify, polish, declutter code) matches the SKILL.md and SPEC.md. Requested actions (reading files, using git blame, running tests/type checks) are consistent with a code-simplification discipline and do not require unrelated credentials or tools.
Instruction Scope
SKILL.md instructs the agent to inspect full files, dependents, run tests, check git blame, and verify imports/types. This is appropriate for refactoring work but means the agent will need access to the repository and test/tooling context. There is no instruction to exfiltrate data or contact external endpoints, and it includes sensible stop conditions and scope gates.
Install Mechanism
No install spec and no code files are present (instruction-only). Nothing will be downloaded or written to disk by an installer, minimizing execution-time risk.
Credentials
The skill declares no required environment variables, credentials, or config paths. SKILL.md references local repo operations and tests only, which are proportionate to the stated purpose.
Persistence & Privilege
always is false, model invocation is allowed (normal). The skill does not request persistent system presence or to modify other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install compound-eng-simplifying-code
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /compound-eng-simplifying-code 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v3.0.4
v3.0.4
v3.0.3
v3.0.3
v3.0.2
v3.0.2
v3.0.1
v3.0.1
v3.0.0
v3.0.0
v2.56.1
v2.56.1
v2.56.0
v2.56.0
v2.55.1
v2.55.1
v2.55.0
v2.55.0
v2.53.2
v2.53.2
v2.53.0
v2.53.0
元数据
Slug compound-eng-simplifying-code
版本 3.0.4
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 11
常见问题

ia-simplifying-code 是什么?

Simplifies, polishes, and declutters code without changing behavior. Use when asked to simplify, clean up, refactor, declutter, remove dead code or AI slop,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 282 次。

如何安装 ia-simplifying-code?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install compound-eng-simplifying-code」即可一键安装,无需额外配置。

ia-simplifying-code 是免费的吗?

是的,ia-simplifying-code 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

ia-simplifying-code 支持哪些平台?

ia-simplifying-code 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 ia-simplifying-code?

由 Ilia Alshanetsky(@iliaal)开发并维护,当前版本 v3.0.4。

💬 留言讨论