Official agent skill

Migrating Mastra To Pydantic AI

by pydantic in pydantic/pydantic-ai

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

OfficialMITAuto-check passedAgent Workflows

Install Migrating Mastra To Pydantic AI

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

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

GitHub CLI
$ gh skill install pydantic/pydantic-ai migrating-mastra-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-mastra-to-pydantic-ai .claude/skills/migrating-mastra-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-mastra-to-pydantic-ai
GitHub stars
21k
Token cost
~2k tokens
SKILL.md length
1,006 words
Files
4 (incl. references)
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 4 steps: Read repository instructions,… → Trace one real request from its public… → Separate these source contracts when… → …
  • Source code imports @mastra/
  • SKILL.md covers Trace the source before…, Choose the smallest target, Apply high-risk gates and Implement and prove one…, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Migrating Mastra To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports @mastra/ or relies on Mastra agents, tools, workflows, memory, processors, streaming, approvals, skills, or subagents.

Its SKILL.md is about 2k 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 sits in Agent Workflows, covering Subagents. It works with Pydantic AI, Mastra, Python and TypeScript. 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 @mastra/
  • Relies on Mastra agents

Example prompts

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

Requirements

  • Python 3

Workflow steps

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

  1. Read repository instructions, dependencies, tests, and the runtime entrypoint. Record the installed Mastra, Pydantic AI, and Harness…
  2. Trace one real request from its public entrypoint, whether an Agent.generate() / Agent.stream() call or a workflow run, through the tools…
  3. Separate these source contracts when present
  4. Record each observed contract, its owner, semantic difference, and executable proof. An unused Mastra feature is not migration scope.

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 Mastra To Pydantic AI loads about 2k tokens when it runs, and up to ~5.9k if it reads all its reference files. Until then it costs about 73 tokens; SKILL.md has 1,006 words of instructions outside code blocks.

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

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,006 words, ~2,017 tokens.

Download SKILL.mdSave it as .claude/skills/migrating-mastra-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-mastra-to-pydantic-ai
description
Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `@mastra/*` or relies on Mastra agents, tools, workflows, memory, processors, streaming, approvals, skills, or subagents.

Migrate Mastra to Pydantic AI

Preserve observable behavior, not TypeScript or Mastra's object model. Migrate the smallest complete caller path and keep application infrastructure in place.

Trace the source before choosing a target

  1. Read repository instructions, dependencies, tests, and the runtime entrypoint. Record the installed Mastra, Pydantic AI, and Harness versions.
  2. Trace one real request from its public entrypoint, whether an Agent.generate() / Agent.stream() call or a workflow run, through the tools, processors, memory, events, results, state, and side effects that callers use. Establish a focused baseline or characterization test.
  3. Separate these source contracts when present:
    • request context, model-chosen tool input, workflow input/output, and shared workflow state;
    • conversation messages, semantic recall, working or observational memory, workflow snapshots, and model-owned plans;
    • final text or objects, token deltas, lifecycle events, tripwires, and terminal workflow status;
    • tool approval, authenticated authorization, and process or sandbox isolation;
    • deterministic workflows, agent-selected delegation, queues, schedules, and durable execution.
  4. Record each observed contract, its owner, semantic difference, and executable proof. An unused Mastra feature is not migration scope.

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

Choose the smallest target

  • Core: use pydantic_ai.Agent for the agent loop, typed dependencies, tools, outputs, normalized messages, generic hooks, streaming, MCP clients, approvals, usage limits, instrumentation, realtime, and durable-runtime integrations.
  • Graph: use pydantic_graph only when explicit typed nodes, branches, and joins remain useful; use plain async Python for simple fixed control flow.
  • Harness: add pydantic-ai-harness only for observed reusable policy such as memory notebooks, planning, model-directed subagents, Agent Skills, coding tools, guardrails, model-agnostic compaction strategies, or step persistence. Harness capabilities compose through the core agent loop; Harness is not a workflow engine or second runtime.
  • Evals: add the separate pydantic-evals package for observed datasets, cases, and evaluators.
  • Application: retain authentication, databases, vector search, queues, schedulers, deployment, product state, API/UI transports, session lookup, and tenant policy unless the requested slice includes them.
  • Gap: name behavior that no supported public seam preserves, explain its impact, and test a bounded adapter. Do not reproduce the Mastra registry, server, storage schema, or event taxonomy merely to hide a difference.

The normal migration is one reusable Agent, application services supplied through typed dependencies, ordinary Pydantic AI tools, a typed output when callers expect structure, and application-owned storage of result.all_messages() for later turns. Preserve an existing HTTP, job, or UI boundary with a small adapter and its current field names. If the Mastra call is only in-process, migrate its nearest caller in the same slice or explicitly agree on a new application-owned service boundary; do not add a transport by default.

Apply high-risk gates

  • Mastra RequestContext is trusted run context, not model input. Map authenticated identity and services to typed dependencies; expose only model-chosen values as tool parameters.
  • Mastra memory combines distinct behaviors. Map thread messages to serialized Pydantic AI message history, keep semantic retrieval behind an application service or tool, and use Harness Memory only when its model-owned notebook semantics preserve the observed working-memory contract. For existing Mastra records, explicitly choose and test one-time conversion, a read-through adapter, or starting fresh as an accepted change. Do not treat message history, a notebook, or Harness StepPersistence as a workflow snapshot.
  • A Mastra workflow is deterministic application control flow. Use plain Python or pydantic_graph; do not move .branch(), .parallel(), .foreach(), loops, or suspend conditions into an agent prompt. Preserve concurrency, aggregation, failure, and cancellation semantics explicitly.
  • Mastra workflow suspension persists a resumable snapshot. Keep branch and workflow-state persistence in the application or underlying durable engine and prove restart at the promised step. Pydantic AI durable integrations make agent model, tool, and MCP operations durable inside that workflow; they do not own its surrounding control flow. Deferred tools preserve agent tool calls, not arbitrary workflow state.
  • Map processors by firing point, input/output mutation, tripwire behavior, ordering, streaming visibility, and persistence. Use the narrowest of core history processors, output validators, hooks, Harness input/output/tool guardrails, a custom capability, or an application adapter, and golden-test any caller-visible event or error.
  • Approval pauses a validated action; it does not authenticate the approver. Keep identity, authorization, audit, correlation, and idempotency in the application, and prove the effect does not run before approval.
  • Map consumer intent for streaming. Pydantic AI output streaming, run-event streaming, UI adapters, and graph iteration are different surfaces; none promises Mastra's fullStream chunk taxonomy.
  • Use Harness SubAgents only for model-directed delegation. Keep deterministic fan-out, aggregation, retries, and scorer-driven verification loops in application or graph code.
  • Mastra Agent Skills may include references and dynamic resolution. Harness Skills loads on-demand SKILL.md instructions only and does not automatically scan .agents or .claude; use Harness FileSystem or an application tool for required references, and test per-request selection separately.
  • Mastra Studio, server adapters, storage providers, deployment targets, logs, trace storage, and live-eval scheduling are product infrastructure. Retain or replace them deliberately rather than treating the agent port as equivalent.
  • Mastra durable agents, workflow time travel, exact snapshot compatibility, observational-memory compaction, and exact raw event identity are gaps unless a supported target seam is proven for the observed caller.
Show full SKILL.md (164 more words)Show less

Implement and prove one vertical slice

  1. Preserve the supported caller boundary and replace only the agent-owned internals.
  2. Start core-only. Add pydantic_graph, Harness, Pydantic Evals, or a durable runtime only after a source contract requires it.
  3. Test inputs, typed outputs, errors, event order, tool arguments/results, processor decisions, state across turns, and side effects at that boundary. Use deterministic models and fake application services offline; add a focused recorded or live test only when provider behavior is the contract.
  4. For persistence, approvals, concurrent workflows, or external effects, test interruption and restart, lineage, authorization, failure aggregation, and idempotency at the exact boundary promised by Mastra.
  5. Remove @mastra/*, Mastra server setup, and Mastra storage or event adapters only after no retained path needs them.

Explain any consequential semantic change before implementing it: state the source behavior, target behavior, caller impact, recommended choice, and remaining risk.

Completion

Apply the completion criterion in Verification and cutover. Label evidence from fakes, recordings, and live providers 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-mastra-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 Mastra 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 Mastra To Pydantic AI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Migrating Mastra To Pydantic AI this skillpydantic/pydantic-ai21k—~2kAutomated safety check: PassMIT
Pydantic AI Harnesspydantic/skills140—~1.9kAutomated safety check: PassMIT
Logfire Instrumentationpydantic/skills140—~6.1kAutomated safety check: PassMIT
Deep Agents Orchestrationlangchain-ai/langchain-skills1.3k—~3.4kAutomated safety check: PassMIT
MCP DeveloperJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Uipath FunctionsUiPath/skills167—~3.6kAutomated safety check: NotesMIT

Similar skills

  • Pydantic AI Harness

    pydantic/skills

    Official

    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…

    140 GitHub stars~1.9k tokensUpdated 10 days ago
    Agent WorkflowsAuto-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
  • Deep Agents Orchestration

    langchain-ai/langchain-skills

    Official

    INVOKE THIS SKILL when using subagents, task planning, or human approval in Deep Agents.

    1.3k GitHub stars~3.4k tokensUpdated 2 days ago
    Agent WorkflowsAuto-check passed
  • MCP Developer

    Jeffallan/claude-skills

    Builds and debugs MCP servers and clients in TypeScript or Python, from tool and resource definitions to transport setup and inspector-based protocol checks.

    12k GitHub stars~1.5k tokensUpdated 7 days ago
    Agent WorkflowsAuto-check passed
  • Uipath Functions

    UiPath/skills

    UiPath Coded Functions — deterministic Python or TypeScript/JavaScript units built with the uip function CLI (new -l py|ts|js, init, serve, run, pack, publish); the functions map in uipath.json…

    167 GitHub stars~3.6k tokensUpdated today
    AI & LLM EngineeringAuto-check: notes
  • Deep Agents Core

    langchain-ai/langchain-skills

    Official

    Explains how to build agents with the Deep Agents framework: create_deep_agent, the built-in middleware, the harness, SKILL.md format and configuration options.

    1.3k GitHub stars~3.1k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-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

Categories

Questions about Migrating Mastra To Pydantic AI

What does Migrating Mastra To Pydantic AI do?

Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Migrating Mastra To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness.

When should I use Migrating Mastra To Pydantic AI?

Migrating Mastra To Pydantic AI fits situations like: source code imports @mastra/; relies on Mastra agents.

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

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

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

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

Can I use Migrating Mastra 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-mastra-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-mastra-to-pydantic-ai, .gemini/skills/migrating-mastra-to-pydantic-ai, .github/skills/migrating-mastra-to-pydantic-ai and .opencode/skills/migrating-mastra-to-pydantic-ai in your project.

What does Migrating Mastra To Pydantic AI need to run?

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

Does Migrating Mastra 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 Mastra 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 Mastra To Pydantic AI use?

Migrating Mastra 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 Mastra To Pydantic AI use?

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

What are the alternatives to Migrating Mastra To Pydantic AI?

Skills that share tags, products or a category with Migrating Mastra To Pydantic AI: Pydantic AI Harness (pydantic/skills, 140 stars), Logfire Instrumentation (pydantic/skills, 140 stars), Deep Agents Orchestration (langchain-ai/langchain-skills, 1.3k stars) and MCP Developer (Jeffallan/claude-skills, 12k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Migrating Mastra 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.