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

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [reference.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/claude-code-command-author/reference.md), [templates/file-reference.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/claude-code-command-author/templates/file-reference.md), [templates/fork.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/claude-code-command-author/templates/fork.md), [templates/git-context.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/claude-code-command-author/templates/git-context.md), [templates/minimal.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/claude-code-command-author/templates/minimal.md).
>
> If the user asked to install this Skill, run `npx skilld install superstone-han/dotfiles/claude-code-command-author`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/claude-code-command-author`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/superstone-han/dotfiles/claude-code-command-author) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/claude-code-command-author`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/claude-code-command-author --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/claude-code-command-author --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Claude Code Command Author

ユーザーの要望を **Claude Code の Custom slash command（Markdownファイル）** に落とし込み、再利用可能なコマンドとして追加できる状態にする。

## Goals
- ユーザーの依頼から **コマンドの目的・引数・出力**を明確化する
- **正しいコマンドファイル（YAML frontmatter + Markdown本文）**を生成する
- 置き場所・命名・引数設計・事前コンテキストなどを適切に選定する
- ユーザーがそのまま `.claude/commands/` または `~/.claude/commands/` に置ける形で出力する

## Non-goals
- Skillの作成（それは`skill-skillsmith`の役割）
- コマンド自体を実行すること（生成・設計まで）

---

## Inputs
- コマンドで何をしたいか（目的）
- コマンド名の候補（任意、なければ提案）
- スコープ（project / personal、任意）
- 引数の要件（任意）
- 事前に埋め込みたいコンテキスト（任意、git status/diff等）

## Outputs
1. **作成/更新するファイルパス**（例: `.claude/commands/review-pr.md`）
2. **ファイル内容（完成版Markdown）**
3. **利用例＆テスト手順**（`/help`で確認、実行例）

---

## Instructions

### Step 0: 要件の最小セットを確定する
不足している場合は **最小限だけ** 確認する（質問攻めにしない）。

確認項目：
- コマンド目的（何をしたい？何を出力したい？）
- コマンド名候補（`/review-pr` 的なやつ）
- スコープ: project (`.claude/commands/`) or personal (`~/.claude/commands/`)
- 引数設計: フリーフォーム(`$ARGUMENTS`) or 位置引数(`$1`, `$2`, ...)
- 事前コンテキスト: bash埋め込み(!) / ファイル参照(@)
- 安全性: 読み取り中心？書き換えあり？

**デフォルト方針**（ユーザーが指定しない場合）：
- スコープ: project（`.claude/commands/`）
- コマンド性質: 読み取り中心（安全）
- 引数: 1つなら `$ARGUMENTS`、複数の役割があるなら `$1..`

### Step 1: パスと命名を決める
- コマンド名は **ファイル名（`.md`除く）** で決まる
- 命名は **kebab-case**（例: `review-pr.md` → `/review-pr`）
- namespacingしたい場合はサブディレクトリ
  - 例: `.claude/commands/frontend/test.md`
  - ※サブディレクトリはコマンド名に影響しない（表示上の区別）
- 衝突回避: projectとpersonalが同名ならprojectが優先

### Step 2: frontmatter を設計する
必須：
- `description`: 何をするコマンドか（`/help`で表示される）

推奨：
- `argument-hint`: 補完時に出る引数ヒント（引数ありの場合）

必要に応じて：
- `allowed-tools`: ! bash実行を使うなら必要（最小権限で）
- `model`: 特定モデル固定したい場合
- `context: fork` + `agent`: 会話を汚したくない/重い作業を分離
- `disable-model-invocation: true`: Skill toolからの自動呼び出しを避けたい

### Step 3: 引数の受け取り設計
- まとめて扱う: `$ARGUMENTS`
- 役割がある: `$1`, `$2`, `$3`（PR番号、優先度、担当など）
- `argument-hint`でユーザーが迷わない形にする

### Step 4: コマンド本文を設計する
本文は「Claudeにやってほしいこと」を **手順＋出力仕様** で書く。

推奨構造：
- 目的（何を達成するか）
- 入力（引数、参照ファイル、前提）
- 手順（箇条書き）
- 出力形式（Markdown、チェックリスト、差分提案など）
- 制約（例: 「ファイル編集は禁止」「提案のみ」など）
- 完了条件（DoD）

### Step 5: 事前コンテキスト埋め込み（必要なら）
#### bash事前実行（!）
```
!`git status`
!`git diff HEAD`
```
- `allowed-tools`で`Bash(...)`を許可する
- 危険なコマンドは許可しない（`rm`, `curl`, `deploy`等は原則不可）

#### ファイル参照（`@path`）
- `@src/...`のように書くとファイル内容をコンテキストに含められる
- コマンド目的に直結する最小限のファイルだけ参照する

### Step 6: 最終アウトプットを生成する
以下の3点をユーザーに渡す：
1. 作成/更新するファイルパス
2. ファイル内容（完成版）
3. 利用例＆テスト手順

---

## Output format (MUST)

```md
## Files
- .claude/commands/<command-name>.md

## .claude/commands/<command-name>.md
\```md
---
description: <short description>
argument-hint: [optional-args]
---

# <Command Title>

## Your task
- ...

## Constraints
- ...

## Output
- ...
\```

## Usage
- `/command-name [args]`
- 確認: `/help` で description が表示されるか
```

---

## Quality Checklist
- [ ] 置き場所は正しいか（project `.claude/commands/` / personal `~/.claude/commands/`）
- [ ] ファイル名がコマンド名として適切か（`kebab-case`）
- [ ] `description` が入っているか（/helpで分かる）
- [ ] 引数があるなら `argument-hint` があるか
- [ ] `$ARGUMENTS` / `$1..` の設計が目的に合っているか
- [ ] ! を使うなら `allowed-tools` に Bash が適切に絞られているか
- [ ] `@file` 参照は最小限か
- [ ] 制約（編集禁止など）が明記されているか
- [ ] `/help` と実行例のテスト手順が書かれているか

---

## Examples

### Example 1
ユーザー: 「PRレビューを毎回同じ観点でやりたいから `/review-pr` 作って。引数はPR番号と優先度と担当。」

→ `.claude/commands/review-pr.md` を生成。`$1..` + `argument-hint` あり。

### Example 2
ユーザー: 「コミットメッセージ作成をコマンド化したい。実行前にgit statusとdiffを入れて。」

→ `allowed-tools` + ! を使うコマンドを生成（危険コマンドは許可しない）。

### Example 3
ユーザー: 「このリポジトリの特定ファイルを説明する `/explain-file` を作って。パスを引数で渡す。」

→ `$ARGUMENTS` で受け、@参照を使う運用を提案。

### Example 4（非対象）
ユーザー: 「このPRをレビューして」

→ これは "コマンド生成" ではなく "レビュー実行"。本Skillは発動せず、通常対応。

---

## Guardrails
- 破壊的操作（削除/デプロイ/課金リソース作成など）を含むコマンドは、明示的なユーザー同意がある場合のみ設計する
- `allowed-tools` は最小権限。可能なら read-only（`git status`, `git diff`）に限定
- ファイル編集を伴う用途では「編集範囲」「バックアップ方針」「確認ステップ」をコマンド本文に含める

---

## References
- [Slash commands - Claude Code Docs](https://code.claude.com/docs/en/slash-commands)
- [Agent Skills - Claude Code Docs](https://code.claude.com/docs/en/skills)
- 詳細仕様: @reference.md
- テンプレート: @templates/
