Claude Code、スキルで検証ループ構築
Anthropic は Claude Code に「スキル」機能を追加し、コード実行結果の自己検証ループを構築可能にして開発効率と信頼性を向上させた。
キーポイント
スキル機能の導入
Claude Code に「スキル」という新たな機能を追加し、特定のタスクやワークフローを定義・実行できる能力を持たせた。
自己検証ループの実現
生成されたコードを実行し、その結果を検証するループを構築することで、エラーの早期発見と修正を自動化可能にした。
開発効率と信頼性の向上
手動でのデバッグや確認プロセスが削減され、AI によるコード生成の精度と信頼性が大幅に高まることを目指している。
重要な引用
Anthropic は Claude Code に「スキル」機能を追加し、コード実行結果の自己検証ループを構築可能にした。
これにより開発効率と信頼性が向上する。
影響分析・編集コメントを表示
影響分析
この発表は、単なるコード生成ツールから、自律的に実行と検証を行う「開発エージェント」へと進化させる重要な転換点です。自己検証ループの実現により、AI によるコーディングの信頼性が飛躍的に向上し、実務レベルでの採用ハードルが下がる可能性があります。
編集コメント
Claude Code の「スキル」機能と自己検証ループの追加は、AI エージェントが単なる提案者から実行・修正可能な実行者へと進化することを示す画期的な進展です。開発現場における AI の信頼性を高めるこのアプローチは、今後のソフトウェア開発ワークフローを根本から変える可能性があります。
スキルとして実装する
反復的な手順を検証ループに組み込む最も一般的な方法は、それを スキル として記述することです。スキルの作成を最速で行うには、スキル作成プラグインをインストールして Claude にインタビューさせるのが効果的です。
例:
/skill-creator Create a skill for verifying frontend changes end-to-end. Interview me about my workflow.
プロジェクト内の .claude/skills/ ディレクトリに Markdown ファイルを配置するだけで、手書きでスキルを作成することも可能です。最もシンプルな検証スキルの構成は、フロントマター数行と本文から成り立ちます。
# .claude/skills/verify-log-hygiene/SKILL.md
---
name: verify-log-hygiene
description: Check that error logs include the request ID and never
include the request body. Use when the diff touches error handling
or logging.
allowed-tools: [Read, Edit, Grep]
---
Read the error-handling paths in the current diff.
For each log call on an error path, confirm it includes the request ID
and does not pass the request body, headers, or any user-supplied payload.
Report each violation with file:line, then fix it: add the request ID
where it's missing and strip the payload from the log call.スキルの完全なスキーマと、その背後にある哲学については、スキル構築の完全ガイド をご覧ください。
検証ループの動作場所を特定する
次に決めるべきは、この検証ループがどのように起動するかです。スタンドアロン型か、埋め込み型か、連鎖型か、それとも PR(プルリクエスト)に紐付けるのか。
スタンドアロン型
これは、アーティファクトが完成した後に意図的に呼び出すタイプです。すべてのケースで適用されるわけではない横断的なチェックのために、スタンドアロンスキルが選ばれます。具体的には、コミット前のセキュリティスキャンや、PR 提出前のアクセシビリティ監査、リポジトリ全体にわたるライセンスヘッダーの検証などが該当します。
多くのワークフローで利用可能にしたいが、コード変更ごとに自動実行したくない処理をここに設定します。
ただし欠点として、呼び出すたびに自分で起動する必要があるという手間がかかります。スタンドアロン型から脱却すべきタイミングは、「すべての変更後に実行している」という状態になった時です。その段階では、この手順は恒久的な場所を得るべきであり、埋め込むか連鎖させるかの選択が必要です。
埋め込み型
これは、生成を行うスキルの一環として自動的に起動するタイプです。特定のワークフローにのみ属し、ユーザーが指示しなくてもそのワークフローが実行します。
最もシンプルな実装は、生成スキルの本体に対して 1 行を追加するだけです。
# .claude/skills/scaffold-component/SKILL.md
---
name: scaffold-component
description: src/components/配下に新しい React コンポーネントをスキャフォールドします。コンポーネントファイル、それに付随するテスト、および index エクスポートを含みます。ユーザーが新規コンポーネントの作成を求めた際に使用してください。
allowed-tools: [Read, Write, Edit, Bash, Glob]
---
# 新しい React コンポーネントのスキャフォールド
コンポーネント名(PascalCase 形式)を受け取り、`src/components/<Name>/`配下に以下のファイルを作成します:<Name>.tsx:型付きプロパティインターフェースを持つ関数コンポーネントであり、デフォルトエクスポートを含みます。<Name>.test.tsx:React Testing Library を用いたテストで、コンポーネントをレンダリングし、エラーなくマウントされることを検証します。index.ts:デフォルトエクスポートと名前付きエクスポートを再エクスポートします。
参考として src/components/Button/ ディレクトリ内のパターンに従ってください。コードベース全体で統一されているインポートエイリアスのスタイル(@/components/...)も合わせて準拠してください。
code continues...
コンポーネントファイルを作成した後、eslintrc に基づいて lint を実行し、報告する前にエラーをすべて修正してください。
スキルを実行して埋め込みが機能しているか確認するには、新しいタスクでそのスキルを呼び出し、出力に新しいステップとして追加されたことが確認できるかを検証します。もし動作しない場合は、スキルの説明や以前の指示において、追加されたチェックが正しく反映されていない可能性があります。
このパターンで利用可能な埋め込みは、編集可能なスキルに限られます。つまり、自分で作成したスキルか、プロジェクトレベルでインストールされ、SKILL.md ファイルの管理権限を持つものです。組み込みスキルやプラグイン経由で管理されるスキル(更新時に上書きされるタイプ)はこのパターンの対象外です。それらの場合は、代わりにチェーン処理を使用してください。
ワークフロー全体にわたるチェックには埋め込みをスキップし、スタンドアロンの形式を採用します。これにより、あらゆるコンテキストから呼び出しが可能になります。
Chained(連鎖型)
一つのスキルが終了時に別のスキルを呼び出し、複数の検証済みハンドオフがエンドツーエンドで実行されます。
Anthropic の Claude Code チームでは、このパターンを日常業務で活用しています。具体的には、/code-review でバグを検出し、/simplify で差分を整理し、/verify スキルでエンドツーエンドの動作を確認します。また、UI に関わる変更がある場合は、カスタムの /design スキルを使って DESIGN.md ファイルに記載されたガイドラインに合致しているかチェックします。
修正できないスキルに対して検証機能を追加したい場合も、この連鎖(チェーン)が役立ちます。元のスキルを呼び出した上で、さらに検証用スキルを呼ぶカスタムラッパーを作成すればよいのです。以下のように実装できます:
.claude/skills/safe-refactor/SKILL.md
現在の差分に対してまず /simplify を実行します。
/simplify が完了したら、/verify-no-public-api-changes を呼び出します。
「/simplify の後に必ず /verify を実行する」という習慣が、「/simplify は完了時に必ず /verify を実行する」という契約へと進化します。この連鎖によって開発サイクル全体を自動化でき、問題が発生してユーザーにエスカレートした場合のみ、人が介入すればよいのです。
各ステップが独立しており、片方だけを単独で実行したい場合もある場合は、連鎖をスキップすることも可能です。ただし、連鎖は柔軟性を犠牲にして自動化を実現するトレードオフがあるため注意が必要です。検証ループの連鎖を実行するとトークン使用量が増える可能性があるため、広く展開する前に必ずテストを行ってください。
すべての PR で
自分の変更に対してチェーンが確立されれば、同じ手順をすべてのプルリクエスト(PR)に適用できます。チームメンバーの変更も、自分が行った変更と同じゲートを通過します。本人がチェーンの呼び出しを忘れたとしても、結果は変わりません。このインフラストラクチャは、すでに作成したチェーンと基本的に同じものです。ただし、一歩進んだ段階であり、著者の努力や注意に依存せずとも、同じスキル、同じ評価基準、そして同じ品質基準が適用されます。
ここで検証プロセスは、個人のインフラからチーム全体のインフラへと進化します。大規模コードベースにおける Claude Code の運用で解説されているような、チーム全体での活用が可能な状態です。週に 2 分節約するために作成したチェック項目が、今やすべての変更において全員の時間を節約する仕組みへと成長します。チェーンの調整が続いている間は、PR 全体のゲートを設けるのは控えておきましょう。その段階では、あらゆる修正がチーム全体に見えるイベントとなってしまうためです。
このプロセスに慣れれば、ループエンジニアリングの拡張も可能です。何を自動化するかや環境がどうであれ、検証ループを作成する手順は一定しています。
- 今週、最も頻繁に行っていた手動のフォローアップ作業を一つ選びましょう。
- まずは組み込みの「/verify」スキルを試して、プロセスに役立つか確認してください。
- その手順を、新人チームメンバーに初日に渡すような平易な英語で記述します。
- 作成したスキルを skill-creator に引き渡すか、または自分で .claude/skills/ ディレクトリに Markdown ファイルを配置してください。
- 新しいタスクでそのスキルを呼び出し、チェックが出力の一部として実行されることを確認します。必要に応じて反復して改善しましょう。
- スキルを連鎖させて、エンドツーエンドの検証フローを作成する実験も行ってください。
Claude に従わせる手順をどれだけ多く記述できるかによって、最初の試行で Claude の回答があなたの意図に近づく頻度が高まります。今後は修正のために時間を費やす必要がなくなるため、その分、スキルでは代替できない個別的かつ独自の作業に集中する注意力を確保できます。
*Claude Code で検証ループの構築を始めましょう。*
*この記事は、Claude Code チームの一員である Delba de Oliviera によって執筆されました。*
原文を表示
Make it a skill
The most common way to encode repetitive steps into a verification loop is to write it as a skill, and the fastest way to create a skill is to install the skill-creator plugin and let Claude interview you:
Example:
/skill-creator Create a skill for verifying frontend changes end-to-end. Interview me about my workflow.You can also hand-write a skill by dropping a markdown file in .claude/skills/ inside your project. The simplest possible verification skill is a few lines of frontmatter plus a body:
# .claude/skills/verify-log-hygiene/SKILL.md
---
name: verify-log-hygiene
description: Check that error logs include the request ID and never
include the request body. Use when the diff touches error handling
or logging.
allowed-tools: [Read, Edit, Grep]
---
Read the error-handling paths in the current diff.
For each log call on an error path, confirm it includes the request ID
and does not pass the request body, headers, or any user-supplied payload.
Report each violation with file:line, then fix it: add the request ID
where it's missing and strip the payload from the log call.
The full schema and the philosophy behind it are in our complete guide to building skills.
Match the check to where it runs
The next thing to determine will be how the verification loop kicks off: standalone, embedded, chained, or tied to PR.
Standalone
You invoke it deliberately, after the artifact exists. A standalone skill earns its place for cross-cutting checks that don't apply every time: a pre-commit security scan, a pre-PR accessibility audit, license-header verification across a repo. Anything you want available across many workflows but don't want firing on every code change.
The cost is that each invocation is still a turn you have to remember to take. The signal that you've outgrown standalone is when you're running it after every change. At that point, the procedure has earned a permanent home: embed it or chain it.
Embedded
Fires automatically as part of the producing skill. The check belongs to one specific workflow, and the workflow now runs it without you asking.
The simplest version is a one-line append to the producing skill's body:
# .claude/skills/scaffold-component/SKILL.md
---
name: scaffold-component
description: Scaffold a new React component under src/components/, including the component file, its co-located test, and an index export. Use when the user asks to create a new component.
allowed-tools: [Read, Write, Edit, Bash, Glob]
---
# Scaffold a new React component
Given a component name (PascalCase), create the following under `src/components/<Name>/`:
1. `<Name>.tsx`: function component with a typed props interface and a default export.
2. `<Name>.test.tsx`: React Testing Library test that renders the component and asserts it mounts without throwing.
3. `index.ts`: re-export the default and any named exports.
Follow the patterns in `src/components/Button/` as the reference. Match the import alias style (`@/components/...`) used throughout the codebase.
# code continues...
After creating the component file, run eslint on it and
address any errors before reporting completion.
Verify the embed works by invoking the skill on a fresh task and confirming the new step runs as part of the output. If it doesn't, the skill's description or earlier instructions aren't pulling the appended check in.
Embedded only works on skills you can edit: ones you wrote yourself, or ones installed at a project level where the SKILL.md file is under your control. Built-in skills and plugin-managed skills (the kind that get overwritten on update) are off-limits for this pattern; for those, chain instead.
Skip embedded for checks that span workflows; those want standalone, so you can invoke them from any context.
Chained
One skill calls another at its end, and several verified handoffs run end-to-end.
Members of Anthropic's Claude Code team use this pattern in their day-to-day: /code-review hunts for bugs, /simplify cleans up the diff, a /verify skill confirms end-to-end behavior, and a custom /design skill checks against guidelines in a DESIGN.md file if the change touched UI.
Chaining is also how you add verification to a skill you can't modify: build a custom wrapper skill that invokes the original, then invokes your verification skill, as depicted below:
# .claude/skills/safe-refactor/SKILL.md
Run /simplify on the current diff first.
When /simplify finishes, invoke /verify-no-public-api-changes.What started as a habit ("I always run /verify after /simplify") becomes a contract ("/simplify always runs /verify when it finishes"). The chain runs the whole dev cycle on its own. You only step in when something escalates back to you.
You can skip chaining when the steps are independent enough that you sometimes want to run one without the others; chaining trades flexibility for automation. Chained verification loops can increase token spend, so it's best to test these loops before deploying them broadly.
On every PR
Once the chain is solid for your own changes, the same procedure can run on every PR. A teammate's change passes the same gates yours did, whether they remembered to invoke the chain or not. The infrastructure is the same kind of thing as the chain you already wrote, one step further along: the same skills, the same rubrics, the same standards, applied without depending on the author's diligence.
This is where verification stops being personal infrastructure and becomesteam infrastructure. The check you wrote down to save yourself two minutes a week is now saving everyone two minutes a week, on every change. Hold off on PR-wide gates while the chain is still in flux; every adjustment becomes a team-visible event.
Once you have the process down, you’re ready to expand your loop engineering. The verification loop creation process is consistent, no matter what you’re automating or in what environment:
- Pick the manual follow-up you did most often this week.
- Try out the built-in /verify skill first and see if it helps your process.
- Write the procedure in plain English, the way you'd hand it to a new teammate on day one.
- Hand it to skill-creator, or drop the markdown file in .claude/skills/ yourself.
- Invoke it on a new task and confirm the check runs as part of the output, iterate if needed.
- Experiment with skill chaining to create an end-to-end verification flow.
The more you can encode for Claude to follow, the more often Claude's response will land closer to what you want on the very first try. The corrections you no longer have to fiddle with now free up your attention for the individual and exclusive work that no skill can write down for you.
*Get started with verification loops in *Claude Code.
*This article was written by Delba de Oliviera, a member of the Claude Code team. *
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み