Claude Code Skills:Slash Commands 完全ガイド
Claude Code の Skills システムをマスターしよう。Slash Commands の仕組み、組み込み Skills、カスタム Skills の作成方法を解説します。
Skills は Claude Code の Slash Command システムであり、/command 構文でトリガーできる再利用可能なプロンプトとワークフローです。このガイドでは、組み込み Skills、カスタマイズ、独自の Skills 作成方法について解説します。
Skills とは?
公式ドキュメントによると、Skills は以下の特徴を持ちます:
- Slash Commands でトリガーされる再利用可能なプロンプトテンプレート
- 複数のステップを組み合わせたワークフロー自動化
- ニーズに合わせて作成できるカスタム拡張機能
- コードベースを理解したプロジェクト固有のコマンド
Skills は、一般的なワークフローを単一のコマンドにエンコードするマクロと考えてください。
Skills の動作原理
ユーザーが入力: /commit
Claude Code:
1. .claude/skills/ または組み込みから Skill 定義を検索
2. Skill のプロンプトテンプレートを読み込み
3. Skill で定義されたワークフローを実行
4. 結果をユーザーに返す
組み込み Skills
コアワークフロー Skills
| Skill | コマンド | 目的 |
|---|---|---|
| Init | /init | 新規プロジェクトの CLAUDE.md を初期化 |
| Help | /help | 利用可能なコマンドを表示 |
| Clear | /clear | 会話コンテキストをクリア |
| Config | /config | 設定を表示/編集 |
| Permissions | /permissions | ツール権限を管理 |
| Doctor | /doctor | Claude Code の問題を診断 |
開発 Skills
| Skill | コマンド | 目的 |
|---|---|---|
| Commit | /commit | 適切なメッセージで Git コミットを作成 |
| Review | /review | 現在の変更をレビュー |
| Test | /test | テストを実行し結果を分析 |
| Build | /build | プロジェクトをビルドしエラーを確認 |
| Lint | /lint | Lint を実行し問題を修正 |
Memory Skills
| Skill | コマンド | 目的 |
|---|---|---|
| Memory Save | /memory-save | 知識を Memory MCP に保存 |
| Memory Search | /memory-search | 保存された知識を検索 |
| Memory List | /memory-list | 保存されたすべてのエンティティを一覧表示 |
| Memory Audit | /memory-audit | Memory の健全性を確認 |
Skills の使用方法
基本的な使い方
Slash Command を入力するだけです:
/commit
Claude が Skill のワークフローを実行します。
引数付き
一部の Skills は引数を受け付けます:
/commit -m "feat: add user authentication"
/review --security
/test --coverage
Skills の連鎖
Skills は連続して使用できます:
ユーザー: 話し合った変更を行って、その後 /commit を実行して
Claude:
→ 変更を実施
→ /commit Skill を実行
→ 適切なコミットメッセージを作成
Skill ファイル構造
Skills は .claude/skills/ ディレクトリで定義されます:
.claude/
├── skills/
│ ├── commit.md # Git commit skill
│ ├── review.md # Code review skill
│ ├── deploy.md # Deployment skill
│ └── my-custom-skill.md # Your custom skills
└── settings.json
Skill 定義フォーマット
---
name: commit
description: Create a git commit with conventional commit message
trigger: /commit
---
# Commit Skill
## Instructions
1. Check git status for staged changes
2. Analyze the changes to understand what was modified
3. Generate a conventional commit message:
- feat: New feature
- fix: Bug fix
- docs: Documentation
- refactor: Code refactoring
- test: Test changes
- chore: Maintenance
4. Create the commit with the generated message
5. Show the commit result
## Format
Use this commit message format:
type(scope): description
- Detail 1
- Detail 2
Co-Authored-By: Claude [email protected]
## Example Output
Created commit: abc1234
feat(auth): add JWT token refresh mechanism
- Implement automatic token refresh before expiration
- Add refresh token rotation for security
- Update auth middleware to handle refresh flow
Co-Authored-By: Claude [email protected]
カスタム Skills の作成
ステップ 1:ファイルを作成
.claude/skills/ に新しい .md ファイルを作成します:
touch .claude/skills/deploy.md
ステップ 2:Skill を定義
---
name: deploy
description: Deploy to staging environment
trigger: /deploy
---
# Deploy to Staging
## Prerequisites Check
1. Verify all tests pass
2. Check for uncommitted changes
3. Confirm current branch
## Deployment Steps
1. Build the project:
```bash
npm run build
-
Run pre-deployment tests:
npm run test:e2e -
Deploy to staging:
npm run deploy:staging -
Verify deployment:
- Check health endpoint
- Run smoke tests
Post-Deployment
- Report deployment status
- Show deployed URL
- Note any warnings
### ステップ 3:Skill を使用
/deploy
## 高度な Skill パターン
### パターン 1:パラメータ化された Skills
Skill で引数を受け付ける:
```markdown
---
name: feature
description: Start a new feature branch
trigger: /feature
args:
- name: feature-name
required: true
description: Name of the feature
---
# New Feature Workflow
## Steps
1. Create branch: `feature/{{feature-name}}`
2. Set up feature structure
3. Create initial files
4. Open PR draft
パターン 2:条件付き Skills
コンテキストに基づいて異なる動作:
---
name: review
description: Review code changes
trigger: /review
---
# Code Review
## Determine Review Type
If reviewing a PR:
- Fetch PR changes
- Compare with base branch
If reviewing local changes:
- Check git diff
- Review staged and unstaged
## Review Checklist
- [ ] Code quality
- [ ] Security considerations
- [ ] Test coverage
- [ ] Documentation
- [ ] Performance implications
パターン 3:マルチエージェント Skills
複数のエージェントをオーケストレーションする Skills:
---
name: audit
description: Comprehensive codebase audit
trigger: /audit
---
# Codebase Audit
## Phase 1: Parallel Analysis
Launch these agents simultaneously:
1. **Explore Agent (quick)**: Map codebase structure
2. **Explore Agent (medium)**: Find code patterns
3. **security-auditor**: Security scan
4. **code-reviewer**: Quality check
5. **test-runner**: Coverage analysis
## Phase 2: Synthesize Results
Combine findings into:
- Security issues (by severity)
- Quality concerns
- Coverage gaps
- Recommended improvements
## Output Format
Audit Report
Security (X issues)
- Critical: …
- High: …
Quality (X concerns)
- …
Coverage (X%)
- Missing: …
Recommendations
- …
- …
パターン 4:インタラクティブ Skills
入力を求める Skills:
---
name: scaffold
description: Scaffold new component/feature
trigger: /scaffold
---
# Scaffold Generator
## Questions
Ask the user:
1. What type? (component/api/service/hook)
2. Name?
3. Location? (suggest based on type)
## Generate Based on Answers
For component:
- Create component file
- Create test file
- Create styles file
- Export from index
For API:
- Create route handler
- Create validation schema
- Create test file
- Update API routes index
プロジェクト固有の Skills
例:E コマース Skills
# .claude/skills/add-product.md
---
name: add-product
description: Add a new product to catalog
trigger: /add-product
---
## Product Creation Workflow
1. Create product migration
2. Add product schema
3. Create API endpoints
4. Add admin UI components
5. Write tests
例:API 開発 Skills
# .claude/skills/new-endpoint.md
---
name: new-endpoint
description: Create new API endpoint with full setup
trigger: /new-endpoint
---
## Endpoint Creation
1. Create route handler
2. Add input validation (Zod)
3. Implement business logic
4. Add error handling
5. Write tests
6. Update API docs
7. Run security-auditor
Skill カテゴリ
ワークフロー Skills
/workflow # Full development workflow
/focus-problem # Problem analysis
/test-first # TDD workflow
/smart-commit # Intelligent git commit
品質 Skills
/self-review # Self-review and fix loop
/code-review # Code review
/security-check # Security scan
/doc-audit # Documentation check
Git Skills
/commit-push-pr # Commit, push, and PR
/smart-commit # Conventional commits
AI Interop Skills
/handoff-codex # Hand off to Codex CLI
/handoff-gemini # Hand off to Gemini CLI
/interop-broker # Route to best CLI
Skills vs Agents vs MCP
| 機能 | Skills | Agents | MCP |
|---|---|---|---|
| 目的 | ワークフロー自動化 | タスク実行 | ツール拡張 |
| トリガー | /command | Task tool | 自動 |
| スコープ | プロジェクト固有 | 組み込みタイプ | 外部サービス |
| カスタマイズ | 簡単(Markdown) | 限定的 | 中程度(コード) |
| コンテキストコスト | 低 | 中 | 可変 |
使い分け
Skills を使用する場合:
- 繰り返し可能なワークフローがある
- Slash Command のショートカットが欲しい
- プロジェクト固有のコマンドが必要
- チームのパターンをエンコードしたい
Agents を使用する場合:
- 並列実行が必要
- 専門的な分析が欲しい
- 自律的なタスク処理が必要
- モデル選択の柔軟性が欲しい
MCP を使用する場合:
- 外部データアクセスが必要
- 永続的なストレージが欲しい
- API 統合が必要
- データベースアクセスが欲しい
Skill ベストプラクティス
1. Skills は焦点を絞る
# Good: Single purpose
/deploy-staging # Deploy to staging
/deploy-prod # Deploy to production
# Avoid: Too broad
/deploy # Deploy to... somewhere?
2. 徹底的にドキュメント化
---
name: my-skill
description: Clear one-line description
trigger: /my-skill
---
# Skill Name
## Purpose
What this skill does and when to use it.
## Prerequisites
What needs to be in place before running.
## Steps
Detailed workflow steps.
## Examples
Example usage and expected output.
3. エラーハンドリングを含める
## Error Handling
If build fails:
- Show error details
- Suggest fixes
- Don't proceed with deployment
If tests fail:
- Report failed tests
- Ask before continuing
4. Agents を適切に使用
## Quality Checks
After implementation:
- Run code-reviewer agent for quality
- Run test-runner agent for coverage
- Run security-auditor if touching auth/payment
Skills の発見
利用可能な Skills を一覧表示
/help
カスタム Skills を含むすべての利用可能な Skills が表示されます。
Skill 定義を確認
.claude/skills/ を見てカスタム Skill の定義を確認できます。
組み込み Skill のドキュメント
組み込み Skills は公式 Claude Code ドキュメントに記載されています。
はじめよう
今日:
- 次の変更で
/commitを試す /helpを使って利用可能な Skills を確認- 組み込み Skills をレビュー
今週:
- ワークフロー用にカスタム Skill を 1 つ作成
- チーム固有の Skills をプロジェクトに追加
- README に Skills をドキュメント化
今月:
- プロジェクト Skills のライブラリを構築
- チームプロジェクト間で Skills を共有
- 複雑なワークフロー用にマルチエージェント Skills を作成
Skills はあなたの専門知識を再利用可能なコマンドにエンコードします。一度作れば、永遠に使えます。