すべてのスキルには SKILL.md ファイルが必要で、2 つの部分があります:Claude にスキルをいつ使用するかを伝える YAML フロントマター(--- マーカー間)と、スキルが呼び出されたときに Claude が従うマークダウンコンテンツです。name フィールドは /slash-command になり、description は Claude がそれを自動的にロードするかどうかを決定するのに役立ちます。~/.claude/skills/explain-code/SKILL.md を作成します:
不正なコードを報告
コピー
AIに質問
---name: explain-codedescription: Explains code with visual diagrams and analogies. Use when explaining how code works, teaching about a codebase, or when the user asks "how does this work?"---When explaining code, always include:1. **Start with an analogy**: Compare the code to something from everyday life2. **Draw a diagram**: Use ASCII art to show the flow, structure, or relationships3. **Walk through the code**: Explain step-by-step what happens4. **Highlight a gotcha**: What's a common mistake or misconception?Keep explanations conversational. For complex concepts, use multiple analogies.
3
スキルをテストする
2 つの方法でテストできます:説明に一致するものを尋ねることで Claude に自動的に呼び出させます:
my-skill/├── SKILL.md # Main instructions (required)├── template.md # Template for Claude to fill in├── examples/│ └── sample.md # Example output showing expected format└── scripts/ └── validate.sh # Script Claude can execute
スキルファイルには任意の指示を含めることができますが、それらを呼び出す方法を考えることは、何を含めるかをガイドするのに役立ちます:リファレンスコンテンツ は Claude が現在の作業に適用する知識を追加します。規約、パターン、スタイルガイド、ドメイン知識。このコンテンツはインラインで実行されるため、Claude は会話コンテキストと一緒に使用できます。
不正なコードを報告
コピー
AIに質問
---name: api-conventionsdescription: API design patterns for this codebase---When writing API endpoints:- Use RESTful naming conventions- Return consistent error formats- Include request validation
タスクコンテンツ は Claude に、デプロイメント、コミット、またはコード生成などの特定のアクション用のステップバイステップ指示を提供します。これらは、Claude が自動的に実行するのではなく、/skill-name で直接呼び出したいアクションであることが多いです。disable-model-invocation: true を追加して、Claude が自動的にトリガーするのを防ぎます。
不正なコードを報告
コピー
AIに質問
---name: deploydescription: Deploy the application to productioncontext: forkdisable-model-invocation: true---Deploy the application:1. Run the test suite2. Build the application3. Push to the deployment target
この例は、ユーザーのみがトリガーできるデプロイスキルを作成します。disable-model-invocation: true フィールドは Claude が自動的に実行するのを防ぎます:
不正なコードを報告
コピー
AIに質問
---name: deploydescription: Deploy the application to productiondisable-model-invocation: true---Deploy $ARGUMENTS to production:1. Run the test suite2. Build the application3. Push to the deployment target4. Verify the deployment succeeded
2 つのフィールドが呼び出しとコンテキスト読み込みにどのように影響するかは次のとおりです:
フロントマター
ユーザーが呼び出せる
Claude が呼び出せる
コンテキストに読み込まれるタイミング
(デフォルト)
はい
はい
説明は常にコンテキストにあり、呼び出されたときにフルスキルが読み込まれます
disable-model-invocation: true
はい
いいえ
説明はコンテキストにはなく、ユーザーが呼び出したときにフルスキルが読み込まれます
user-invocable: false
いいえ
はい
説明は常にコンテキストにあり、呼び出されたときにフルスキルが読み込まれます
通常のセッションでは、スキル説明はコンテキストに読み込まれるため Claude は利用可能なものを知っていますが、フルスキルコンテンツは呼び出されたときにのみロードされます。プリロードされたスキルを持つサブエージェントは異なります:フルスキルコンテンツはスタートアップ時に注入されます。
ユーザーと Claude の両方がスキルを呼び出すときに引数を渡すことができます。引数は $ARGUMENTS プレースホルダーを通じて利用可能です。このスキルは GitHub の問題を番号で修正します。$ARGUMENTS プレースホルダーはスキル名の後に続くものに置き換えられます:
不正なコードを報告
コピー
AIに質問
---name: fix-issuedescription: Fix a GitHub issuedisable-model-invocation: true---Fix GitHub issue $ARGUMENTS following our coding standards.1. Read the issue description2. Understand the requirements3. Implement the fix4. Write tests5. Create a commit
---name: deep-researchdescription: Research a topic thoroughlycontext: forkagent: Explore---Research $ARGUMENTS thoroughly:1. Find relevant files using Glob and Grep2. Read and analyze the code3. Summarize findings with specific file references
スキルは任意の言語でスクリプトをバンドルして実行でき、Claude に単一のプロンプトで可能なことを超えた機能を提供します。1 つの強力なパターンはビジュアル出力を生成することです:ブラウザで開くインタラクティブ HTML ファイルで、データの探索、デバッグ、またはレポート作成に使用できます。この例はコードベースエクスプローラーを作成します:ディレクトリを展開および折りたたむことができるインタラクティブツリービュー、一目でファイルサイズを確認でき、色でファイルタイプを識別できます。スキルディレクトリを作成します:
~/.claude/skills/codebase-visualizer/SKILL.md を作成します。説明は Claude にこのスキルをいつアクティブにするかを伝え、指示は Claude にバンドルされたスクリプトを実行するよう伝えます:
不正なコードを報告
コピー
AIに質問
---name: codebase-visualizerdescription: Generate an interactive collapsible tree visualization of your codebase. Use when exploring a new repo, understanding project structure, or identifying large files.allowed-tools: Bash(python:*)---# Codebase VisualizerGenerate an interactive HTML tree view that shows your project's file structure with collapsible directories.## UsageRun the visualization script from your project root:```bashpython ~/.claude/skills/codebase-visualizer/scripts/visualize.py .```This creates `codebase-map.html` in the current directory and opens it in your default browser.## What the visualization shows- **Collapsible directories**: Click folders to expand/collapse- **File sizes**: Displayed next to each file- **Colors**: Different colors for different file types- **Directory totals**: Shows aggregate size of each folder
~/.claude/skills/codebase-visualizer/scripts/visualize.py を作成します。このスクリプトはディレクトリツリーをスキャンし、以下を含む自己完結型 HTML ファイルを生成します:
テストするには、任意のプロジェクトで Claude Code を開き、「Visualize this codebase」と尋ねます。Claude がスクリプトを実行し、codebase-map.html を生成し、ブラウザで開きます。このパターンは任意のビジュアル出力に機能します:依存関係グラフ、テストカバレッジレポート、API ドキュメント、またはデータベーススキーマの視覚化。バンドルされたスクリプトが重い処理を行い、Claude がオーケストレーションを処理します。