Skip to content
←INDEX / 提示詞庫
TUTORIAL/Claude Code/進階

Claude Code 自訂 slash command 設計器:把重複貼的指令變成一鍵 /command

把你每次都要重貼的 checklist 或多步驟流程,設計成一個自訂 slash command(.claude/commands/<name>.md 或現代的 .claude/skills),含正確 frontmatter、$ARGUMENTS 參數、用 !`cmd` 預先注入即時上下文(git diff、PR 內容),並用 allowed-tools 收斂權限。

SakuyaPromptCraft 主筆 · 寫於 2026-06-08
AI 教學 / 腳本Claude Code進階預期輸出說明≈ 829 tokens · 實際用量依工具與輸入而異
Last reviewed2026-06-08Read~14 MIN

01PROMPT

Design a reusable Claude Code slash command for the workflow described below, then create the file(s) and explain how to use it.

Workflow I keep repeating: {{WORKFLOW_DESCRIPTION}}
What I'd type to trigger it: /{{COMMAND_NAME}}
Arguments it should accept (if any): {{ARGUMENTS}}
Live context it should pull in automatically (shell commands whose output should be injected, e.g. `git diff HEAD`, `gh pr diff`): {{LIVE_CONTEXT}}
Tools it legitimately needs (e.g. Read, Grep, Bash(git *)): {{TOOLS_NEEDED}}

Follow these steps:

1. CHOOSE THE FORMAT (state your choice and why).
   - Simplest: a single markdown file at `.claude/commands/{{COMMAND_NAME}}.md`. The filename becomes `/{{COMMAND_NAME}}`. This still works and is the lightest option.
   - Recommended if it needs supporting files, a subagent, or auto-invocation: a skill at `.claude/skills/{{COMMAND_NAME}}/SKILL.md`. Same `/` invocation, but supports a directory of helper files.
   Default to the commands/ file unless the workflow clearly needs the extra features.

2. WRITE THE FRONTMATTER (YAML between --- markers). Use only fields that earn their place:
   - `description:` — one line, written so a teammate reading the `/` menu knows exactly what it does and when to use it.
   - `argument-hint:` — if it takes args, show them, e.g. `[issue-number]` or `[component] [from] [to]`.
   - `allowed-tools:` — list ONLY the tools this command should run without asking, scoped tightly. A lint command listing `Bash(npm run lint:*)` and nothing else cannot accidentally edit files. Do not grant broad Bash or Edit unless the workflow truly needs it.
   - `disable-model-invocation: true` — add this ONLY for commands with side effects you want to control timing on (deploy, commit, send-message), so Claude never fires them on its own.

3. WRITE THE BODY (the instructions). Make it a precise, ordered procedure, not prose. Rules:
   - Reference arguments with `$ARGUMENTS` (everything after the command) or by position with `$1`, `$2`, or `$ARGUMENTS[0]`. Wrap multi-word arg values in quotes when invoking.
   - To inject live state, put `` !`<shell command>` `` on its own line (or after whitespace). Claude Code runs the command BEFORE the model sees the file and replaces the line with the output — so the model receives real data (e.g. the actual diff), not the command. Use this for {{LIVE_CONTEXT}}. For multi-line, use a fenced ```! block.
   - Spell out acceptance criteria: what 'done' looks like, and what to do on the empty/error case (e.g. 'if the diff is empty, say there are no changes').
   - Keep it tight — once invoked, the body stays in context for the rest of the session, so every line is a recurring token cost.

4. CREATE the file(s) with the content you designed.

5. EXPLAIN: show me exactly what to type to run it (with a realistic example using my arguments), confirm whether teammates get it automatically (yes, if committed under .claude/), and note that project-level commands/skills require accepting the workspace-trust dialog before `allowed-tools` takes effect.

Constraints: do not invent frontmatter fields that don't exist. Do not put `allowed-tools` permissions broader than the workflow needs. If part of the workflow is genuinely risky (e.g. it deploys), call that out and set `disable-model-invocation: true`.

把方括號 [ ] 內的變數換成你的內容,丟進 Claude Code。

◆ 直接開到工具Claude(記得貼)
RUN站內試跑 / TRY IT
▶ 站內試跑

不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。

SKILL安裝成 SKILL / INSTALL
安裝成 SKILLClaude Code Agent Skill

不只複製貼上 — 下載後放到 ~/.claude/skills/slash-command-designer/SKILL.md,之後每個 session 自動可用(觸發時自動載入)。

macOS / Linux
mkdir -p ~/.claude/skills/slash-command-designer && mv ~/Downloads/SKILL.md ~/.claude/skills/slash-command-designer/SKILL.md
Windows PowerShell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\slash-command-designer" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\SKILL.md" "$env:USERPROFILE\.claude\skills\slash-command-designer\SKILL.md"

02CONTEXT / 使用情境

【何時用】當你發現自己第三次把同一段「幫我做 X 的步驟」貼進 Claude Code 時。【為何有效】(1) 它先幫你選對載體——輕量需求用 .claude/commands/<name>.md(檔名即指令名,至今仍可用),需要附帶腳本/子代理/自動觸發才升級成 .claude/skills/<name>/SKILL.md;(2) frontmatter 只留真正有用的欄位:description 讓隊友在 / 選單看得懂、allowed-tools 把權限收到剛好(例如只給 Bash(npm run lint:*) 的 lint 指令就不可能誤改檔案)、有副作用的(deploy/commit)加 disable-model-invocation:true 避免 Claude 自作主張;(3) 教你用 !`git diff` 這種『執行注入』把即時狀態在模型讀到前就塞進去,所以模型拿到的是真 diff 而非一句指令。【技巧】把 command 檔 commit 進 .claude/ 後全隊自動共用;專案層的 allowed-tools 要先接受 workspace-trust 對話框才生效。參數用 $ARGUMENTS 抓全部、$1/$2 抓單一位置,多字參數記得加引號。

03SAMPLE / 期待成果

Chosen format: .claude/commands/summarize-changes.md (lightweight, no supporting files needed) --- description: Summarize uncommitted changes and flag risks. Use when asked what changed or for a commit message. allowed-tools: Bash(git diff:*) Bash(git status:*) --- ## Current changes !`git diff HEAD` ## Task Summarize the diff above in 2-3 bullets, then list risks (missing error handling, hardcoded values, tests to update). If the diff is empty, say there are no uncommitted changes. How to run: /summarize-changes Teammates get it automatically once .claude/commands/ is committed. Project-level allowed-tools activates after you accept the workspace-trust dialog.

這是預期成果的文字說明。請查看本文實測說明,並以自己的輸入素材小規模試用。

04VARIABLES / 變數說明

01[WORKFLOW_DESCRIPTION]

你重複在做的流程,講清楚步驟與目的,例如「總結未提交的改動並標出風險、給 commit message」

02[COMMAND_NAME]

想用的指令名(kebab-case),例如 summarize-changes、fix-issue、review-pr

03[ARGUMENTS]

指令要吃的參數(沒有就寫『無』),例如「issue 編號」或「元件名 來源框架 目標框架」

04[LIVE_CONTEXT]

要自動注入的即時上下文 shell 指令(沒有就寫『無』),例如 `git diff HEAD`、`gh pr diff`、`git status --short`

05[TOOLS_NEEDED]

這指令合理需要、且希望免按同意的工具,盡量收窄,例如 Read、Grep、Bash(git add *) Bash(git commit *)

05RESOLVER · 變數代入器0 / 5

填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。

修飾
Assembled · 填剩餘變數…
Design a reusable Claude Code slash command for the workflow described below, then create the file(s) and explain how to use it.

Workflow I keep repeating: {{WORKFLOW_DESCRIPTION}}
What I'd type to trigger it: /{{COMMAND_NAME}}
Arguments it should accept (if any): {{ARGUMENTS}}
Live context it should pull in automatically (shell commands whose output should be injected, e.g. `git diff HEAD`, `gh pr diff`): {{LIVE_CONTEXT}}
Tools it legitimately needs (e.g. Read, Grep, Bash(git *)): {{TOOLS_NEEDED}}

Follow these steps:

1. CHOOSE THE FORMAT (state your choice and why).
   - Simplest: a single markdown file at `.claude/commands/{{COMMAND_NAME}}.md`. The filename becomes `/{{COMMAND_NAME}}`. This still works and is the lightest option.
   - Recommended if it needs supporting files, a subagent, or auto-invocation: a skill at `.claude/skills/{{COMMAND_NAME}}/SKILL.md`. Same `/` invocation, but supports a directory of helper files.
   Default to the commands/ file unless the workflow clearly needs the extra features.

2. WRITE THE FRONTMATTER (YAML between --- markers). Use only fields that earn their place:
   - `description:` — one line, written so a teammate reading the `/` menu knows exactly what it does and when to use it.
   - `argument-hint:` — if it takes args, show them, e.g. `[issue-number]` or `[component] [from] [to]`.
   - `allowed-tools:` — list ONLY the tools this command should run without asking, scoped tightly. A lint command listing `Bash(npm run lint:*)` and nothing else cannot accidentally edit files. Do not grant broad Bash or Edit unless the workflow truly needs it.
   - `disable-model-invocation: true` — add this ONLY for commands with side effects you want to control timing on (deploy, commit, send-message), so Claude never fires them on its own.

3. WRITE THE BODY (the instructions). Make it a precise, ordered procedure, not prose. Rules:
   - Reference arguments with `$ARGUMENTS` (everything after the command) or by position with `$1`, `$2`, or `$ARGUMENTS[0]`. Wrap multi-word arg values in quotes when invoking.
   - To inject live state, put `` !`<shell command>` `` on its own line (or after whitespace). Claude Code runs the command BEFORE the model sees the file and replaces the line with the output — so the model receives real data (e.g. the actual diff), not the command. Use this for {{LIVE_CONTEXT}}. For multi-line, use a fenced ```! block.
   - Spell out acceptance criteria: what 'done' looks like, and what to do on the empty/error case (e.g. 'if the diff is empty, say there are no changes').
   - Keep it tight — once invoked, the body stays in context for the rest of the session, so every line is a recurring token cost.

4. CREATE the file(s) with the content you designed.

5. EXPLAIN: show me exactly what to type to run it (with a realistic example using my arguments), confirm whether teammates get it automatically (yes, if committed under .claude/), and note that project-level commands/skills require accepting the workspace-trust dialog before `allowed-tools` takes effect.

Constraints: do not invent frontmatter fields that don't exist. Do not put `allowed-tools` permissions broader than the workflow needs. If part of the workflow is genuinely risky (e.g. it deploys), call that out and set `disable-model-invocation: true`.
FAQ · 常見問題

「Claude Code 自訂 slash command 設計器:把重複貼的指令變成一鍵 /command」這組提示詞要怎麼用?

這組 prompt 專為 Claude Code 設計。把 prompt 內 5 個方括號 [變數] 換成你自己的內容,貼進 Claude Code 執行即可。難度中等,照變數說明填好後即可上手。

「Claude Code 自訂 slash command 設計器:把重複貼的指令變成一鍵 /command」是免費的嗎?

完整 prompt 免費開放閱讀,不用註冊;可保存瀏覽器收藏,登入後可一鍵複製與留言。

用 Claude Code 依這組 prompt 生成的成果可以商用嗎?

prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 Claude Code 使用的方案與其官方服務條款,請以該工具的授權規範為準。

RELATED你可能也需要

PRO01
TUTORIALSuno v5.5FEATURED
r/SunoAI (anonymous studio engineer)2026-06-12

Suno 工程師思維:4 步驟做出不像 AI 的歌

5.0(1)

Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt

高階
Read

免費02
TUTORIALClaude 4.5 SonnetFEATURED
r/ClaudeAI2026-05-14

5 個 6 月 stuck 下來的 Claude 每週 workflow

提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。

進階
Read

PRO03
TUTORIALClaude 4.5 SonnetFEATURED
r/PromptEngineering2026-05-14

7 個跨 model A/B 測過的 prompt 技巧(不是 vibes)

六個月在 Claude / GPT-4 / Gemini 上用人工 rater A/B 測 200+ prompt 後寫的。包含 persona+constraint stacking / anti-example / role reversal QA / cognitive scaffold / emotional priming / uncertainty CoT / steelman first。

高階
Read

免費04
TUTORIALChatGPTFEATURED
r/ChatGPTPromptGenius2026-05-14

5 個信任檢查單行 prompt(沒有 role-play)

一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。

入門
Read

免費 · 全文開放閱讀

完整 prompt 已經開放.

免登入閱讀全文、保存瀏覽器收藏;登入後可一鍵複製與留言討論。不用信用卡。

不想註冊?

留個 email,下次有新 prompt 會寄一封簡短摘要給你。退訂一鍵、不轉賣。

每週一期,新上架提示詞 + 模型測試心得。每封信底部都有一鍵取消訂閱。

或訂 RSS feed(30 秒一次的人味選擇)

COMMENTS · 討論區0 則
登入 後可留言。還沒帳號?註冊
目前沒有留言。第一個說說你的經驗。
EMBED · 嵌入 blog / Note一行 iframe HTML、貼進文章即顯示此 prompt 卡片+

適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。

<iframe src="https://prompt.luvai.net/embed/claude-code-slash-command-designer" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
預覽 embed →380px tall · responsive width
發現這個 prompt 過時 / 跑不動 / 有錯字? 回報給我們 →