test-pi-extension

test-pi-extension is a skill for Claude Code, Codex from aretw0/agents-lab. It costs 44 tokens per session (2,104 once invoked), scanned C, original, MIT.

A testing guide for pi extensions using a test harness and Vitest. The harness runs the extension itself while scripted responses stand in for the language model.

In plain words
What is it for?
Use it to create automated tests for pi extensions and verify that a package still works after publishing.
Why use it?
It lets developers check loading, tools, hooks, events, and outputs without relying on unpredictable model responses.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is const EXT = path.resolve(__dirname, "../../extensions/safe-guard.ts");.

Good fit Use it to create automated tests for pi extensions and verify that…

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

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

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 test-pi-extension

README.md
[![agentmods](https://agentmods.dev/badge/skills/aretw0/agents-lab/test-pi-extension.svg)](https://agentmods.dev/skills/aretw0/agents-lab/test-pi-extension)
Your own site
<a href="https://agentmods.dev/skills/aretw0/agents-lab/test-pi-extension"><img src="https://agentmods.dev/badge/skills/aretw0/agents-lab/test-pi-extension.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,104 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00044 $0.02104
Opus 5 $0.00022 $0.01052
Sonnet 5 $0.00009 $0.00421
Haiku 4.5 $0.00004 $0.00210

Measured 6d ago against content hash eb78b9373550, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade C, and why

test-pi-extension scanned grade C with 1 finding 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 6d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

it("bloqueia rm -rf /", async () => {
packages/pi-skills/skills/test-pi-extension/SKILL.md · 321 lines

How it starts

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

Testando Extensões Pi

O @marcfargas/pi-test-harness permite testar extensões pi com o runtime real — sem LLM. Tudo roda de verdade (loading, hooks, tools, eventos), exceto o modelo que é substituído por um playbook scriptado.

Instalação

npm install --save-dev @marcfargas/pi-test-harness vitest

Peer dependencies: @earendil-works/pi-coding-agent, @earendil-works/pi-ai, @earendil-works/pi-agent-core.

Teste Básico

import { describe, it, expect, afterEach } from "vitest";
import { createTestSession, when, calls, says, type TestSession } from "@marcfargas/pi-test-harness";

describe("minha extensão", () => {
  let t: TestSession;
  afterEach(() => t?.dispose());

  it("registra e executa uma tool", async () => {
    t = await createTestSession({
      extensions: ["./src/index.ts"],
      mockTools: {
        bash: (params) => `$ ${params.command}\noutput`,
        read: "conteúdo do arquivo",
        write: "ok",
        edit: "ok",
      },
    });

    await t.run(
      when("Liste os arquivos", [
        calls("bash", { command: "ls" }),
        says("Encontrei os arquivos."),
      ]),
    );

    expect(t.events.toolResultsFor("bash")).toHaveLength(1);
    expect(t.events.toolResultsFor("bash")[0].text).toContain("output");
  });
});

Arquitetura

┌───────────────────────────────────────┐
│  Ambiente pi REAL                     │
│                                       │
│  Extensions ─── carregadas de verdade │
│  Tool registry ─ hooks reais          │
│  Session state ─ persistência real    │
│                                       │
│  ┌─────────────────────────────────┐  │
│  │  streamFn ── SUBSTITUÍDO       │  │ ← playbook (when/calls/says)
│  │  tool.execute ── INTERCEPTADO  │  │ ← mockTools
│  │  ctx.ui.* ── INTERCEPTADO      │  │ ← mockUI
│  └─────────────────────────────────┘  │
└───────────────────────────────────────┘

Só 3 pontos são substituídos — todo o resto é pi real.

Playbook DSL

Read the full file on GitHub · 321 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. 6d ago First seen · 321 lines · 44 tokens per session scan C eb78b9373550

Subscribe to this mod's changes

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