指令
為重複性任務建立自訂指令。
自訂指令可讓您指定在會話中執行該指令時要執行的提示詞。
/my-command
自訂指令是除了 /init、/undo、/redo、/help 等內建指令之外的功能。了解更多。
建立指令檔案
在 commands/ 目錄中建立 Markdown 檔案以定義自訂指令。
建立 .dropstone/commands/test.md:
---
description: Run tests with coverage
agent: build
model: dropstone/dropstone-pro
---
Run the full test suite with coverage report and show any failures.
Focus on the failing tests and suggest fixes.
Frontmatter 定義指令屬性。內容則成為範本。
輸入 / 後接指令名稱即可使用該指令。
/test
設定
您可以透過 Dropstone 設定或在 commands/ 目錄中建立 Markdown 檔案來新增自訂指令。
JSON
在您的 Dropstone 設定 中使用 command 選項:
{
"$schema": "https://dropstone.io/schema/config.json",
"command": {
// This becomes the name of the command
"test": {
// This is the prompt that will be sent to the LLM
"template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes.",
// Shown as the description in the slash command palette
"description": "Run tests with coverage",
"agent": "build",
"model": "dropstone/dropstone-pro"
}
}
}
現在您可以從任何會話執行此指令:
/test
Markdown
您也可以使用 Markdown 檔案定義指令。將它們放置在:
- 全域:
~/.config/dropstone/commands/ - 專案內:
.dropstone/commands/
---
description: Run tests with coverage
agent: build
model: dropstone/dropstone-pro
---
Run the full test suite with coverage report and show any failures.
Focus on the failing tests and suggest fixes.
Markdown 檔案名稱即為指令名稱。例如,test.md 可讓您執行:
/test
提示詞設定
自訂指令的提示詞支援多種特殊佔位符和語法。
引數
使用 $ARGUMENTS 佔位符將引數傳遞給指令。
---
description: Create a new component
---
Create a new React component named $ARGUMENTS with TypeScript support.
Include proper typing and basic structure.
使用引數執行指令:
/component Button
$ARGUMENTS 將被替換為 Button。
您也可以使用位置參數存取個別引數:
$1- 第一個引數$2- 第二個引數$3- 第三個引數- 依此類推...
例如:
---
description: Create a new file with content
---
Create a file named $1 in the directory $2
with the following content: $3
執行指令:
/create-file config.json src "{ \"key\": \"value\" }"
這會替換:
$1為config.json$2為src$3為{ "key": "value" }
Shell 輸出
使用 !command 將 shell 指令 的輸出注入到您的提示詞中。
例如,建立一個分析測試覆蓋率的自訂指令:
---
description: Analyze test coverage
---
Here are the current test results:
!`npm test`
Based on these results, suggest improvements to increase coverage.
或檢視最近的變更:
---
description: Review recent changes
---
Recent git commits:
!`git log --oneline -10`
Review these changes and suggest any improvements.
指令會在您專案的根目錄中執行,其輸出會成為提示詞的一部分。
檔案引用
使用 @ 後接檔案名稱,在指令中包含檔案。
---
description: Review component
---
Review the component in @src/components/Button.tsx.
Check for performance issues and suggest improvements.
檔案內容會自動包含在提示詞中。
選項
讓我們詳細了解設定選項。
範本
template 選項定義了執行指令時將發送給 LLM 的提示詞。
{
"command": {
"test": {
"template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes."
}
}
}
這是必填的設定選項。
描述
使用 description 選項提供指令功能的簡短描述。
{
"command": {
"test": {
"description": "Run tests with coverage"
}
}
}
這會顯示在斜線指令面板中指令的旁邊。
Agent
使用 agent 設定可選擇性地指定哪個 agent 應執行此指令。
如果這是 subagent,指令預設會觸發 subagent 呼叫。
若要停用此行為,請將 subtask 設為 false。
{
"command": {
"review": {
"agent": "plan"
}
}
}
這是選用的設定選項。若未指定,預設使用您目前的 agent。
Subtask
使用 subtask 布林值強制指令觸發 subagent 呼叫。
如果您希望指令不污染您的主要上下文,這會很有用,且會強制 agent 以 subagent 身分運作,
即使 agent 設定中的 mode 設為 primary 也是如此。
{
"command": {
"analyze": {
"subtask": true
}
}
}
這是選用的設定選項。
模型
使用 model 設定覆寫此指令的預設模型。
{
"command": {
"analyze": {
"model": "dropstone/dropstone-pro"
}
}
}
這是選用的設定選項。
內建指令
Dropstone 包含多個內建指令,如 /init、/undo、/redo、/help。了解更多。
內建的 /review 指令會執行多階段審查——尋找者角度、獨立驗證,然後是限制數量的發現清單。使用 review.effort 控制其深度。
Note
自訂指令可以覆寫內建指令。如果您定義的自訂指令與內建指令同名,自訂指令優先。