mcpField
S
slash-commands

slash-commands

github.com/parcadeiエージェントワークフロー3.9k491 回インストール39 週間前に更新
リポジトリ

slash-commands について

Claude Codeでユーザーが呼び出すスラッシュコマンドを作成・利用するためのリファレンススキルです。コマンドファイル、引数、Bash実行、ファイル参照と、スキルとの違いを説明します。

主な機能

  1. 01組み込みコマンド一覧
  2. 02プロジェクト用・個人用コマンドの設定
  3. 03YAMLフロントマターと引数
  4. 04プロンプト内でのBash実行
  5. 05ファイル参照と名前空間
  6. 06MCPサーバーが提供するコマンド

活用シーン

  1. 01再利用可能なプロンプトの作成
  2. 02コマンドへの引数とファイル参照の追加
  3. 03プロンプト読み込み前のBash実行
  4. 04スラッシュコマンドとスキルの使い分け

MCP 対応

MCPサーバーがプロンプトをスラッシュコマンドとして公開できることを説明し、呼び出し例を示します。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill slash-commands

インストール後、Claude Code で/slash-commandsを入力して読み込まれたか確認します。

詳細

スラッシュコマンドのリファレンス

/command-name 構文を使って、ユーザーが呼び出すプロンプトを作成して使用します。

使用する場面

  • 「スラッシュコマンドを作成するにはどうすればよいですか?」
  • 「どのようなスラッシュコマンドを使用できますか?」
  • 「コマンドに bash を追加する」
  • 「コマンドでファイル参照を使用する」
  • 「スラッシュコマンドとスキルの違い」

組み込みコマンド

コマンド目的
/clear会話履歴を消去する
/compact焦点を絞って会話を圧縮する
/config設定インターフェースを開く
/costトークン使用量を表示する
/agentsサブエージェントを管理する
/mcpMCP サーバーを管理する
/memoryCLAUDE.md ファイルを編集する
/modelAI モデルを選択する
/reviewコードレビューを依頼する
/resumeセッションを再開する
/help使用方法に関するヘルプを表示する

コマンドの作成

プロジェクトコマンド
mkdir -p .claude/commands
cat > .claude/commands/optimize.md << 'EOF'
---
description: Analyze code for performance issues
---

Review this code for:
- Performance bottlenecks
- Memory leaks
- Caching opportunities
EOF
個人用コマンド
mkdir -p ~/.claude/commands
cat > ~/.claude/commands/review.md << 'EOF'
---
description: Security-focused code review
---

Check for vulnerabilities:
- Input validation
- SQL injection
- XSS risks
EOF

コマンドファイルの形式

---
description: Brief description for /help
allowed-tools: [Bash, Read, Write]  # Optional
argument-hint: "[file] [type]"       # Optional
---

Your markdown instructions here.
Use $1, $2 for arguments or $ARGUMENTS for all.

Bash の実行

! 接頭辞を使うと、プロンプトを読み込む前に bash を実行できます。

---
allowed-tools: Bash(git:*), Bash(grep:*)
description: Git commit helper
---

Current status: !`git status`
Staged changes: !`git diff --staged`
Recent commits: !`git log --oneline -5`

Based on these changes, suggest a commit message.

ルール:

  • フロントマターに allowed-tools: Bash(...) を宣言する必要があります
  • バッククォートを使用します: !`command`
  • 出力は Claude のコンテキストに含まれます

ファイル参照

@ 接頭辞を使ってファイルを含めます。

Review against @.claude/STYLE_GUIDE.md

Compare:
- @src/old.js
- @src/new.js

Refactor files matching @src/**/*.util.ts

引数

---
argument-hint: "[pr-number] [priority]"
---

Review PR #$1 with priority: $2

# Or use all arguments:
Fix issue #$ARGUMENTS

使用方法:

/review-pr 456 high
# $1 = "456", $2 = "high"

名前空間

サブディレクトリを使って整理します。

.claude/commands/
├── frontend/
│   └── component.md    → /component (project:frontend)
└── backend/
    └── endpoint.md     → /endpoint (project:backend)

MCP スラッシュコマンド

MCP サーバーはプロンプトをコマンドとして公開します。

/mcp__github__list_prs
/mcp__github__pr_review 456
/mcp__jira__create_issue "Bug" high

スラッシュコマンドとスキルの違い

項目スラッシュコマンドスキル
呼び出し明示的:/command自動検出
ファイル単一の .md ファイルSKILL.md を含むディレクトリ
用途手軽なプロンプト複雑なワークフロー

スラッシュコマンドの用途: 頻繁に入力するプロンプト、シンプルなテンプレート
スキルの用途: 複雑なワークフロー、複数のファイル、自動検出

例:Git コミットコマンドの全体像

---
description: Generate semantic commit message
allowed-tools: Bash(git:*), Read
argument-hint: "[type]"
---

# Semantic Commit Generator

Staged files: !`git diff --name-only --cached`

Diff preview:
!`git diff --cached | head -100`

Generate a conventional commit message.
Type: $1 (feat/fix/docs/style/refactor/perf/test/chore)

Format: `<type>(<scope>): <subject>`

使用方法: /commit feat

コメント