On this page
Prompt Templates
Prompt Templates
#Prompt templates turn Markdown files into reusable / commands. Use one when you want to reuse the same prompt without adding executable behavior or a larger set of supporting instructions.
A template can accept arguments and appear in command completion. pig can load templates from personal configuration, project configuration, an explicit path, or a pig package. Project configuration loads only after project trust is granted.
Create a template
#Create ~/.pig/agent/prompts/review.md:
---
description: Review staged git changes
argument-hint: "[focus]"
---
Review the staged changes. Focus on ${1:-correctness, security, and error handling}.
The filename becomes the command name, so this template is available as /review. The description appears in command completion. If it is omitted, pig uses the first non-empty line.
argument-hint is optional and must be a YAML string. Use <angle brackets> for required arguments and [square brackets] for optional arguments.
Run /reload after adding or changing a template in an active session.
Use a template
#Type the template command in the editor:
/review
/review concurrency
pig expands the template before the resulting text enters the agent. Extensions receive the raw input first through the input event unless an extension command with the same name handles it.
Templates support these substitutions:
| Syntax | Result |
|---|---|
$1, $2, … | One positional argument |
$@ or $ARGUMENTS | All arguments joined with spaces |
${1:-default} | First argument, or a default value |
${@:-default} or ${ARGUMENTS:-default} | All arguments, or a default value |
${@:N} | Arguments starting at position N |
${@:N:L} | L arguments starting at position N |
Arguments follow shell-like quoting, so /review "API compatibility" supplies one argument containing a space.
Add it to pig
#Place the template in your user (~/.pig/agent/prompts/) or project (.pig/prompts/) prompt directory. pig reads prompts/ only; it has no compatibility with a commands/ directory. Conventional prompt directories load direct .md children only, while directories named in settings are walked. When two templates have the same name, the first one found wins and pig reports the collision. --prompt-template <path> adds one for a run and --no-prompt-templates turns discovery off.
Settings and packages can select nested Markdown files; a package manifest can narrow discovery with explicit paths and globs. See Settings and pig Packages for these options.
Project templates become commands in the editor after trust is granted. Review their content before trusting an unfamiliar project. See Security.