Skip to content

Instantly share code, notes, and snippets.

@mj-meyer
Last active April 8, 2026 21:23
Show Gist options
  • Select an option

  • Save mj-meyer/0b20e3276fd9516bcf366c37e5bdec0a to your computer and use it in GitHub Desktop.

Select an option

Save mj-meyer/0b20e3276fd9516bcf366c37e5bdec0a to your computer and use it in GitHub Desktop.
PI extension: capitalizes 'pi' → 'PI' in system prompts (Anthropic)
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
// Replaces standalone lowercase "pi" with "PI" in the system prompt.
// Uses lookbehind/lookahead so paths like ~/.pi/ and pi-coding-agent are untouched.
export default function (pi: ExtensionAPI) {
pi.on("before_agent_start", (event, ctx) => {
if (ctx.model?.provider !== "anthropic") return;
const replaced = event.systemPrompt.replace(/(?<=^|\s)pi(?=\s|[,.]|$)/gm, "PI");
if (replaced === event.systemPrompt) return;
return { systemPrompt: replaced };
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment