tool-function-schema-designer
Designs robust function/tool calling schemas for LLMs with JSON schemas, validation strategies, typed interfaces, and example calls. Use when implementing "function calling", "tool use", "LLM tools", or "agent actions".
What this skill does
# Tool/Function Schema Designer
Design robust tool schemas that LLMs can reliably invoke.
## Function Schema Format
```typescript
// OpenAI function calling format
const searchDocsTool = {
type: "function",
function: {
name: "search_documentation",
description:
"Search through product documentation using semantic search. Use this when the user asks about features, how-tos, or troubleshooting.",
parameters: {
type: "object",
properties: {
query: {
type: "string",
description: "The search query, phrased as a question or keywords",
},
filters: {
type: "object",
properties: {
category: {
type: "string",
enum: ["api", "guides", "tutorials", "troubleshooting"],
description: "Filter by documentation category",
},
version: {
type: "string",
description: "Filter by product version (e.g., 'v2.0')",
},
},
},
max_results: {
type: "integer",
minimum: 1,
maximum: 10,
default: 5,
description: "Maximum number of results to return",
},
},
required: ["query"],
},
},
};
```
## Typed Interfaces
```typescript
// TypeScript types matching schema
interface SearchDocsParams {
query: string;
filters?: {
category?: "api" | "guides" | "tutorials" | "troubleshooting";
version?: string;
};
max_results?: number;
}
// Implementation
async function search_documentation(
params: SearchDocsParams
): Promise<SearchResult[]> {
const { query, filters = {}, max_results = 5 } = params;
// Implementation
return await vectorStore.search(query, {
filter: filters,
limit: max_results,
});
}
```
## Validation Strategy
```typescript
import { z } from "zod";
// Zod schema for runtime validation
const searchDocsSchema = z.object({
query: z.string().min(1, "Query cannot be empty"),
filters: z
.object({
category: z
.enum(["api", "guides", "tutorials", "troubleshooting"])
.optional(),
version: z.string().optional(),
})
.optional(),
max_results: z.number().int().min(1).max(10).default(5),
});
// Validate before execution
function validateAndExecute(toolName: string, params: unknown) {
const validated = searchDocsSchema.parse(params);
return search_documentation(validated);
}
```
## Tool Registry
```typescript
export const TOOLS = {
search_documentation: {
schema: searchDocsTool,
implementation: search_documentation,
validator: searchDocsSchema,
},
create_ticket: {
schema: createTicketTool,
implementation: create_ticket,
validator: createTicketSchema,
},
// ... more tools
};
// Execute tool safely
async function executeTool(name: string, params: unknown) {
const tool = TOOLS[name];
if (!tool) throw new Error(`Unknown tool: ${name}`);
const validated = tool.validator.parse(params);
return tool.implementation(validated);
}
```
## Example Calls
```typescript
// Example 1: Simple search
{
"name": "search_documentation",
"parameters": {
"query": "How do I authenticate API requests?"
}
}
// Example 2: With filters
{
"name": "search_documentation",
"parameters": {
"query": "rate limiting",
"filters": {
"category": "api",
"version": "v2.0"
},
"max_results": 3
}
}
```
## Error Handling
```typescript
interface ToolResult {
success: boolean;
data?: any;
error?: {
code: string;
message: string;
};
}
async function safeExecuteTool(
name: string,
params: unknown
): Promise<ToolResult> {
try {
const data = await executeTool(name, params);
return { success: true, data };
} catch (error) {
if (error instanceof z.ZodError) {
return {
success: false,
error: {
code: "VALIDATION_ERROR",
message: `Invalid parameters: ${error.message}`,
},
};
}
return {
success: false,
error: {
code: "EXECUTION_ERROR",
message: error.message,
},
};
}
}
```
## Best Practices
1. **Clear descriptions**: Explain when to use the tool
2. **Specific types**: Use enums, ranges, patterns
3. **Sensible defaults**: Reduce required parameters
4. **Validate rigorously**: Don't trust LLM output
5. **Error messages**: Help LLM correct mistakes
6. **Example calls**: Show success cases
7. **Type safety**: TypeScript interfaces
## Output Checklist
- [ ] JSON schema defined
- [ ] TypeScript interface
- [ ] Validation with Zod
- [ ] Implementation function
- [ ] Error handling
- [ ] Example calls (3+)
- [ ] Tool registry entry
- [ ] Documentation
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.