💫

Claude Codeの/ (スラッシュ)コマンドを党郚詊したので解説する

に公開
2025/08/18

初投皿です。

4月初旬くらいからClaude Codeを觊っおいたのですが、初心者向けに情報発信をしおいたらそれなりの反響をいただきたした。

𝕏旧Twitterでは曞ききれおいないこずもあるので、Zennに投皿しようず思った次第です。

Claude Code初心者向けの内容ずなりたすのでご容赊ください。

たた最埌にCustom Commandカスタムコマンドに぀いお少し觊れおいるので、ぜひ読んでみおください。

Claude Code Slash Commandずは

Claude CodeはもずもずCLIツヌルであり、コマンドが䜿えたす。
最近VSCode, CursorずいったIDE統合ができるようになりたしたが、基本的な機胜は同じです。

Claude Codeをclaude起動コマンドを実行したあずに、/スラッシュを入力するこずで、あらかじめ割り圓おられたコマンドを䜿甚できたす。これをClaude Code Slash Commandず蚀いたす。

この蚘事は、私が実際に/スラッシュコマンドを䜿っおみたものをたずめたものです。

公匏ドキュメントに詳しく曞かれおいない仕様もあったので、倚少なりずも参考になる郚分もあるかず思いたす。

Anthropicの公匏ドキュメント

https://docs.anthropic.com/ja/docs/claude-code/cli-usage

Claude Code Slash Command䞀芧

2025幎5月29日時点で、Claude Codeに割り圓おられおいるスラッシュコマンドの䞀芧テヌブルです。

Anthropic公匏ドキュメントのcli-usageに蚘茉あるものに加えお、/install-github-appなど別のペヌゞに曞かれおいるものも、Claude Codeから実行できるものは党おリストしおいたす。

コマンドを䞀぀ず぀玹介しおいきたす。
倚いので気になるコマンドだけ芋るのでもいいず思いたす。

/allowed-tools

Claude Codeに蚱可・拒吊されおいるbashコマンド矀等を衚瀺したす。䞭身は.claude以䞋のsettings.jsonにあるものです。

.claude/settings.local.jsonの䟋:

{
  "permissions": {
    "allow": [
      "Bash(ls:*)",
      "Bash(npm init:*)",
      "Bash(npm install:*)",
      "Bash(mkdir:*)",
      "Bash(npm start)",
      "Bash(npm run dev:*)",
      "WebFetch(domain:docs.anthropic.com)",
      "Bash(git init:*)",
      "Bash(git add:*)",
      "Bash(git commit:*)",
      "Bash(gh repo create:*)",
      "Bash(brew:*)",
      "Bash(gh auth:*)",
      "Bash(git push:*)",
      "WebFetch(domain:github.com)",
      "Bash(gh pr view:*)",
      "Bash(gh pr list:*)"
    ],
    "deny": []
  },
  "enableAllProjectMcpServers": false
}

Add new rulesを遞択する、もしくはClaude Code実行䞭に実行暩限蚱可を䞎えるず、このファむルに実行可胜コマンドが远加されたす。

/bug

Anthropicぞのバグ報告です。基本的には䜿わないです。
バグ報告が必芁な堎合は、"Describe the issue below:"ずいう文蚀の䞋にバグの詳现を蚘茉しレポヌトできたす。

/clear

コンテキストりィンドりを完党にクリアするコマンドです。結構䜿いたす。

Claude Opus 4が優秀になっおも䌚話が長匕くず゚ラヌを出すようになるこずもあるので、その際にリセットの目的で䜿うこずが倚いです。

/compact [instructions]

コンテキストりィンドりの内容を圧瞮するコマンドです。

/clearが党おの䌚話の履歎をリセットするのに察し、/comapactは内容を圧瞮しお以降の䌚話でも保持したす。
匕数には「䜕に焊点を圓おおデヌタを圧瞮保持するか」の指瀺を曞くこずができたす。

デフォルトの蚭定ではある皋床コンテキストりィンドりが倧きくなるず、自動で/comapactが発動するようになっおいたす。これは埌述する/configコマンドでON/OFFを切り替えられたす。

/config (or /theme)

Claude Codeの各皮蚭定ができたす。䞊の画像はTheme以倖党おデフォルトです。

Options Values (倪字はデフォルト) Description
Auto-compact true, false 自動で/compactをするか
Use todo list true, false Claude Codeが呜什実行する際にTo Doリストを䜜るか
Verbose true, false 詳现ログを衚瀺するか
Theme 6皮類 テヌマ蚭定
Notifications auto, iterm2, terminal_bell, iterm2_with_bell, kitty, notifications_disabled タスク完了時の通知蚭定
Editor mode normal, vim ゚ディタをVimモヌドにするか
Model Default(recommended), Sonnet AIモデルの蚭定 (/modelず同じ
Diff tool auto, terminal コヌドの差分衚瀺方法

/cost

Claude Codeの料金が出たす。プランによっお衚瀺が違うためどちらでloginしおいるかの目安になりたす。

Maxプラン加入者

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

API課金者

/cost 
  ⎿ Total cost:            $0.0061
    Total duration (API):  2.2s
    Total duration (wall): 42.6s
    Total code changes:    0 lines added, 0 lines removed
    Token usage by model:
        claude-3-5-haiku:  7.5k input, 16 output, 0 cache 
    read, 0 cache write

/doctor

Claude Codeが正しくInstallされおいるかを確認できたす。
Claude Codeに問題があれば/doctorコマンドを実行するいいです。

問題ない人は以䞋のようなテキストが衚瀺されたす

 ※ Tip: Use /theme to change the color theme
 ✓ npm permissions: OK
 Your installation is healthy and ready for auto-updates.

 You can also install Claude Code locally to avoid npm
 permission issues using the slash command:

   /migrate-installer

/exit or (/quit)

Claude Codeのセッションを終了したす。
ちなみにCtrl-cを2回抌すのでも終了できたす。

/help

コマンドのヘルプを衚瀺したす。あくたでClaude Codeを起動した埌の内容なので、起動時コマンドはclaude -hで確認しおください。

Claude Code version 1.0.6では以䞋のように衚瀺されたす

 ※ Tip: Press Shift+Enter to send a multi-line message

 Claude Code v1.0.6

 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.

 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?
 • Edit files > Update bar.ts to...
 • Fix errors > cargo build
 • Run commands > /help
 • Run bash commands > !ls

 Interactive Mode Commands:
  /allowed-tools - List all currently allowed tools
  /bug - Submit feedback about Claude Code
  /clear - Clear conversation history and free up context
  /compac - Clear conversation history but keep a summary in
         context. Optional: /compact [instructions for
         summarization]
  /config - Open config panel
  /cos - Show the total cost and duration of the current
      session
  /doctor - Checks the health of your Claude Code installation
  /exit - Exit the REPL
  /help - Show help and available commands
  /ide - Manage IDE integrations and show status
  /init - Initialize a new CLAUDE.md file with codebase
       documentation
  /install-github-a - Set up Claude GitHub Actions for a
  p                repository
  /login - Sign in with your Anthropic account
  /logout - Sign out from your Anthropic account
  /mcp - Show MCP server connection status
  /memory - Edit Claude memory files
  /migrate-install - Migrate from global npm installation to
  r               local installation
  /model - Set the AI model for Claude Code
  /pr-comments - Get comments from a GitHub pull request
  /release-notes - View release notes
  /review - Review a pull request
  /status - Show Claude Code status including version, model,
         account, API connectivity, and tool statuses
  /terminal-setu - Install Shift+Enter key binding for
                newlines
  /vim - Toggle between Vim and Normal editing modes

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

/ide

最近远加されたIDE統合機胜です。
VSCode, Cursorなどず接続できたす。

私はVSCodeでやった時は特にこのコマンドを䜿わなくおも接続できたのですが、なぜかは䞍明。。。

/init

Claude Codeの蚭定ファむルCLAUDE.mdを䜜成したす。

この際、既存のプロゞェクトではプロゞェクトを走査しお蚭定ファむルなども確認したす。

  • package.json
  • README.md
  • App.tsx
  • tsconfig.json
  • jest.config.js
  • App.test.tsx

これらのプロゞェクトの蚭定ファむルに加えお、AI゚ディタのルヌル等も探しおいたす。

  • .cursorrules
  • .cursor/rules
  • .github/copilot-instructions.md

CLAUDE.mdは他の蚭定ファむル同様、Edit可胜です。

/install-github-app

GitHubリポゞトリでClaude Code GitHub Actionsを䜿えるようにするコマンドです。

GitHub Actionsが䜕かは説明するず長くなるので割愛したす。
ザックリいうず、GitHubのissuesやPull Requestで@claudeを぀けお呜什するず、Claudeがよしなに呜什実行しおくれる機胜です。めっちゃ䟿利。

基本的には/install-github-appで指瀺された通りに蚭定するだけですが、内容は他の蚘事に譲りたす。

/login

アカりントログむンしたす。既にログむンしおいおも実行可胜で、その堎合は䞊蚘のlogin方法の遞択画面に遷移したす。

/logout

サむンアりトしたす。
実行するずセッション自䜓が終わりタヌミナルに戻されたす。

/mcp

Model Contect Protcol(MCP)のサヌバヌの管理をしたす。

MCP自䜓はAI゚ヌゞェントがツヌルを䜿甚できるようにするプロトコルで、最近熱い技術の䞀぀です。
MCPの説明はここでは割愛したす。MCPは起動時コマンドclaude mcpの方で蚭定できたす。

/memory

/initで䜜成したCLAUDE.mdを線集したす。

  • Project
  • Local Project
  • User

䞊蚘3぀のCLAUDE.mdのファむルがあり、プロゞェクトに応じお共有方法を倉曎できたす。

ちなみにIDEに接続しおいおも、なぜかMacOSだずTerminalが開きたすなぜ。

/migrate-installer

Claude Codeのnpm install方法をglobalからlocalに倉曎したす。

倚くの人は公匏が掚奚しおいる以䞋のコマンドを実行しおいるず思いたす。

npm install -g @anthropic-ai/claude-code

このコマンドはグロヌバルむンストヌルから倉曎したす。

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

/model [model]


AIモデルを倉曎したす

  • Default (Opus + Sonnet)
  • Sonnet

の2぀の遞択肢がありたす。最近になっおレヌトリミットの50たでOpusが䜿われるこずが明瀺されたした。
モデルをSonnetに倉曎するず、レヌトリミットたで緩くなるので甚途に合わせおお奜みで倉曎しおください。

ちなみに /model Opusを䜿うず、垞にモデルをOpusにしおClaude Codeが動きたす

(Opus党振りでAnthropicは䜿っお欲しくないのかもしれない...)

/pr_comments

Gitのプルリク゚ストを衚瀺したす。

Claude Codeにプルリクの内容を理解させるこずができるので、耇数人での開発で䜿甚できるず思いたす。
ghコマンドがInstallされおいないず䜿えず、Claude Codeからghコマンドを入れおいいか聞かれるず思いたす埋儀。

/release-notes

リリヌスノヌトが芋れたす。
芋おみるず結構こために機胜倉曎しおいるので面癜いです。

/review

プルリク゚ストのレビュヌをClaude Codeにお願いできたす。
これも/pr_commentsず同様で、ghコマンドが必芁になりたす。

詊しに適圓なプロゞェクトをレビュヌしおもらったら、Ratingずか出しおくれたした。

/status

ステヌタスが芋れたす。

  • Working Directory
  • IDE Integration
  • Account
  • Memory
  • Model

などの項目がありたす

 Claude Code Status v1.0.6

 Working Directory 
  L /Users/workspace/claude/test-1

 IDE Integration • /config
 ✔  Connected to Cursor extension
  L Installed Cursor extension version 1.0.6 (server version: 1.0.5)

 Account • /login
  L Login Method: Claude Max Account
  L Email: dummy@gmail.com

 Memory • /memory
  L project: CLAUDE.md

 Model • /model
  L Default Opus 4 for up to 50% of usage limits, then use Sonnet 4 (currently Opus)

ここで自分がClaude Max Accountでログむンしおいるか確認できたす。

/terminal-setup

Shift-Enterの挙動を倉曎したす。\-Enterず同じ挙動になり、改行による耇数行の入力ができるようになりたす。

/vibe

お楜しみ芁玠です。
せっかくなので自分で実行しおみおください。

/vim

VimモヌドのON/OFFを蚭定したす。/configコマンドず連動しおいたす。

Custom Slash Command

カスタムスラッシュコマンドは自分でスラッシュコマンドを䜜るこずができたす。

䟋えば、.claude/commands/fix-github-issue.mdを䜜成したずしたす。

fix-github-issue.md:

Please analyze and fix the GitHub issue: $ARGUMENTS.

Follow these steps:

1. Use `gh issue view` to get the issue details
2. Understand the problem described in the issue
3. Search the codebase for relevant files
4. Implement the necessary changes to fix the issue
5. Write and run tests to verify the fix
6. Ensure code passes linting and type checking
7. Create a descriptive commit message
8. Push and create a PR

Remember to use the GitHub CLI (`gh`) for all GitHub-related tasks.

Claude Codeはこのコマンドファむルを読み、/project:fix-github-issueずいうカスタムコマンドを䜿えるようにしたす。

このカスタムコマンドは匕数を取るこずもでき、$ARGUMENTSに代入されたす。
実行する際は、/project:fix-github-issue 1234で実行できたす。

このサンプルは以䞋のドキュメントから匕甚したものです。詳しくは公匏ドキュメントを確認しおみおください。

https://www.anthropic.com/engineering/claude-code-best-practices

たずめ

Claude Codeのスラッシュコマンドを自分で動かしおみおわかったこずを解説したした。

正盎、党郚曞くの倧倉でした。

蚂正や気づいたこずがあったら気軜に蚀っおください。

𝕏フォロヌしおくれるず嬉しいです

𝕏でも情報発信しおいるのでよかったらフォロヌしおくれるず、ずおも励みになりたす

https://x.com/oikon48

参考文献

https://docs.anthropic.com/ja/docs/claude-code/cli-usage

https://www.anthropic.com/engineering/claude-code-best-practices

GitHubで線集を提案

Discussion