Official agent skill

Pydantic AI Harness

by pydantic in pydantic/skills

Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell…

OfficialMITAuto-check passedAgent Workflows

Install Pydantic AI Harness

skills CLI
$ npx skills add pydantic/skills --skill pydantic-ai-harness -a claude-code

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

GitHub CLI
$ gh skill install pydantic/skills pydantic-ai-harness --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/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/pydantic-ai-harness .claude/skills/pydantic-ai-harness && 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
pydantic-ai-harness
GitHub stars
140
Token cost
~1.9k tokens
SKILL.md length
710 words
Files
2 (incl. references)
Skills in repo
9
Repo updated
First seen
Licence
MIT

At a glance

Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell…

  • The user mentions pydantic-ai-harness
  • SKILL.md covers When to Use This Skill, Supported Capabilities, Install and Quick Start, plus 2 more sections
  • Calls uv
  • Tool sandboxing

What it does

Pydantic AI Harness is an agent skill from pydantic/skills, published by the product's own GitHub organization. Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell, sub-agents, planning, context compaction, and more. Use when the user mentions pydantic-ai-harness, CodeMode, Monty, code mode, or tool sandboxing, when they want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent, when they want an agent to run agent-written Python, or when a…

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/CODE-MODE.md`). Compatibility notes: Requires Python 3.10+ and pydantic-ai-slim=2.18.0

It sits in Agent Workflows, covering Subagents and Context engineering. It works with Pydantic AI, Python and Pydantic. The licence is MIT.

When your agent uses it

  • The user mentions pydantic-ai-harness
  • Tool sandboxing
  • They want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent
  • They want an agent to run agent-written Python

Example prompts

  • “/pydantic-ai-harness”

Requirements

  • Python 3
  • Compatibility (from SKILL.md): Requires Python 3.10+ and pydantic-ai-slim>=2.18.0

What it can do on your machine

Read from SKILL.md and the folder at commit 238d971. 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

    Shell commands in SKILL.md call:

    • uv

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

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com

    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.

  • Compatibility

    Requires Python 3.10+ and pydantic-ai-slim>=2.18.0

    From compatibility in the SKILL.md frontmatter.

Context cost

Pydantic AI Harness loads about 1.9k tokens when it runs, and up to ~3.6k if it reads all its reference files. Until then it costs about 158 tokens; SKILL.md has 710 words of instructions outside code blocks.

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

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/skills at commit 238d971, republished under its MIT licence (© pydantic). 710 words, ~1,899 tokens.

Download SKILL.mdSave it as .claude/skills/pydantic-ai-harness/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
pydantic-ai-harness
description
Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell, sub-agents, planning, context compaction, and more. Use when the user mentions pydantic-ai-harness, CodeMode, Monty, code mode, or tool sandboxing, when they want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent, when they want an agent to run agent-written Python, or when a Pydantic AI agent would benefit from orchestrating multiple tool calls in a single sandboxed script.
compatibility
Requires Python 3.10+ and pydantic-ai-slim>=2.18.0
license
MIT
metadata.version
0.1.0
metadata.author
pydantic

Building with Pydantic AI Harness

Pydantic AI Harness is the official capability library for Pydantic AI. Capabilities that need model or framework support -- and those fundamental to every agent -- live in core pydantic-ai; optional, batteries-included capabilities live here. Both are composed onto an agent through the same capabilities=[...] API.

This skill covers the capabilities shipped by pydantic-ai-harness. For the core framework -- agents, tools, structured output, hooks, and testing -- use the building-pydantic-ai-agents skill instead.

When to Use This Skill

Invoke this skill when:

  • The user mentions pydantic-ai-harness, CodeMode, code mode, or the Monty sandbox
  • An agent makes many sequential tool calls that could collapse into one sandboxed Python execution
  • The user wants the model to write Python that loops, branches, aggregates, or parallelizes tool calls with asyncio.gather
  • The user asks to sandbox or constrain the code an agent runs

Do not use this skill for:

  • Core Pydantic AI usage -- building agents, adding tools, structured output, streaming, or testing (use building-pydantic-ai-agents)
  • Capabilities that ship in core pydantic-ai, such as web search, tool search, and thinking
  • The Pydantic validation library on its own (pydantic/BaseModel without agents)

Supported Capabilities

CodeMode has a full reference below; it is the flagship capability and the one this skill goes deep on. The rest ship today and each has its own README with API and examples.

Each capability lives in its own submodule and is imported from there (from pydantic_ai_harness.<module> import ...). Capabilities are not importable from the top-level pydantic_ai_harness package by design, so each one keeps its own optional dependencies isolated. CodeMode, FileSystem, Shell, and ManagedPrompt also have top-level re-exports (importable directly from pydantic_ai_harness).

APIs are subject to change between releases; breaking changes ship deprecation warnings where practical.

CapabilityModuleDescription
CodeModepydantic_ai_harness.code_mode (also top-level)Wraps eligible tools into a single sandboxed run_code tool so the model orchestrates them in Python -- see Code Mode
FileSystempydantic_ai_harness.filesystem (also top-level)Read, write, edit, and search files under a root directory, with traversal prevention
Shellpydantic_ai_harness.shell (also top-level)Run commands in a subprocess with allowlists, a default denylist, timeouts, and env masking
ManagedPromptpydantic_ai_harness.logfire (also top-level)Back an agent's instructions with a Logfire-managed prompt
SubAgentspydantic_ai_harness.subagentsDelegate subtasks to specialized child agents
DynamicWorkflowpydantic_ai_harness.dynamic_workflowOrchestrate sub-agents from a model-written Python script
Planningpydantic_ai_harness.planningBreak complex tasks into structured plans before execution
compaction family (SlidingWindowCompaction, SummarizingCompaction, ...)pydantic_ai_harness.compactionTrim or summarize conversation history to stay within token limits
ToolOutputLimitspydantic_ai_harness.tool_output_limitsTruncate, summarize, or spill large tool outputs
RepoContextpydantic_ai_harness.repo_contextAuto-load CLAUDE.md/AGENTS.md and repo structure
StepPersistencepydantic_ai_harness.step_persistenceSave, restore, resume, and fork run state
PydanticAIDocspydantic_ai_harness.pydantic_ai_docsOn-demand read_pyai_docs tool for Pydantic AI docs
CapabilityCreationpydantic_ai_harness.capability_creationLet an agent author, validate, and load real capabilities at runtime
media externalizationpydantic_ai_harness.mediaOffload large BinaryContent to content-addressed stores

Still experimental: an ACP server adapter, imported from pydantic_ai_harness.experimental.acp. Importing it emits a HarnessExperimentalWarning.

The full, current list with links and status is in the capability matrix.

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

Install

bash
uv add pydantic-ai-harness

Each capability declares its own extra. Code Mode needs the Monty sandbox:

bash
uv add "pydantic-ai-harness[codemode]"   # `code-mode` is also accepted as an alias

Requires Python 3.10+ and pydantic-ai-slim>=2.18.0.

Quick Start

A harness capability is added to the agent like any other. Here CodeMode wraps locally registered tools into a single run_code tool that the model drives with Python.

python
from pydantic_ai import Agent

from pydantic_ai_harness import CodeMode

agent = Agent('anthropic:claude-sonnet-4-6', capabilities=[CodeMode()])


@agent.tool_plain
def get_temperature_f(city: str) -> float:
    return {'Paris': 68.0, 'Tokyo': 77.0}[city]


@agent.tool_plain
def convert_temp(fahrenheit: float) -> float:
    return round((fahrenheit - 32) * 5 / 9, 1)

result = agent.run_sync(
    'Compare the weather in Paris and Tokyo, and report both temperatures in Celsius.'
)
print(result.output)
#> Paris is 20.0 C and Tokyo is 25.0 C.

The model writes a single Python script that fetches both temperatures with asyncio.gather and then converts them -- performing four tool calls across two dependent stages in one run_code invocation.

Key Practices

  • Confirm a harness capability is actually needed. If core Pydantic AI tools and capabilities are enough, use the building-pydantic-ai-agents skill instead -- don't reach for the harness by default.
  • Read the reference before writing code. Each capability has its own configuration, constraints, and gotchas -- load the linked reference (e.g. Code Mode) first.
  • Install the capability's extra. Importing CodeMode without pydantic-ai-harness[codemode] raises an ImportError; the Monty sandbox is an optional dependency.

Common Gotchas

  • native=True tools bypass CodeMode. Provider-native MCP servers and web search execute server-side, so run_code never sees them. Use native=False for client-side dispatch that CodeMode can wrap, but do not treat a remote server as trusted or sandboxed; see the Code Mode trust boundary.
  • The Monty sandbox is a Python subset. It has no third-party imports and only a small stdlib allowlist -- read Code Mode before debugging generated code that fails to run.
  • CodeMode needs its extra. Install pydantic-ai-harness[codemode], not the bare package.

© 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 1 other file (references) in skills/pydantic-ai-harness of pydantic/skills.

  • SKILL.md
  • references/CODE-MODE.md

Open the folder on GitHubat commit 238d971

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/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Pydantic AI Harness 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.

Pydantic AI Harness compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Pydantic AI Harness this skillpydantic/skills140—~1.9kAutomated safety check: PassMIT
Migrating Mastra To Pydantic AIpydantic/pydantic-ai21k—~2kAutomated safety check: PassMIT
Migrating Vercel AI SDK And Eve To Pydantic AIpydantic/pydantic-ai21k—~2.3kAutomated safety check: PassMIT
Pydantic AI Harnesspydantic/pydantic-ai21k—~4.9kAutomated safety check: PassMIT
Claude Statusbarleeguooooo/claude-code-usage-bar378—~2.6kAutomated safety check: PassMIT
Migrating Claude Agent SDK To Pydantic AIpydantic/pydantic-ai21k—~1.6kAutomated safety check: PassMIT

Similar skills

  • Official

    Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Migrate TypeScript Vercel AI SDK or Eve applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~2.3k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • 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
    AI & LLM EngineeringAuto-check passed
  • Claude Statusbar

    leeguooooo/claude-code-usage-bar

    Manage cs (claude-statusbar) — switch theme/style/density, override severity colors, preview combinations, run doctor, reset config, install, upgrade (cs upgrade — the only supported upgrade path)…

    378 GitHub stars~2.6k tokensUpdated 2 days ago
    Agent WorkflowsAuto-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
    Agent WorkflowsAuto-check passed
  • Official

    Migrate Python Google Agent Development Kit (ADK) applications to Pydantic AI.

    21k GitHub stars~1.6k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from pydantic/skills

All 9 skills in this repo
  • Logfire Infrastructure

    pydantic/skills

    Official

    Monitor hosts, Docker containers, Kubernetes clusters, database/queue/cache servers, and cloud-provider metrics with Pydantic Logfire — no application code required.

    140 GitHub stars~1.8k tokensUpdated 10 days ago
    Auto-check passed
  • Logfire Query

    pydantic/skills

    Official

    Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results.

    140 GitHub stars~2.2k tokensUpdated 10 days ago
    Auto-check passed
  • Official

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

    140 GitHub stars~5.4k tokensUpdated 10 days ago
    Auto-check passed
  • Logfire Evals

    pydantic/skills

    Official

    Run offline Python (pydanticevals) or Node.js (logfire/evals) evaluations and review them in Logfire.

    140 GitHub stars~3.6k tokensUpdated 10 days ago
    Auto-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
    Auto-check passed
  • Logfire UI

    pydantic/skills

    Official

    Open or return Logfire project pages, live views, trace links, and Explore pages in the Codex browser without querying telemetry first.

    140 GitHub stars~2.9k tokensUpdated 10 days ago
    Auto-check passed

Categories

Questions about Pydantic AI Harness

What does Pydantic AI Harness do?

Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell…. Pydantic AI Harness is an agent skill from pydantic/skills, published by the product's own GitHub organization. Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell, sub-agents, planning, context compaction, and more.

When should I use Pydantic AI Harness?

Pydantic AI Harness fits situations like: the user mentions pydantic-ai-harness; tool sandboxing; they want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent; they want an agent to run agent-written Python.

How do I install Pydantic AI Harness in Claude Code?

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

How do I install Pydantic AI Harness in Codex?

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

Can I use Pydantic AI Harness 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/skills --skill pydantic-ai-harness -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/pydantic-ai-harness, .gemini/skills/pydantic-ai-harness, .github/skills/pydantic-ai-harness and .opencode/skills/pydantic-ai-harness in your project.

What does Pydantic AI Harness need to run?

Going by SKILL.md and its folder, Pydantic AI Harness needs the command-line tools its instructions call (uv). Our summary lists: Python 3. Compatibility (from SKILL.md): Requires Python 3.10+ and pydantic-ai-slim>=2.18.0.

Does Pydantic AI Harness access the network?

SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.

Is Pydantic AI Harness 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 Pydantic AI Harness use?

Pydantic AI Harness is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Pydantic AI Harness use?

About 1.9k tokens (SKILL.md is roughly 7.6k 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 1.7k tokens, read only when the agent opens those files.

What are the alternatives to Pydantic AI Harness?

Skills that share tags, products or a category with Pydantic AI Harness: Migrating Mastra To Pydantic AI (pydantic/pydantic-ai, 21k stars), Migrating Vercel AI SDK And Eve To Pydantic AI (pydantic/pydantic-ai, 21k stars), Pydantic AI Harness (pydantic/pydantic-ai, 21k stars) and Claude Statusbar (leeguooooo/claude-code-usage-bar, 378 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Pydantic AI Harness?

pydantic (a GitHub organization, an official publisher) maintains it in pydantic/skills, which has 140 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on October 1, 2026.

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