pydantic-ai-tool-system
Register and implement PydanticAI tools with proper context handling, type annotations, and docstrings. Use when adding tool capabilities to agents, implementing function calling, or creating agent actions.
npx skills add majiayu000/claude-skill-registry --skill pydantic-ai-tool-system --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# PydanticAI Tool System ## Tool Registration Two decorators based on whether you need context: ```python from pydantic_ai import Agent, RunContext agent = Agent('openai:gpt-4o') # @agent.tool - First param MUST be RunContext @agent.tool async def get_user_data(ctx: RunContext[MyDeps], user_id: int) -> str: """Get user data from database. Args: ctx: The run context with dependencies. user_id: The user's ID. """ return await ctx.deps.db.get_user(user_id) # @agent.tool_plain - NO context parameter allowed @agent.tool_plain def calculate_total(prices: list[float]) -> float: """Calculate total price. Args: prices: List of prices to sum. """ return sum(prices) ``` ## Critical Rules 1. **@agent.tool**: First parameter MUST be `RunContext[DepsType]` 2. **@agent.tool_plain**: MUST NOT have `RunContext` parameter 3. **Docstrings**: Required for LLM to understand tool purpose 4. **Google-style docstrings**: Used for parameter descriptions ### Gates (verify in the file, not from memory) 1. **Decorator matches signature** — If the first parameter is `RunContext[...]`, the decorator must be `@agent.tool` (not `@agent.tool_plain`). **Pass:** the same `def` line’s decorator stack includes `@agent
- Tool Registration
- Critical Rules
- Gates (verify in the file, not from memory)
- Docstring Formats
- Tool Return Types
- Accessing Context
- Tool Prepare Functions
- Toolsets
- Common Mistakes
- Wrong: Context in toolplain
- Wrong: Missing context in tool
- Wrong: Context not first parameter
- Async vs Sync
What does the pydantic-ai-tool-system skill do?
Register and implement PydanticAI tools with proper context handling, type annotations, and docstrings. Use when adding tool capabilities to agents, implementing function calling, or creating agent actions.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill pydantic-ai-tool-system --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
