オプション

このスキルは、ユーザーが「コードを簡素化してほしい」、「コードを整理してほしい」、「わかりやすさを重視してリファクタリングしてほしい」、「複雑さを軽減してほしい」、「可読性を向上させてほしい」、 「メンテナンスしやすくしてほしい」、あるいは最近変更されたコードを簡素化してほしいといった要望があった際に使用すべきです。

...すべて拡張します
71
更新された時間 2026年7月2日

概要code-simplify

「code-simplify 」スキルは、実行時の挙動、公開インターフェース、副作用、および動作意図を維持しつつ、既存のコードを簡素化するように設計されています。このスキルは、機能的な変更を加えることなく、開発者がコードの複雑さを軽減し、可読性を向上させ、メンテナンス性を高めることを支援します。 このスキルは、広範囲にわたる書き換えではなく、安全かつ的を絞ったリファクタリングに重点を置いており、入力、出力、エラー時の挙動、および外部から依存されている契約が安定した状態を維持されることを保証します。コードが理解しづらくなったり、過度にネストされたり、重複したり、不必要に複雑化したりしている状況での使用を想定しています。

このスキルは、ユーザーが指定した対象、最近変更されたファイル、またはリポジトリの変更に基づいて、適切な範囲を決定します。変更を行う前に、周囲のコンテキストを分析して動作のベースラインを確立します。 簡素化は、制御フローの平坦化、命名規則の明確化、重複の削減、密なデータ変換をより明確なステップへの再構成、および必要に応じて型や契約の明確化を含む、構造化されたプロセスを通じて行われます。このワークフローは、小規模で元に戻せる編集を重視し、既存のプロジェクト規約、リンター、フォーマッター、およびテストに従います。 安全ルールにより、同期APIを非同期APIに変換すること、運用上の安全策を削除すること、明示的な指示なしに外部インターフェースを変更することなど、動作を変更するような変更が防止されます。

このスキルは、機能を変えずにコード品質を向上させたいと考える、進化し続けるコードベースに取り組む開発者、メンテナー、およびチームにとって有用です。 一般的なユースケースとしては、最近変更されたコードの整理、可読性を高めるためのリファクタリング、複雑な関数における認知負荷の軽減、ネストされたロジックの簡素化、長期的なメンテナンスに向けたコードの準備などが挙げられます。特に、検証や動作の安定性が重要な要件となるリポジトリベースの開発ワークフローにおいて、このスキルは大きな価値を発揮します。

よくある質問

このスキルはどのような場合に使用すべきですか?

コードを簡素化したり、可読性を向上させたり、複雑さを軽減したり、最近変更されたコードを整理したり、動作を変更せずにコードの保守性を高めたい場合に使用してください。

このスキルは、アプリケーションの挙動やパブリックAPIを変更しますか?

いいえ。このスキルは、実行時の挙動、パブリック契約、副作用、入力、出力、および外部から依存されているエラーのセマンティクスを維持するように設計されています。

このスキルにはGitリポジトリが必要ですか?

はい。ワークフローは、リポジトリのコンテキストの確認から始まります。現在のディレクトリがGitリポジトリでない場合、処理は停止し、Gitリポジトリから実行するよう要求します。

このスキルは、どのファイルを変更するかをどのように決定しますか?

利用可能な場合は、ユーザーが指定した対象ファイルを使用します。そうでない場合は、セッションで変更されたファイルに焦点を当て、セッションで変更されたファイルが存在しない場合は、未コミットの追跡対象ファイルおよび追跡対象外のファイルにフォールバックすることがあります。

実行されるリファクタリングの種類に制限はありますか?

はい。このスキルは、動作を変更するような修正、大規模な書き換え、不必要な抽象化、同期APIと非同期API間の変更、およびロギング、テレメトリ、ガード、リトライ、その他の運用上重要なコードの削除を避けます。

GitHubで見る

Code Simplify

Objective

Simplify code while preserving behavior, public contracts, and side effects. Favor explicit code and local clarity over clever or compressed constructs.

Arguments

  • Paths, patterns, a commit/range, or a scope phrase: used in Scope Resolution step 2.
  • --no-report: Skip the full user-facing report and return terse working notes for the caller.
  • --no-verify: Skip verification because a parent orchestrator will verify the final result separately.
  • Default: verify touched behavior and present the full report.

Scope Resolution

Resolve scope once, then treat the result as fixed for the rest of the run.

  1. Verify repository context: git rev-parse --git-dir. If this fails, stop and tell the user to run from a git repository.
  2. If the request names targets — file paths/patterns, a commit/range, a natural-language subset (e.g. "the parser changes"), or a resolved-scope fenced block with one repo-relative path per line — scope is exactly those targets. Map natural-language subsets to concrete paths before continuing.
  3. Otherwise, scope is only session-modified files: files created or edited earlier in this session. Do not include other uncommitted changes.
  4. If there are no session-modified files, or earlier conversation history is not visible in this context, fall back to all uncommitted files, running each command once:
    • tracked: git diff --name-only --diff-filter=ACMR
    • untracked: git ls-files --others --exclude-standard
    • combine both lists and de-duplicate.
  5. Exclude generated/low-signal files unless explicitly requested: lockfiles, minified bundles, build outputs, vendored code.
  6. If scope resolves to zero files, report that and stop.
  7. Emit the scope as a fenced code block tagged resolved-scope, one repo-relative path per line. The block is authoritative: do not re-run scope commands or revisit exclusions afterward.

Operating Rules

  • Preserve runtime behavior exactly. Keep inputs, outputs, side effects, and error behavior stable.
  • Prefer project conventions over personal preferences. Infer conventions from existing code, linters, formatters, and tests.
  • Make small, reversible edits. Avoid broad rewrites when targeted simplifications solve the problem.
  • Call out uncertainty immediately when behavior may change.

Workflow

1) Determine Scope

  • Apply the Scope Resolution section.

2) Build a Behavior Baseline

  • Read surrounding context, not only changed lines.
  • Identify invariants that must not change:
    • function signatures and exported APIs
    • state transitions and side effects
    • persistence/network behavior
    • user-facing messages and error semantics where externally relied on
  • Note available verification commands (lint, tests, typecheck).

3) Apply Simplification Passes (in this order)

  1. Control flow:
    • Flatten deep nesting with guard clauses and early returns.
    • Replace nested ternaries with clearer conditionals.
  2. Naming and intent:
    • Rename ambiguous identifiers when local context supports safe renaming.
    • Separate mixed concerns into small helpers with intent-revealing names.
  3. Duplication:
    • Remove obvious duplication.
    • Abstract only when at least two real call sites benefit and the abstraction reduces cognitive load.
  4. Data shaping:
    • Break dense transform chains into named intermediate steps when readability improves.
    • Keep hot-path performance characteristics stable unless improvement is explicit and measured.
  5. Type and contract clarity:
    • Add or tighten type annotations when they improve readability and safety without forcing broad churn.
    • Preserve external interfaces unless asked to change them.

4) Enforce Safety Constraints

  • Do not convert sync APIs to async (or reverse) unless explicitly requested.
  • Do not alter error propagation strategy unless behavior remains equivalent and verified.
  • Do not remove logging, telemetry, guards, or retries that encode operational intent.
  • Do not collapse domain-specific steps into generic helpers that hide intent.

5) Verify

Skip when --no-verify is set. Otherwise verify per the Verification section below.

6) Report

Produce the Report section below.

Simplification Heuristics

  • Prefer explicit local variables over nested inline expressions when it reduces cognitive load.
  • Prefer one clear branch per condition over compact but ambiguous condition trees.
  • Keep function length manageable, but do not split purely for line count.
  • Keep comments that explain intent, invariants, or non-obvious constraints.
  • Remove comments that restate obvious code behavior.
  • Optimize for the next maintainer's comprehension time, not minimum character count.

Anti-Patterns

  • Do not perform speculative architecture rewrites.
  • Do not introduce framework-wide patterns while simplifying a small local change.
  • Do not replace understandable duplication with opaque utility layers.
  • Do not bundle unrelated cleanups into one patch.

Verification

Run the narrowest checks that validate touched behavior:

  • formatter/lint on touched files
  • targeted tests for touched modules
  • typecheck when relevant

Run broader checks only when risk warrants it. Name every skipped check and why.

Report

Skip when --no-report is set; return terse working notes instead: touched scope, key simplifications, residual risks.

Use these section headings, in this order. Omit sections that do not apply — do not number them and do not leave gaps or placeholders.

Scope

Files and regions changed.

Simplifications

One sentence per meaningful change, focused on the readability or maintainability gain. Confirm behavior-preservation assumptions explicitly.

Verification

Commands run and outcomes, including skipped checks.

Residual Risks

One line per risk: Assumed <assumption>; if wrong, <what breaks>; check via <command or inspection>. Plain language — expand or gloss domain-specific terms. Include questions that need a user decision, phrased directly. Write None. when there are none.

Stop Conditions

Stop and ask for direction when:

  • simplification requires changing public API/contracts.
  • behavior parity cannot be confidently verified.
  • the code appears intentionally complex due to domain constraints.
  • the requested scope implies a larger redesign rather than simplification.

すべてのファイル

1件のファイル

code-simplifyをインストール

スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/PaulRBerg/agent-skills/blob/main/skills/code-simplify/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: skill フォルダを .claude/skills/ にコピーしてください。Claude が自動的にスキルを検出して使用します。
リポジトリ paulrberg/agent-skills

関連スキル

requesting-code-review
更新された時間 2026年6月29日
Git Commit Helper
更新された時間 2026年6月29日
commit-standards
更新された時間 2026年6月29日
fetch-pr-review-comments
更新された時間 2026年6月29日
OR