提示模板
pi 可以建立 prompt templates。要求它為您的工作流程建立一個。
提示範本是 Markdown 片段,可擴充為完整提示。在編輯器中輸入/name以呼叫模板,其中name是不帶.md的檔名。
地點
Pi 從以下位置載入 prompt templates:
- 全球:
~/.pi/agent/prompts/*.md - 項目:
.pi/prompts/*.md(僅在專案信任後) - 包:
prompts/目錄或package.json中的pi.prompts條目 - 設定:
prompts包含檔案或目錄的陣列 - CLI:
--prompt-template <path>(可重複)
使用 --no-prompt-templates 禁用發現。
格式
---
description: Review staged git changes
---
Review the staged changes (`git diff --cached`). Focus on:
- Bugs and logic errors
- Security issues
- Error handling gaps- 檔案名稱成為命令名。
review.md變為/review。 description是可選的。如果遺失,則使用第一個非空白行。argument-hint是可選的。設定後,提示將顯示在自動完成下拉清單中的描述之前。
論證提示
在 frontmatter 中使用 argument-hint 來顯示自動完成中的預期參數。使用 <angle brackets> 作為必需參數,使用 [square brackets] 作為可選參數:
---
description: Review PRs from URLs with structured issue and code analysis
argument-hint: "<PR-URL>"
---這在自動完成下拉清單中呈現為:
→ pr <PR-URL> — Review PRs from URLs with structured issue and code analysis
is <issue> — Analyze GitHub issues (bugs or feature requests)
wr [instructions] — Finish the current task end-to-end
cl — Audit changelog entries before release用法
在編輯器中鍵入 /,後面跟著模板名稱。自動完成顯示可用範本和描述。
/review # Expands review.md
/component Button # Expands with argument
/component Button "click handler" # Multiple arguments論據
模板支援位置參數、預設值和簡單切片:
$1,$2,... 位置參數$@或$ARGUMENTS對於所有加入的參數- 當存在/非空時,
${1:-default}使用arg 1,否則default ${@:-default}或${ARGUMENTS:-default}在存在/非空時使用所有參數,否則default${@:N}對於第 N 個位置的參數(1-索引)${@:N:L}代表從 N 開始的L參數
例子:
---
description: Create a component
---
Create a React component named $1 with features: $@預設值對於可選參數很有用:
Summarize the current state in ${1:-7} bullet points.用法:/component Button "onClick handler" "disabled support"
載入規則
prompts/中的模板發現是非遞歸的。- 如果您想要子目錄中的模板,請透過
prompts設定或套件清單明確新增它們。