💨

サンプルで覚える! Claude Code の How To スラッシュコマンド!

に公開

コマンドリスト全部使ってないし、わかってなかった
だから、書くことにした!

マニュアルと実装に差分がある

公式マニュアルより/release-note(後述)のほうが確実です
少し前に、スラッシュコマンドの一覧記事を書きました
これはアプデのたびにメンテして更新してます!
https://zenn.dev/mohy_nyapan/articles/2c16d000a4125c

実際スラッシュコマンドで何が出来るの?

書いたはいいんですが、日本語呼んでも具体的にそもそもなにができるんじゃい!!
なお、この記事では「カスタムスラッシュコマンド」は触れません。
(そのうち書くと思いますw)

Claude Code デフォルトスラッシュコマンド動作例

このドキュメントでは、Claude Codeのデフォルトスラッシュコマンドがどのような出力を返すかを示します。

/export [filename]

会話を指定形式でエクスポートできるようになりました
クリップボードとファイルを選択可能
また、ファイル名を省略した場合はスラッシュコマンドでファイル保存を選択した際、任意の名前が付けられます(編集可能)
拡張子は無視され「test.md」と保存しても「test.txt」として保存されます

ただ、WSL環境でクリップボードの場合、2バイト文字は文字化けしてしまいます

command: /export
result:


/status

Claude Codeの現在の状態を表示します。
色々な状態(SessionID、参照メモリ、モデルなど)一括で見るなら便利

command: /status
result:
Claude Code Status v1.0.43
  L Session ID: b32a1112-xxx-xxxx-xxxx-5f73966xxxxx

 Working Directory
  L /mnt/d/claude/xxxxxxx

 Installation Health • /doctor
 ⚠  Config mismatch: running npm-global but config says unknown

 MCP servers • /mcp
 ✔  context7
 ✔  playwright

 Account • /login
  L Login Method: Claude Max Account
  L Organization: youraddress@gmail.com's Organization
  L Email: youraddress@gmail.com

 Memory • /memory
  L user: ~/.claude/CLAUDE.md
  L project: /mnt/d/claude/CLAUDE.md
  L project: CLAUDE.md

 Model • /model
  L opus (claude-opus-4-20250514)

/help

利用可能なスラッシュコマンドの一覧を表示します。
一部の内容は日本語で知りたかったので、翻訳しました
自身で追加したコマンドは(user)がつきます

command: /help
result:
   Claude Code v1.0.43

   Always review Claude's responses, especially when running code. Claude has read access to files in the current directory and can run commands and edit files with your permission.
   (  Claudeの応答は常に確認してください、特にコードを実行する時は注意が必要。Claudeは現在のディレクトリ内のファイルに読み取りアクセスがあり、あなたの許可があればコマンドを実行したりファイルを編集したりできます。)

   Usage Modes:
   • REPL: claude (interactive session)
   • Non-interactive: claude -p "question"

   Run claude -h for all command line options

   Common Tasks:
   • Ask questions about your codebase > How does foo.py work?
	    • コードベースについて質問する > foo.pyはどのように動作しますか?
   • Edit files > Update bar.ts to...
		• ファイルを編集する > bar.tsを更新して...   
   • Fix errors > cargo build
		• エラーを修正する > cargo build
   • Run commands > /help
		• コマンドを実行する > /help
   • Run bash commands > !ls
		• bashコマンドを実行する > !ls

Interactive Mode Commands:
  /add-dir - Add a new working directory
  /bug - Submit feedback about Claude Code
  /clear - Clear conversation history and free up context
  /compact - Clear conversation history but keep a summary in context. Optional: /compact [instructions for summarization]
  /config - Open config panel
  /cost - Show the total cost and duration of the current session
  /doctor - Checks the health of your Claude Code installation
  /exit - Exit the REPL
  /gemini-search - Gemini Search (user)
  /help - Show help and available commands
  /hooks - Manage hook configurations for tool events
  /ide - Manage IDE integrations and show status
  /init - Initialize a new CLAUDE.md file with codebase documentation
  /install-github-app - Set up Claude GitHub Actions for a repository
  /login - Sign in with your Anthropic account
  /logout - Sign out from your Anthropic account
  /mcp - Manage MCP servers
  /memory - Edit Claude memory files
  /migrate-installer - Migrate from global npm installation to local installation
  /model - Set the AI model for Claude Code
  /permissions - Manage allow & deny tool permission rules
  /pr-comments - Get comments from a GitHub pull request
  /release-notes - View release notes
  /resume - Resume a conversation
  /review - Review a pull request
  /status - Show Claude Code status including version, model, account, API connectivity, and tool statuses
  /upgrade - Upgrade to Max for higher rate limits and more Opus
  /vim - Toggle between Vim and Normal editing modes

 Learn more at: https://docs.anthropic.com/s/claude-code

/mcp

接続されているMCPサーバーの一覧を表示します。
MCPサーバーを選択することで、MCPサーバの詳細が閲覧できます。

command: /mcp
result:
Manage MCP servers                                        
❯ 1. context7    ✔ connected · Enter to view details                                 2. playwright  ✔ connected · Enter to view details 

/doctor

Claude Codeのインストール状態を診断します。

command: /doctor
result:
 Claude CLI Diagnostic
 Currently running: npm-global (1.0.43)
 Path: /home/xxxx/.nvm/versions/node/v22.16.0/bin/node
 Invoked: /home/xxxx/.nvm/versions/node/v22.16.0/bin/claude
 Auto-updates: No
 Config install method: unknown
 Config auto-updates: true
 Update permissions: Yes
 Recommendation: Run '/migrate-installer' to enable auto-updates
 This migrates to a local installation in ~/.claude/local

/login

新しいログインを試行できます。
ログアウトしちゃうよ!

command: /login
result:

/memory

読み込んでいるメモリ設定(CLAUDE.mdファイル)と各ファイルの編集ができます。

command: /memory
result:

/model

利用可能なAIモデル一覧を表示します。
表示されたモデル一覧から使用するモデルを選択できます。
選択中のモデルには「✔」が表示されます

command: /model
result:

/settings

設定ファイルの場所と利用可能な設定オプションを表示します。

command: /settings
result:

/hooks

フック設定を表示します。
hooksは機能が大きいので、この記事では具体的な内容までは触れません

command: /hooks
result:

/add-dir [dir]

作業ディレクトリを追加します。
例えば、root_dir/back-endでclaudeを起動した場合に、front-endもclaudeの作業ディレクトリとしたいに利用
root_dir
├── back-end ← カレントディレクトリ
└── front-end ← 追加したい作業ディレクトリ

command: /add-dir ../front-end
result:

/bug

バグレポートを送信したい場合。
内容を記載しておくることができます。

command: /bug
result:

/compact

会話履歴をクリアしつつ、要約をコンテキストに保持します。
オプションで要約の指示を追加できます。
結構Token使います。

command: /compact
result: 
====================================================================================== Previous Conversation Compacted =====================================================================================
● Compact summary (ctrl+r to expand)
  ⎿  Read slash_command_example.md (69 lines)
  ⎿  Read ../../../../../home/xxxxx/.claude/settings.json (7 lines)
  ⎿  Read ../../CLAUDE.md (48 lines)
  ⎿  Todo list read (3 items)

> /compact
  ⎿  Compacted. ctrl+r to see full summary

要約方法を指示も出せます
あんまうまくいきません

command: /compact 技術的な詳細を中心に要約

/config

設定パネルを開きます。
Claude Codeの各種設定を変更できます。

command: /config
result: 
Auto-compact (自動圧縮設定)
Use todo list (ToDoリストを使うか)
Verbose output (詳細モードを利用するか>ctrl+rで開くような詳細が全部出力されます)
Auto-updates (自動アプデ)
Theme (テーマ設定)
Notifications (通知設定)
Editor mode (vim | normal)
Model (/modelのエイリアス)

/cost

現在のセッションの合計コストと所要時間を表示します。
使用したトークン数とAPI利用料金を確認できます。
APIモードの場合利用できるようで、MAXプランの場合は出ません。
ccusage使ってニヤニヤするといいよ!

command: /cost
result:
/cost
  ⎿  With your Claude Max subscription, no need to monitor cost — your subscription includes Claude Code usage

/exit

REPLを終了します。
現在のセッションを終了し、Claude Codeを閉じます。
/quit:q というエイリアスも持ってます。

command: /exit
result: Claude Codeが終了します

/ide

IDE統合を管理し、ステータスを表示します。
VSCodeなどのIDEとの連携状態を確認できます。
連携してないので以下

command: /ide
result:

/init

CLAUDE.mdファイルを初期化し、コードベースのドキュメントを作成します。
自身のコードベースをプロジェクト内のCLAUDE.mdとして定義します。
ディレクトリ名から結構類推はしてくれる
プロジェクトのガイドラインをClaude用に設定します。

command: /init
result: 
/init is analyzing your codebase…
● I'll analyze this codebase and create a CLAUDE.md file to guide future Claude instances. Let me start by exploring the project structure and understanding what's here
● Based on my analysis, I can see this is a documentation project for Claude Code slash commands. Let me create an appropriate CLAUDE.md file for this project

/install-github-app

リポジトリにClaude GitHub Actionsをセットアップします。
GitHub連携の自動化を設定します。
今回は入力してません

command: /install-github-app
result:

/logout

Anthropicアカウントからサインアウトします。
現在のセッションを終了します。

command: /logout

/migrate-installer

グローバルnpmインストールからローカルインストールに移行します。
インストール方法を更新します。
グローバルインストールしているときにこれやると、グローバル消しちゃうので注意

command: /migrate-installer
result:
Claude Code Local Installer
This will install Claude Code to ~/.claude/local
instead of using a global npm installation.
Press Enter to continue or Esc to exit
✓ Local installation successful!

/pr-comments

GitHubプルリクエストからコメントを取得します。
PR上のフィードバックを確認できます。
GitHub連携していないと意味が無いです

command: /pr-comments

/release-notes

リリースノートを表示します。
Claude Codeの最新の更新内容を確認できます。
ドキュメント等を見るよりこっち見たほうが確実です

command: /release-notes
result:
 /release-notes
  ⎿  Version 0.2.21:
     • Fuzzy matching for /commands

     Version 0.2.26:
     • New /approved-tools command for managing tool permissions
     • Word-level diff display for improved code readability
     • Fuzzy matching for slash commands
...

/resume

会話を再開します。
以前のセッションから続きを開始できます。
「claude --resume」 で開始時にも選択できます

command: /resume
result:

/review

プルリクエストをレビューします。
コードの変更を分析し、フィードバックを提供します。
GitHub連携していないと意味がありません

command: /review
result:
/review is reviewing pull request…

/upgrade

より高いレート制限とOpusの使用量を増やすためにMaxにアップグレードします。
サブスクリプションを管理します。
MAX20の場合は、以下のようにこれ以上アップグレードできんぜ?的に言われます

command: /upgrade
result:
/upgrade
  ⎿  You are already on the highest Max subscription plan. For additional usage, run /login to switch to an API usage-billed account.

/vim

VimモードとNormalモードを切り替えます。
エディタのキーバインディングを変更します。

command: /vim
result: 
 /vim
  ⎿  Editor mode set to vim. Use Escape key to toggle between INSERT and NORMAL modes

/permissions

ツールの許可・拒否権限ルールを管理します。
特定のツールの実行を制御できます。
Allow Deny Workspaceを編集できます

command: /permissions
result:

注意事項

  • 出力内容は環境や設定により異なります
  • バージョン番号、ファイルパス、ユーザー情報などは実際の環境に依存します
  • 一部のコマンドは追加の引数を受け付ける場合があります
  • カスタムコマンドは個人の設定により異なります

あとがき

使ってなかったスラッシュコマンドも使えてまあまあ理解
記事書くたびにハンズオンの大切さが身に沁みます

でも、わたしは、わきがあまいのでぬこぬこ師に突っ込まれて無事死亡
今日からデマにゃぱんです
https://x.com/schroneko/status/1942188361504182775

Discussion