migrating-mastra-to-pydantic-ai
Skill by pydantic
Guides migration of TypeScript Mastra applications to Python with Pydantic AI, and Pydantic AI Harness when needed. It is for developers whose source code imports @mastra packages or relies on Mastra agents, tools, workflows, memory, or streaming.
Install migrating-mastra-to-pydantic-ai
Built from the published package, never by AI.
git clone --depth 1 https://github.com/pydantic/pydantic-ai /tmp/pydantic-ai && mkdir -p ~/.claude/skills && cp -r /tmp/pydantic-ai/pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-mastra-to-pydantic-ai ~/.claude/skills/migrating-mastra-to-pydantic-aiRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install migrating-mastra-to-pydantic-ai in Claude Code
git clone --depth 1 https://github.com/pydantic/pydantic-ai /tmp/pydantic-ai && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/pydantic-ai/pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-mastra-to-pydantic-ai ~/.gemini/antigravity-cli/skills/migrating-mastra-to-pydantic-aiAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install migrating-mastra-to-pydantic-ai in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This agent skill gives step-by-step migration guidance for moving a TypeScript Mastra application to Python. It tells the assistant to trace one real request from its public entrypoint, record the observed contracts, and write a baseline or characterization test before changing code. It then maps each contract to a target: a core Pydantic AI Agent by default, pydantic_graph only for explicit typed control flow, Pydantic AI Harness only for observed reusable policy, and pydantic-evals for datasets and evaluators.
The skill sets gates for high-risk areas such as request context, memory, workflow suspension, processors, approvals, streaming, subagents, and skills. It asks that each consequential semantic change be explained before implementation. It is aimed at developers who need to port a Mastra codebase while keeping its observable behavior and application infrastructure in place.
Written from the project's SKILL.md and checked against it.
What it can do
- Trace the source before choosing a targetReads repository instructions, dependencies, tests and the entrypoint, then traces one real request to set a baseline.
- Choose the smallest targetSelects core Pydantic AI, pydantic_graph, Harness, Evals or application code based on observed source contracts.
- Map Mastra memorySeparates thread messages, semantic recall, working memory and workflow snapshots, and maps each to a suitable target.
- Map Mastra workflowsKeeps deterministic workflow control flow in plain Python or pydantic_graph instead of agent prompts.
- Map processors and streamingMaps processors by firing point, mutation, tripwire behavior and streaming visibility, with golden tests for events.
- Gate tool approvalsKeeps identity, authorization, audit and idempotency in the application and checks that effects wait for approval.
- Implement one vertical sliceReplaces only the agent-owned internals of one caller path while keeping the supported boundary unchanged.
- Verify and cut overLists tests for inputs, outputs, errors, tool calls and restarts, and removes Mastra code only after no path needs it.
What you need
- An existing TypeScript Mastra application
- Python with Pydantic AI for the migrated code
Try asking
- Migrate this Mastra agent and its tools to a Pydantic AI Agent in Python
- Trace one request through my Mastra workflow and write a baseline test first
- Map my Mastra memory and processors to Pydantic AI targets and list the risks
Good to know
- Mastra durable agents, workflow time travel and exact snapshot compatibility are listed as gaps unless a supported seam is proven.
- Harness Skills does not automatically scan .agents or .claude directories.
- Mastra Studio, server adapters, storage and deployment are product infrastructure that must be retained or replaced deliberately.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-mastra-to-pydantic-ai/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md8 KB -
agents/openai.yaml301 B -
references/RESEARCH-AND-MAPPING.md9 KB -
references/VERIFICATION-AND-CUTOVER.md6 KB
Alternatives to migrating-mastra-to-pydantic-ai
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
migrating-mastra-to-pydantic-ai: common questions
Does this skill migrate the whole Mastra app at once?
No. The source says to migrate the smallest complete caller path and to prove it with one vertical slice before expanding.
Does the skill replace Mastra workflows with agent prompts?
No. The source says deterministic workflow control flow should stay in plain Python or pydantic_graph, not in an agent prompt.
When should Pydantic AI Harness be added?
The source says to add Harness only for observed reusable policy, such as memory notebooks, planning, subagents, or Agent Skills.
How do I install migrating-mastra-to-pydantic-ai?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is migrating-mastra-to-pydantic-ai free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is migrating-mastra-to-pydantic-ai safe to use?
It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to migrating-mastra-to-pydantic-ai?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
