Official agent skill

Migrating Pi To Pydantic AI

by pydantic in pydantic/pydantic-ai

Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness.

OfficialMITAuto-check passed

Install Migrating Pi To Pydantic AI

skills CLI
$ npx skills add pydantic/pydantic-ai --skill migrating-pi-to-pydantic-ai -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pydantic/pydantic-ai migrating-pi-to-pydantic-ai --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pydantic/pydantic-ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-pi-to-pydantic-ai .claude/skills/migrating-pi-to-pydantic-ai && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
migrating-pi-to-pydantic-ai
GitHub stars
21k
Token cost
~2.1k tokens
SKILL.md length
1,031 words
Files
4 (incl. references)
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness.

  • Works in 5 steps: Read repository instructions,… → Trace one real request from the Pi CLI,… → Inventory every active extension factory… → …
  • Source code imports @earendil-works/pi-
  • SKILL.md covers Trace the source before…, Treat extensions as capability…, Choose the smallest target and Apply high-risk gates, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Migrating Pi To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness. Use when source code imports @earendil-works/pi-, calls createAgentSession, registers Pi extensions, or relies on Pi tools, hooks, skills, sessions, compaction, providers, TUI, RPC, or packages.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `agents/openai.yaml`, `references/RESEARCH-AND-MAPPING.md` and `references/VERIFICATION-AND-CUTOVER.md`).

It works with Pydantic AI, TypeScript and Python. The repository describes itself as: How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end. The licence is MIT.

When your agent uses it

  • Source code imports @earendil-works/pi-
  • Calls createAgentSession
  • Registers Pi extensions
  • Relies on Pi tools

Example prompts

  • “/migrating-pi-to-pydantic-ai”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Read repository instructions, package.json, Pi settings, tests, extension/package manifests, and runtime entrypoints. Record the installed…
  2. Trace one real request from the Pi CLI, RPC boundary, or createAgentSession().prompt() through resource discovery, system instructions…
  3. Inventory every active extension factory and package resource. For each pi.on(...), registerTool, registerCommand, provider registration…
  4. Separate these contracts when present
  5. Record each observed contract, its owner, semantic difference, and executable proof. An installed but inactive Pi package feature is not…

What it can do on your machine

Read from SKILL.md and the folder at commit 69ea1e5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Migrating Pi To Pydantic AI loads about 2.1k tokens when it runs, and up to ~7k if it reads all its reference files. Until then it costs about 88 tokens; SKILL.md has 1,031 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~88
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pydantic/pydantic-ai at commit 69ea1e5, republished under its MIT licence (© pydantic). 1,031 words, ~2,119 tokens.

Download SKILL.mdSave it as .claude/skills/migrating-pi-to-pydantic-ai/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
migrating-pi-to-pydantic-ai
description
Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness. Use when source code imports `@earendil-works/pi-*`, calls `createAgentSession`, registers Pi extensions, or relies on Pi tools, hooks, skills, sessions, compaction, providers, TUI, RPC, or packages.

Migrate Pi to Pydantic AI

Preserve observable behavior, not Pi's TypeScript API. Migrate the smallest complete caller path and keep product/host infrastructure in the application.

Trace the source before choosing a target

  1. Read repository instructions, package.json, Pi settings, tests, extension/package manifests, and runtime entrypoints. Record the installed Pi, Pydantic AI, and Harness versions.
  2. Trace one real request from the Pi CLI, RPC boundary, or createAgentSession().prompt() through resource discovery, system instructions, tools, extensions, model requests, messages, compaction/retry, events, session entries, UI/RPC output, and side effects. Establish a focused baseline or characterization test.
  3. Inventory every active extension factory and package resource. For each pi.on(...), registerTool, registerCommand, provider registration, renderer/UI contribution, skill, prompt, and persisted entry, record its firing point, trusted inputs, mutations, output, state owner, and caller-visible effect.
  4. Separate these contracts when present:
    • model messages, append-only session entries/tree branches, compaction summaries, and extension state;
    • model-chosen tool input, trusted host context, project trust, approval, authorization, and OS isolation;
    • token deltas, tool lifecycle, Pi extension events, capability events, RPC events, and terminal rendering;
    • agent-loop behavior, CLI/TUI host behavior, provider transport, package distribution, and external side effects.
  5. Record each observed contract, its owner, semantic difference, and executable proof. An installed but inactive Pi package feature is not migration scope.

Read Research and concept mapping for the detected features. Read Verification and cutover before implementation.

Treat extensions as capability candidates

A Pi extension is the closest source concept to a Pydantic AI capability, but it is broader. An extension can combine agent behavior with terminal UI, commands, provider registration, resource discovery, and host lifecycle. Port responsibilities, not the extension file:

  1. Map reusable model-facing behavior—tools, instructions, model settings, history/event processing, guardrails, and agent-loop hooks—to an existing Core or Harness capability when its lifecycle matches.
  2. Bundle related instructions and tools in core Capability; subclass AbstractCapability only for reusable behavior that needs lifecycle hooks, adaptive models/settings, native tools, or typed capability events.
  3. Keep CLI commands, flags, keyboard shortcuts, TUI renderers/dialogs, session selection, project trust, package installation, and provider credential setup in the Python application or interface adapter. They are not agent capabilities merely because a Pi extension owns them.
  4. Split mixed extensions at that seam. A permission extension may become a ToolGuardrail or approval capability plus an application-owned approver UI; a coding package may become Coder plus host configuration; a provider extension remains a model/provider integration.
  5. Preserve order only where evidence shows it matters. Pi handler load order and Pydantic AI capability/hook ordering are different contracts.

Choose the smallest target

  • Core: use pydantic_ai.Agent for the agent loop, typed dependencies, tools/toolsets, outputs, normalized messages, capabilities/hooks, streaming, approvals, usage limits, instrumentation, MCP, and provider/model integration.
  • Harness: use Coder for Pi's ordinary coding tools only when its exact composition fits. Add focused capabilities such as FileSystem, Shell, Skills, Planning, SubAgents, guardrails, compaction, tool-output limits, or step persistence only for observed behavior.
  • Application/interface: retain or replace CLI/TUI/RPC, auth, project trust, settings, provider login/catalogs, session browsing, package management, deployment, and transport deliberately.
  • Graph: use plain async Python or pydantic_graph for deterministic workflows; do not encode them in prompts or subagents.
  • Gap: name behavior with no supported public seam, explain its impact, and test a bounded adapter. Do not clone Pi's extension bus or JSONL format just to claim parity.

The normal embedded migration is one reusable Agent, Coder or a smaller capability composition, application services in typed dependencies, an application-owned message/session store, and a thin adapter at the existing RPC or UI boundary.

Show full SKILL.md (452 more words)Show less

Apply high-risk gates

  • ctx, project trust, credentials, session managers, and service handles are trusted host context. Put equivalents in typed dependencies or application services, never model-chosen tool arguments.
  • Pi session JSONL is an append-only branching host log containing more than model context. result.all_messages() preserves model history, not tree navigation, labels, extension entries, compaction records, model changes, queues, or abandoned branches. Choose and test conversion, a compatibility store, or an accepted fresh start.
  • Pi compaction, context interception, steering/follow-up queues, retries, and branch summaries have specific timing. Select matching core/Harness seams independently and test ordering; generic message history or summarization is not automatic parity.
  • Map tool_call permission gates by effect. Use guardrails for validation/block/redaction and deferred tools for an action that must await approval. Keep identity, authorization, UI, audit, persistence, and idempotency in the application.
  • Pi extensions run arbitrary TypeScript with host permissions. A Pydantic AI capability also runs application code; neither is a sandbox. Use an OS/container/cloud isolation boundary for untrusted commands or code.
  • Harness Skills loads configured SKILL.md instructions on demand but does not reproduce Pi's discovery roots, resource files, scripts, reload, package installation, or behavioral frontmatter. Preserve those separately when observed.
  • Use SubAgents only for model-directed isolated tasks. Keep deterministic orchestration and Pi subprocess/tmux/package-specific semantics in application code.
  • Map dynamic tool activation to core ToolSearch or on-demand capabilities only after testing load timing, schemas, prompt/cache changes, and provider fallback behavior.
  • Pydantic AI run events and capability events do not reproduce Pi's extension event bus, RPC protocol, or TUI render lifecycle. Adapt only stable fields consumers use.
  • Pi provider extensions and payload hooks may alter authentication, catalogs, wire payloads, headers, and streaming. Implement them at the Pydantic AI model/provider or application transport layer and run provider contract tests; do not hide them in a generic capability.

Implement and prove one vertical slice

  1. Preserve the supported CLI, RPC, SDK, job, or UI boundary and replace only agent-owned internals.
  2. Start with core plus the smallest coding capabilities. Add broader Harness behavior only after a traced contract requires it.
  3. For each source extension, document the split: capability behavior, application/interface behavior, retained integration, and gap. Test each side through its real boundary.
  4. Use language-neutral fixtures for RPC/events and persisted records. Test tool arguments/results, errors, event order, session continuation, UI decisions, and side effects. Use deterministic models offline; add focused recorded/live provider tests only for provider behavior.
  5. Remove Pi packages, settings, Node runtime, or extension adapters only after no retained path needs them.

Explain consequential semantic changes before implementing them: state the Pi behavior, target behavior, caller impact, recommended choice, and remaining risk.

Completion

Apply the completion criterion in Verification and cutover. Label fake, recording, live-provider, terminal, restart, and sandbox evidence accurately.

© pydantic, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-pi-to-pydantic-ai of pydantic/pydantic-ai.

  • SKILL.md
  • agents/openai.yaml
  • references/RESEARCH-AND-MAPPING.md
  • references/VERIFICATION-AND-CUTOVER.md

Open the folder on GitHubat commit 69ea1e5

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in pydantic/pydantic-ai, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Migrating Pi To Pydantic AI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Migrating Pi To Pydantic AI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Migrating Pi To Pydantic AI this skillpydantic/pydantic-ai21k—~2.1kAutomated safety check: PassMIT
Failproof AI SDK IntegrationFailproofAI/failproofai5.3k—~6kAutomated safety check: PassCustom licence
Logfire Instrumentationpydantic/skills140—~6.1kAutomated safety check: PassMIT
MCP Server Builderanthropics/skills180k63 repos~2.3kAutomated safety check: PassApache-2.0
Code Review ChecklistshareAI-lab/learn-claude-code78k4 repos~1.1kAutomated safety check: PassMIT
MCP Server BuildershareAI-lab/learn-claude-code78k4 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Failproof AI SDK Integration

    FailproofAI/failproofai

    Helps instrument a custom Python or TypeScript agent to record events for Failproof AI, verify what gets written, and run an evaluator worker that scores the runs.

    5.3k GitHub stars~6k tokensUpdated 4 days ago
    AI & LLM EngineeringAuto-check passed
  • Official

    Add Pydantic Logfire observability to application code — traces, logs, metrics, and AI/agent spans.

    140 GitHub stars~6.1k tokensUpdated 10 days ago
    AI & LLM EngineeringAuto-check passed
  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 63 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 4 repos~1.1k tokens
    DevelopmentAuto-check passed
  • MCP Server Builder

    shareAI-lab/learn-claude-code

    Walks through building MCP servers in Python or TypeScript that expose tools, resources and prompts to Claude, with templates, registration and testing.

    78k GitHub starsUsed in 4 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • Image to Three.js Model

    img2threejs/img2threejs

    Rebuilds the object in a reference image as a procedural, animation-ready Three.js model written entirely in code, using staged sculpting with quality checks.

    18k GitHub starsUsed in 1 repo~8.2k tokens
    Game DevelopmentAuto-check passed

More from pydantic/pydantic-ai

All 20 skills in this repo
  • Pydantic AI Harness

    pydantic/pydantic-ai

    Official

    Adds optional capabilities to Pydantic AI agents from pydantic-ai-harness, led by Code Mode, which runs many tool calls as one sandboxed Python script.

    21k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Building Pydantic AI Agents

    pydantic/pydantic-ai

    Official

    Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), workspaces, structured output, streaming, testing, and multi-agent patterns.

    21k GitHub stars~8.2k tokensUpdated today
    Auto-check passed
  • Complete Partial PR

    pydantic/pydantic-ai

    Official

    Evaluate and complete an issue or PR where the submitted patch fixes only a narrow symptom of the reported pain point.

    21k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Testing Skill

    pydantic/pydantic-ai

    Official

    Record, rewrite, and debug VCR cassettes for HTTP recordings.

    21k GitHub stars~839 tokensUpdated today
    Auto-check: notes
  • Migrating Agno To Pydantic AI

    pydantic/pydantic-ai

    Official

    Migrate Python Agno applications to Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Official

    Migrate Python applications from the Claude Agent SDK to Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~1.6k tokensUpdated today
    Auto-check passed

Questions about Migrating Pi To Pydantic AI

What does Migrating Pi To Pydantic AI do?

Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness. Migrating Pi To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness.

When should I use Migrating Pi To Pydantic AI?

Migrating Pi To Pydantic AI fits situations like: source code imports @earendil-works/pi-; calls createAgentSession; registers Pi extensions; relies on Pi tools.

How do I install Migrating Pi To Pydantic AI in Claude Code?

Run `npx skills add pydantic/pydantic-ai --skill migrating-pi-to-pydantic-ai -a claude-code`. Or copy the skill folder (pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-pi-to-pydantic-ai in pydantic/pydantic-ai) into .claude/skills/migrating-pi-to-pydantic-ai in your project. Claude Code loads it when a task matches its description.

How do I install Migrating Pi To Pydantic AI in Codex?

Run `npx skills add pydantic/pydantic-ai --skill migrating-pi-to-pydantic-ai -a codex`. Or copy the skill folder (pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-pi-to-pydantic-ai in pydantic/pydantic-ai) into .agents/skills/migrating-pi-to-pydantic-ai in your project. Codex loads it when a task matches its description.

Can I use Migrating Pi To Pydantic AI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pydantic/pydantic-ai --skill migrating-pi-to-pydantic-ai -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/migrating-pi-to-pydantic-ai, .gemini/skills/migrating-pi-to-pydantic-ai, .github/skills/migrating-pi-to-pydantic-ai and .opencode/skills/migrating-pi-to-pydantic-ai in your project.

What does Migrating Pi To Pydantic AI need to run?

SKILL.md names no scripts, command-line tools or credentials: Migrating Pi To Pydantic AI is instructions for the agent only. Our summary lists: Python 3.

Does Migrating Pi To Pydantic AI access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Migrating Pi To Pydantic AI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Migrating Pi To Pydantic AI use?

Migrating Pi To Pydantic AI is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Migrating Pi To Pydantic AI use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.9k tokens, read only when the agent opens those files.

What are the alternatives to Migrating Pi To Pydantic AI?

Skills that share tags, products or a category with Migrating Pi To Pydantic AI: Failproof AI SDK Integration (FailproofAI/failproofai, 5.3k stars), Logfire Instrumentation (pydantic/skills, 140 stars), MCP Server Builder (anthropics/skills, 180k stars) and Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Migrating Pi To Pydantic AI?

pydantic (a GitHub organization, an official publisher) maintains it in pydantic/pydantic-ai, which has 20,537 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 11, 2026.

Source: pydantic/pydantic-ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.