⌨️ HN #1 トピック

Claude Code Slash Commands — 8 組み込み + カスタム完全ガイド

/init /review /compact /cost /loop /schedule /plugin /help 全リスト + .claude/commands/ カスタムコマンド project/personal 2 スコープ。

8 つの組み込み slash コマンド

1) **/init** — プロジェクト初期化(CLAUDE.md + .claude/ 生成) 2) **/review** — コードレビュー実行(active plugin の review skill 利用) 3) **/compact** — 現在の会話コンテキストを圧縮、ヘビーユーザーは 20-30 分ごとに使用 4) **/cost** — 当セッションの token 使用量と費用見積もり 5) **/loop** — prompt / コマンドのポーリング実行(デプロイ監視等) 6) **/schedule** — Routine 作成(Routines ガイド参照) 7) **/plugin** — plugin 閲覧 / インストール / 無効化(projected context cost 表示) 8) **/help** — コマンド一覧

/compact が最頻用法

経験豊富な Claude Code ユーザーは「アクティブ作業中 20-30 分ごとに /compact 実行」と報告、長セッション後半のモデル品質低下を大幅軽減。Compact は現在の会話を要約 + 重要 artifact パス保持し、中間 churn を削除。plugin の projected context cost 表示と組み合わせて token 予算を精密管理。新セッション開始との違い:作業記憶とサブエージェント状態を保持。

カスタム slash コマンド — project vs personal

カスタムコマンドは markdown ファイルとして保存、ファイル名 = コマンド名、本文 = Claude に注入する prompt。2 スコープ: - **Project**:`<repo>/.claude/commands/<name>.md`(チーム共有、git バージョン管理) - **Personal**:`~/.claude/commands/<name>.md`(自分のマシンのみ、全プロジェクト共通) 例:`.claude/commands/deploy-staging.md` に「.deploy.yml に従って staging 実行、restart、15s sleep、curl ヘルスチェック」を書けば、チーム誰でも /deploy-staging で起動可能。

Hook / Subagent / Plugin との関係

**Hook** はイベント駆動の副作用(PostToolUse / PreCommit)、ユーザー直接呼び出し不可。**Subagent** は dispatch 可能なタスクユニット。**Plugin** はクライアント機能パッケージ(hook + skill + slash command 含むことも)。**Slash command** はユーザー呼び出しのショートカット。1 つの plugin が複数 slash command を提供可能。カスタム作成前に判断:コマンド(/x)、自動化(hook)、タスク(subagent)のどれ?

FAQ

チーム slash コマンドを新メンバーに配布する方法は?

`.claude/commands/` を git バージョン管理に入れる。新メンバーが repo を clone すれば即利用可能。`~/.claude/commands/` は個人領域、各自で管理。

slash コマンドに引数を渡せる?

可能。コマンドファイル本文に `{{ARGS}}` プレースホルダーを使えば、`/cmd arg1 arg2` の追加テキストを受け取れます。Claude が置換して完全 prompt を注入。Claude Code docs 参照。

Codex に似た slash コマンドある?

あり。Codex CLI に `/goal` `/mcp` 等のコマンド。セマンティクスと拡張メカニズムは若干異なる。Codex のカスタムコマンド機構は現状 Claude Code ほど柔軟ではない。

QCode 経由で Claude Code 全機能を活用

中国国内から Claude へ透明接続、全 slash コマンド・カスタム・plugin 海外と同じ体験。

QCode プランを開始