CodingOpen SourceFreeActiveMachine-verified· beginner · ~5 min setup

Pi: The Reusable Prompt Template

Turn a prompt you retype into a permanent Pi slash command.

by Shilpa Mitra· verified today· v1.0.0

Run this workflow

CI-verified, 4/4 fixtures passing.

Build this with your agent

One copy-paste hands Claude Code, Codex, or Cursor the full recipe, steps included, nothing to fetch.

Intended Use

Anyone who runs the same prompt more than twice (commit messages, release notes, PR descriptions) and wants it as a one-time markdown file Pi expands as a slash command or via @-include.

Not for

  • One-off prompts you'll never reuse
  • Anyone unwilling to bring their own model key/subscription

The Stack

Tested Against

pi@0.74node@20.x

Side effects & data flow

Network
your model provider, only in the non-CI run step
Writes
<pi config dir>/prompts/commitmsg.md
Credentials
model API key/subscription, for the run step only

Data privacy

  • your model provider, only in the non-CI run step the staged diff you pipe in (retention: per that provider's API policy)

Prerequisites

  • Pi (MIT): `npm install -g --ignore-scripts @earendil-works/pi-coding-agent`
  • A model key/subscription (only needed to run the template)

Steps

  1. 1

    Scaffold the template at Pi's prompt-discovery path

    CI writes the commit-message template to Pi's documented prompts directory (`<config>/prompts/commitmsg.md`, default `~/.pi/agent/prompts/`) and confirms it lands non-empty and that Pi's print mode flag exists — the deterministic half of 'a file becomes a permanent command.'

    export PI_CODING_AGENT_DIR="$PWD/.pi"
    pi --version >/dev/null || { echo "pi missing"; exit 1; }
    mkdir -p "$PI_CODING_AGENT_DIR/prompts"
    cat > "$PI_CODING_AGENT_DIR/prompts/commitmsg.md" <<'EOF'
    Write a Conventional Commits message for the staged diff below.
    Output only the commit message, nothing else.
    EOF
    test -s "$PI_CODING_AGENT_DIR/prompts/commitmsg.md" && echo "template scaffolded: prompts/commitmsg.md"
    test -r "$PI_CODING_AGENT_DIR/prompts/commitmsg.md" && echo "template path resolves for: git diff --staged | pi -p @prompts/commitmsg.md"
    pi --help 2>&1 | grep -q -- "--print" && echo "pi supports -p print mode"
  2. 2

    Use it (the model step, not checked by CI)

    Interactively type `/commitmsg`, or non-interactively `git diff --staged | pi -p @~/.pi/agent/prompts/commitmsg.md`. Templates also support `{{variables}}`. The text it generates is the model's job, so CI doesn't run it.

Eval, 4 fixtures

Last passed: verified today
  • template-scaffoldedcontainstimeout 60s · max $0

    Expected: template scaffolded: prompts/commitmsg.md

  • path-resolvescontainstimeout 60s · max $0

    Expected: template path resolves for:

  • pi-printcontainstimeout 60s · max $0

    Expected: pi supports -p print mode

  • clean-exitexit_codetimeout 60s · max $0

    Expected: 0

Results

Stop retyping the same instruction, from the WebAfterAI guide.

Did this work for you?

Our CI checks the setup runs. You tell us if the whole thing worked. Tell us straight.

Related workflows

Liked this workflow?

Get new verified workflows in WebAfterAI, three issues a week (Tue, Thu, Sat).