create-pi-extension

create-pi-extension is a skill for Claude Code, Codex from aretw0/agents-lab. It costs 37 tokens per session (1,110 once invoked), scanned A, original, MIT.

A guide for building TypeScript extensions for Pi, a coding-agent application. Extensions can add custom tools, commands, event handlers, user-interface behavior, and saved state.

In plain words
What is it for?
Use it to create Pi tools, slash commands, lifecycle handlers, terminal UI features, or persistent extension state.
Why use it?
It explains how to add behavior that a skill alone cannot provide and shows the required extension structure and registration patterns.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/aretw0/agents-lab/create-pi-extension
Any agent
npx skills add aretw0/agents-lab --skill create-pi-extension
Clone the repo
git clone --depth 1 https://github.com/aretw0/agents-lab

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for create-pi-extension

README.md
[![agentmods](https://agentmods.dev/badge/skills/aretw0/agents-lab/create-pi-extension.svg)](https://agentmods.dev/skills/aretw0/agents-lab/create-pi-extension)
Your own site
<a href="https://agentmods.dev/skills/aretw0/agents-lab/create-pi-extension"><img src="https://agentmods.dev/badge/skills/aretw0/agents-lab/create-pi-extension.svg" alt="Measured on agentmods" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,110 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.01110
Opus 5 $0.00018 $0.00555
Sonnet 5 $0.00007 $0.00222
Haiku 4.5 $0.00004 $0.00111

Measured 5d ago against content hash 85046fd43d95, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

create-pi-extension scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/pi-skills/skills/create-pi-extension/SKILL.md · 159 lines

How it starts

The opening of the file, as written. The whole thing — 159 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Criando uma Extensão Pi

Extensões são módulos TypeScript que se registram no ciclo de vida do pi. Use quando skills não são suficientes.

Estrutura Mínima

extensions/minha-extension.ts

Ou como pacote:

packages/minha-extension/
├── package.json
├── index.ts
└── README.md

Template Base

import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";

export default function (pi: ExtensionAPI) {
  // Registrar tools, commands, eventos, etc.
}

Registrando uma Tool

import { Type } from "@sinclair/typebox";

pi.registerTool({
  name: "minha_tool",
  label: "Minha Tool",
  description: "O que esta tool faz (visível ao LLM)",
  parameters: Type.Object({
    input: Type.String(),
  }),
  async execute(toolCallId, params, signal, onUpdate, ctx) {
    return {
      content: [{ type: "text", text: `Resultado: ${params.input}` }],
      details: {},
    };
  },
});

Registrando um Comando

pi.registerCommand("meu-comando", {
  description: "O que o /meu-comando faz",
  handler: async (args, ctx) => {
    ctx.ui.notify("Executado!", "info");
  },
});

Eventos Comuns

// Quando a sessão inicia ou recarrega
pi.on("session_start", async (event, ctx) => {
  // Reconstruir estado, configurar UI
});

// Antes de cada chamada ao LLM
pi.on("before_agent_start", async (event, ctx) => {
  // Modificar system prompt, injetar contexto
});

// A cada tool call
pi.on("tool_call", async (event, ctx) => {
  // Gate: retornar { cancelled: true, reason: "..." } para bloquear
});

// Quando a sessão encerra
pi.on("session_shutdown", async (event, ctx) => {
  // Cleanup, salvar estado
});

Empacotando como npm

{
  "name": "@aretw0/minha-extension",
  "keywords": ["pi-package"],
  "type": "module",
  "pi": {
    "extensions": ["./index.ts"]
  },
  "peerDependencies": {
    "@earendil-works/pi-coding-agent": "*",
    "@earendil-works/pi-ai": "*",
    "@earendil-works/pi-tui": "*",
    "@sinclair/typebox": "*"
  }
}

Read the full file on GitHub · 159 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 159 lines · 37 tokens per session scan A 85046fd43d95

Subscribe to this mod's changes

create-pi-extension is a skill published in the GitHub repository aretw0/agents-lab (11 stars, last pushed 2mo ago), licensed MIT. It adds 37 tokens to every session and 1,110 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories