CC Guide
中級

Skill を定義して再利用可能なプロンプトを作る

.claude/skills/ に SKILL.md ファイルを作成し、ユーザーとClaudeの両方から呼び出せるスキルを定義する方法

skillsreusabilityconfiguration

Skill を定義して再利用可能なプロンプトを作る

Claude Code の Skills 機能を使うと、再利用可能なプロンプトを定義できます。カスタムスラッシュコマンドと異なり、スキルはユーザーからの明示的な呼び出しだけでなく、Claude が文脈に応じて自動的に参照することも可能です。

スキルのディレクトリ構造

.claude/skills/
  hello/
    SKILL.md
  code-review/
    SKILL.md
  deploy/
    SKILL.md

各スキルはディレクトリ内の SKILL.md ファイルとして定義します。

SKILL.md の基本構造

---
description: "Generate database migration files for schema changes. Use when modifying Prisma schema or adding new tables."
disable-model-invocation: false
user-invocable: true
context: inline
---

# Database Migration Generator

## Instructions

When generating database migrations:

1. Read the current Prisma schema at `prisma/schema.prisma`
2. Identify what changed since last migration
3. Generate appropriate migration SQL
4. Create a descriptive migration name

## Rules

- Always include `up` and `down` migrations
- Use transactions for data migrations
- Add indexes for new foreign keys
- Never drop data without confirmation

Frontmatter の設定項目

項目説明
descriptionstringスキルの説明(いつ使うべきかを記述)
disable-model-invocationbooleantrue の場合、ユーザーのみ呼び出し可能(例: /deploy
user-invocablebooleanfalse の場合、/メニューに非表示(Claudeのみ呼び出し)
contextstringfork で独立サブエージェント環境で実行
agentstringcontext: fork 時のエージェントタイプ

コンテキストフォークの活用

context: fork を設定すると、スキルが独立したサブエージェント環境で実行されます。メインの会話履歴にアクセスできないため、安全な独立処理に適しています。

---
description: "Security scan of the codebase"
context: fork
agent: Explore
---

Scan the codebase for security vulnerabilities...

プラグインスキル

プラグインも plugin.jsonskills パス経由でスキルを定義できます。Superpowers プラグインの14のスキルや、Everything Claude Code の150のスキルがこの仕組みで動作しています。

自動呼び出しの仕組み

Claude はスキルの description を読み、現在のタスクに適用できるかを判断します。そのため、description には「何をするスキルか」ではなく「いつ使うべきか」を記述することが重要です。

---
description: "Use when implementing new API endpoints or modifying existing routes"
---

スキルとコマンドの使い分け

特徴SkillCustom Command
Claudeからの自動参照可能不可
ユーザーからの呼び出し/skill-name/command-name
フォーク実行対応非対応
引数非対応$ARGUMENTS 対応
目的再利用可能な振る舞い定義定型プロンプトのショートカット

あわせて読む

関連コンテンツ