tool-design-pattern

Enforce standardized AI tool design patterns with Pydantic schemas and error handling.

2|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill tool-design-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tool-design-pattern
Source: https://github.com/ricardoroche/ricardos-claude-code/tree/main/.claude/skills/tool-design-pattern
Command: npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill tool-design-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires langchain, pydantic, httpx, pytest.

What problem does it solve?

This Skill provides a structured framework for designing and implementing AI tools (e.g., for LangChain, function calling). It addresses common challenges like inconsistent input schemas, poor error handling, and lack of testability, ensuring your tools are robust, predictable, and easy to integrate.

Core Features & Use Cases

  • Pydantic Schema Design: Enforces clear, validated input schemas for tools using Pydantic, improving reliability and reducing runtime errors.
  • Comprehensive Error Handling: Guides on implementing robust try/except blocks and structured JSON error responses for predictable tool behavior.
  • Context-Aware Tools: Patterns for safely accessing and utilizing conversation context (like user_id, session_id) within tool logic.
  • Async & Testing: Provides examples for building asynchronous tools and writing thorough unit tests for tool functions.
  • Use Case: An LLM agent needs to interact with an external API to fetch user data. This skill helps an engineer design a fetch_user_data tool with a Pydantic input schema, proper error handling for API failures, and comprehensive tests, making the agent's interactions reliable.

Quick Start

Design a new AI tool for searching a database, ensuring it has a Pydantic input schema and robust error handling.

Frequently Asked Questions about tool-design-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design AI tools with Pydantic schemas for LangChain?

Design AI tools by defining Pydantic input schemas that validate tool parameters, then implement robust error handling and logging. This enforces type safety, reduces runtime errors, and makes tools predictable for LangChain agents and function-calling workflows.

What's the best way to handle errors in AI tool implementations?

Implement structured error handling with try/except blocks that return JSON error responses, ensuring tools fail gracefully and predictably. This prevents agent crashes and provides clear feedback when external APIs or operations fail.

Can I access conversation context like user_id in my AI tools?

Yes, tools can safely access and utilize conversation context such as user_id and session_id through context-aware design patterns. This enables personalized tool behavior while maintaining security and isolation.

How do I write tests for LangChain and function-calling tools?

Write comprehensive unit tests using pytest to validate tool inputs, outputs, error cases, and async behavior. Testing ensures tools behave reliably before integration with agents and reduces debugging friction.

Do I need to use async when building AI tools?

Async is optional but recommended for tools that call external APIs or perform I/O, improving performance in agent workflows. The skill provides patterns for both synchronous and asynchronous tool implementations.

Why is input validation important for AI tool design?

Input validation using Pydantic prevents malformed data from reaching tool logic, reducing bugs and security risks. Clear schemas also make tools self-documenting and easier for LLMs to understand and invoke correctly.