Index of every page on this site: llms.txt
All skills
superstone-han avatar

/claude-code-command-author

@f5f9792
Run it yourself

Claude Codeのカスタムslash command(Commands)を設計・生成・更新する。 「/コマンドを作りたい」「この作業を毎回同じ手順でやりたいのでコマンド化したい」「.claude/commandsにテンプレを追加したい」 「Claude Codeのcommands作って」「スラッシュコマンド作成」「引数付きコマンド」「allowed-toolsを設定したい」などの依頼で発動する。 プロジェクト用(.claude/commands)・個人用(~/.claude/commands)・サブディレクトリ(namespacing)・引数($ARGUMENTS/$1..)・bash事前実行(!)・ファイル参照(@)・context:fork などに対応する。

Use this Skill: https://skilld.dev/gh/superstone-han/dotfiles/claude-code-command-author

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

reference.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Claude Code Command Author Reference

このファイルは SKILL.md を薄く保つための詳細資料。


Claude Code Commands 仕様(公式準拠)

配置場所

スコープ パス 用途
project .claude/commands/ チーム共有、リポジトリにコミット
personal ~/.claude/commands/ 個人用、マシン固有

優先度: 同名の場合、project が personal を上書きする

ファイル名 → コマンド名

  • review-pr.md → /review-pr
  • frontend/test.md → /test(サブディレクトリは表示上の区別のみ)
  • kebab-case 推奨

Frontmatter 項目一覧

必須(強く推奨)

項目 説明 例
description /help で表示。Skill tool からの発動判定にも使用 PR を security/performance/style でレビュー

推奨

項目 説明 例
argument-hint 補完時に表示される引数ヒント [pr-number] [priority]
allowed-tools ! bash実行で許可するツール Bash(git status:*), Bash(git diff:*)

任意

項目 説明 例
model 使用モデルを固定 claude-sonnet-4-20250514
context fork で会話を分離 fork
agent fork時のエージェントタイプ general-purpose
disable-model-invocation Skill tool からの自動呼び出しを無効化 true
hooks コマンド実行中のフック (hooks仕様参照)

引数の受け取り方

$ARGUMENTS(フリーフォーム)

Review the following: $ARGUMENTS
  • 引数全体を1つの文字列として受け取る
  • シンプルな用途に最適

位置引数($1, $2, ...)

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

Review PR #$1 with priority $2 and assign to $3.
  • 役割が明確な複数引数に最適
  • 未指定の引数は空文字になる

事前コンテキスト埋め込み

bash事前実行(!)

コマンド本文で ! を使うと、実行前にbashを走らせて出力を埋め込める。

---
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*)
---

## Context
- status: !`git status`
- diff: !`git diff HEAD`
- recent commits: !`git log --oneline -10`

重要:

  • allowed-tools でBashを許可する必要がある
  • read-onlyコマンドに限定(rm, curl, deploy 等は許可しない)

ファイル参照(@path)

Review the following file: @src/main.ts

Or dynamically:
Review the file at: @$1
  • ファイル内容がコンテキストに含まれる
  • コマンド目的に直結する最小限のファイルだけ参照

allowed-tools の書き方

パターン

# 特定コマンド
allowed-tools: Bash(git status:*)

# 複数コマンド
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*)

# 引数パターン
allowed-tools: Bash(npm test:*)

安全なコマンド例(許可OK)

  • git status, git diff, git log, git branch
  • ls, cat, head, tail(読み取り系)
  • npm test, npm run lint(テスト系)
  • echo, date, pwd

危険なコマンド例(原則許可しない)

  • rm, rmdir, mv(破壊系)
  • curl, wget(外部通信)
  • npm install, pip install(パッケージ変更)
  • git push, git commit(リポジトリ変更)
  • deploy, kubectl apply(インフラ変更)

context: fork の使い方

会話を汚したくない、または重い処理を分離したい場合:

---
description: 重い分析タスク
context: fork
agent: general-purpose
---

<やること>

agent の選択肢:

  • general-purpose: 汎用(デフォルト)
  • explore: コードベース探索
  • 他のカスタムエージェント

トリガー語(description に入れる)

description に以下の語を含めると発動しやすくなる:

コマンド作成依頼

  • 「コマンド作って」「commands作成」「スラッシュコマンド」
  • 「毎回同じ手順で」「コマンド化」「再利用」
  • 「.claude/commands」「~/.claude/commands」
  • 「/xxx を作って」

コマンド機能キーワード

  • 「引数付き」「$ARGUMENTS」「$1」
  • 「git statusを埋め込み」「!` で実行」
  • 「@ファイル参照」「ファイル内容を含める」
  • 「fork」「会話を分離」

よくあるパターン

パターン1: シンプルなレビュー系

  • 読み取り専用
  • 引数は $ARGUMENTS で受け取り
  • 出力はMarkdown

パターン2: git状態を使う系

  • allowed-tools で git コマンドを許可
  • ! で status/diff/log を埋め込み
  • コミットメッセージ生成、差分レビューなど

パターン3: ファイル分析系

  • @ でファイル参照
  • 引数でパスを受け取り
  • 説明、リファクタ提案など

パターン4: 分離実行系

  • context: fork で会話を汚さない
  • 重い分析、長いタスク向け
  • 結果だけ返す

命名規則

コマンド名(ファイル名)

  • kebab-case: review-pr, explain-file, generate-commit
  • 動詞-名詞 または 名詞-動詞
  • 短く、意図が分かる

避けるべき名前

  • 既存の組み込みコマンドと衝突(/help, /clear 等)
  • 一般的すぎる(/do, /run, /go)
  • 長すぎる(20文字超)

デバッグ・テスト手順

  1. 配置確認

    ls -la .claude/commands/
  2. /help で表示確認

    • description が表示されるか
    • argument-hint が表示されるか
  3. 実行テスト

    /command-name test-arg
    • 期待通りの動作か
    • エラーがないか
  4. 引数テスト

    • 引数なしで実行
    • 引数ありで実行
    • 複数引数で実行

参考リンク

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning8mo3 checks · Risk SAFE
  • Gen Agent Trust Hub8mo

    This skill is a utility designed to help users create custom slash commands for Claude Code. It provides structured templates and clear instructions that emphasize security best practices, such as using 'allowed-tools' to restrict shell command execution to a safe white-list and explicitly forbidding the use of networking or destructive tools like curl and rm.

  • Socket8mo

    1 alert: gptSecurity

  • Snyk8mo

    Risk: LOW · No issues

Signed by skilld at f5f9792. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 10 months ago

README badge

README badge for superstone-han/dotfiles/claude-code-command-author