本文へスキップ
Skillpedia
APIとサーバー(バックエンド)48k · #5617

repo-native-refactor

できること

このツールは、プログラムのコードを安全にレビューして整理するためのものです。エラーがないかを確認し、コードが期待どおりに動き続けるようにしながら、中心となる動作を変えずに小さな改善を行います。

使う場面

  • ✓AIにコードをレビューしてもらいたいが、コードは変更してほしくないとき。
  • ✓すでに動いているコードに、小さな修正を加えたいとき。
  • ✓コードの中で繰り返し書かれている部分を整理したり、簡潔にしたりしたいとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/repo-native-refactor/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/repo-native-refactor/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このコードを確認して、重要な部分が壊れていないかチェックし、簡単に改善できる点があれば教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは、セキュリティ、動作、構成に関するルールと照らし合わせながらコードを分析します。エラーの修正と、すでに正しく動いている部分の維持を優先し、必要かつ安全な変更だけを行います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Repo-native refactor

When to Use

  • Use when the user asks to review a diff, branch, or PR for correctness, contract breaks, or operational risk.
  • Use when the user authorizes bounded cleanup before opening a PR or asks to consolidate duplicated policy with shared ownership.
  • Use for repository rehabilitation only when the user explicitly requests work across multiple domains.
  • Establish review-only, edit, or combined authority before choosing the operating mode.

Produce the smallest coherent change that belongs naturally in the target repository.

Prioritize in order:

  1. Correctness and security: prevent regressions, avoid new security vulnerabilities, handle boundary conditions.
  2. Semantic integrity: preserve existing invariants, state transitions, validation, and error boundaries.
  3. Contracts stay as declared: the rule lives in references/shared-contracts.md §1. Preserve the authorized target contract; otherwise keep exact declared types. Internal helpers are fine when exposed contracts stay exact.
  4. Repository conformity: match surrounding naming, domain conventions, and architectural precedents.
  5. Economy and simplicity: minimal intervention. Delete dead weight, avoid premature abstractions.

This is a post-implementation audit and small cleanup skill. It is not permission to redesign the repository. Establish a concrete consequence such as inconsistent behavior, duplicated policy that must change together, unclear ownership, avoidable resource cost, or a demonstrated maintenance obstacle. Leave healthy code unchanged when the benefit is speculative.


Minimal intervention and evidence gate

  • Evidence-based intervention: refactor only with concrete evidence of divergence, defect, or operational risk. If greenfield code or an additive diff is already minimal, idiomatic, and passing, leave it. A pattern you recognize is a candidate finding, not a reason to change anything.
  • Semantic DRY (Cost-benefit consolidation): merge duplicated logic only when the copies share an owner, an invariant, and a reason to change, and only if merging saves more than it costs. Leave similar-looking checks in separate domains alone, and keep small local duplication when merging would obscure ownership.
  • Contract boundary protection: preserve public interfaces, parameter names, and return types, except where the task clearly authorizes the change. During cleanup, keep the authorized target contract; don't revert to the old one.

Operating modes

  • Review vs. Refactor Authority: first establish the outcome: findings, edits, or both. Review-only means inspection and verification, no source edits. Authorized cleanup allows bounded corrections; don't ask approval again for routine choices.
  • Change-set cleanup: for a working tree, branch, commit range, feature, or bounded checkpoint. Work diff-first; read surrounding code only to understand ownership, contracts, and precedent.
  • Repository rehabilitation: only when explicitly requested across multiple domains. Read repository rehabilitation, build a short profile, and work in batches you can verify independently.

Evidence hierarchy

Use the evidence hierarchy to guide investigation, not to resolve material contradictions automatically. Reconcile conflicting requirements, documentation, callers, and tests before changing the affected contract. When repository patterns conflict, resolve in order:

  1. User requirements and explicitly authorized scope.
  2. Documented architecture and repository guidelines.
  3. Observable public contracts and persisted schemas.
  4. Healthy sibling code within the same domain and runtime boundary.
  5. Relevant tests, schemas, callers, and dependencies.
  6. Dominant local conventions.
  7. Language and runtime idioms.
  8. Conservative, idiomatic defaults.

Never treat a temporary workaround, buggy sibling, or accidental pattern as precedent.


Workflow

1. Establish scope and baseline

Before mutating code, identify:

  • Comparison base and working-tree state.
  • In-scope files vs. untouched user modifications.
  • Existing verification commands and their current pass/fail status.

Differentiate pre-existing failures from regressions introduced by this pass. Never claim a check ran when it did not.

2. Establish intent, ownership, and preservation

Refactoring is behavior-preserving by default. Protect:

…

よくある質問

AIがコードを全面的に書き換えることはありますか?

いいえ。主な目的はレビューと小さな整理です。大規模な変更や設計のつくり直しは、主な目的ではありません。

「authorized contracts(承認済みの約束事)を維持する」とはどういう意味ですか?

ルールや、コードが他の部分とやり取りする方法(「公開インターフェース」と呼ばれます)を変えないことを意味します。ただし、変更を明示的に許可した場合は別です。

AIは使われていないコードを削除しますか?

安全で妥当だと判断できる場合は、不要なコードを削除してシンプルにすることがあります。

詳細

作者による元の説明

Review diffs without editing, or perform evidence-based cleanup while preserving authorized behavior, public contracts, and domain ownership.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#5617
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル