Skip to content

Prompt Templates

✓ Fresh · 2026-02-24

Prompt templates are reusable Markdown prompts with variable interpolation. They let you standardize common requests and invoke them with a single slash command.

Creating a Template

Place a .md file in any prompts directory:

markdown
<!-- ~/.pi/agent/prompts/review.md -->
Review this code for bugs, security, and performance.
Focus on: {{focus}}

Variable Interpolation

Templates support syntax for dynamic content. When you invoke a template, Pi prompts you to fill in each variable:

markdown
<!-- ~/.pi/agent/prompts/refactor.md -->
Refactor the following code:
- File: {{file}}
- Goal: {{goal}}
- Constraints: {{constraints}}

Apply best practices for {{language}}.

When you type /refactor, Pi asks for each variable value before sending the prompt.

Template Directories

DirectoryScope
~/.pi/agent/prompts/Global (all projects)
.pi/prompts/Project-specific
Pi packagesInstalled via pi install

Invoking Templates

Templates are available as slash commands using the filename (without .md):

/review          # invokes review.md
/refactor        # invokes refactor.md
/commit-msg      # invokes commit-msg.md

They appear alongside built-in commands in the / completion menu.

Example Templates

Code Review

markdown
<!-- prompts/review.md -->
Review this code for:
1. Bugs and logic errors
2. Security vulnerabilities
3. Performance issues
4. Code style

Focus area: {{focus}}
Severity threshold: {{severity}}

Commit Message

markdown
<!-- prompts/commit-msg.md -->
Write a conventional commit message for the staged changes.
Type: {{type}}
Scope: {{scope}}

Follow the format: type(scope): description

Include a body if the changes are significant.

Bug Report

markdown
<!-- prompts/bug-report.md -->
Help me investigate this bug:

Description: {{description}}
Steps to reproduce: {{steps}}
Expected behavior: {{expected}}
Actual behavior: {{actual}}

Start by reading relevant source files, then identify the root cause.

Test Generation

markdown
<!-- prompts/test.md -->
Generate tests for {{file}}.

Testing framework: {{framework}}
Coverage goal: {{coverage}}

Include:
- Unit tests for all public functions
- Edge cases
- Error handling tests

Template Workflow

Templates vs Skills

AspectPrompt TemplatesSkills
PurposeReusable user promptsAgent knowledge packages
FormatMarkdown with Plain Markdown
Invocation/templatename/skill:name or auto
VariablesYes, user-filledNo
Auto-loadedNoYes (when relevant)
Best forStandardized requestsDomain expertise

Pi Coding Agent SOP Documentation