/vibe:skill-function-calling-patternsfrom vibe
Decision framework for implementing function calling in production: tool design, error handling, security, and provider patterns for OpenAI and Anthropic.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When building an LLM application that uses tools, apply this decision framework.
Use function calling when:
Use structured outputs instead when:
Use both when:
One tool, one action. A tool named manage_database that handles queries, inserts, updates, and deletes is too broad. Split into query_records, insert_record, update_record. The model selects better with specific tools.
Descriptions are prompts. The model reads tool descriptions to decide selection. Write them like you would write instructions for a junior developer. Include what the tool returns, not just what it does.
Constrain with enums. If a parameter has 3-10 valid values, use an enum. The model will invent strings -- "celsius", "Celsius", "C", "metric" -- unless you constrain it.
Fewer tools is better. GPT-4o handles 5-10 tools well. At 20+ tools, selection accuracy drops. At 50+ tools, expect 10-15% wrong tool selection. Group related functionality or use a routing layer.
Required means required. Only mark a parameter as required if the tool literally cannot function without it. Optional parameters with good defaults reduce tool call failures.
tools=[{"type": "function", "function": {"name": ..., "parameters": ...}}]
tool_choice="auto" # model decides
tool_choice="required" # must call at least one tool
tool_choice={"type": "function", "function": {"name": "specific_tool"}}
tool_calls in one response)gpt-4o-mini is 10x cheaper and handles simple tool routing welltools=[{"name": ..., "description": ..., "input_schema": ...}]
tool_choice={"type": "auto"} # model decides
tool_choice={"type": "any"} # must call at least one tool
tool_choice={"type": "tool", "name": "specific_tool"}
type: "tool_use"type: "tool_result"input_schema, not parameters (common migration bug)function_declarations=[{"name": ..., "description": ..., "parameters": ...}]
function_calling_config={"mode": "AUTO"} # or "ANY" or "NONE"
function_declarations at the top levelfunction_response parts{"error": true, "message": "City 'Toky' not found. Did you mean 'Tokyo'?", "code": "NOT_FOUND", "suggestions": ["Tokyo"]}
Include actionable information. "Not found" is bad. "Not found, did you mean X?" is good. The model uses error messages to self-correct.
Set timeouts on all tool executions. 30 seconds is a reasonable default. If a tool times out, return a structured timeout error so the model can inform the user rather than hanging.
| Check | Why | How |
|---|---|---|
| Allowlist functions | Prevent arbitrary code execution | Only register tools the user needs |
| Validate argument types | Prevent type confusion attacks | Check types before execution |
| Sanitize string arguments | Prevent injection | Reject or escape special characters |
| Parameterize database queries | Prevent SQL injection | Never pass model-generated SQL directly |
| Filter tool results | Prevent data leakage | Remove API keys, PII, internal errors |
| Rate limit tool calls | Prevent runaway loops | Max 10-20 calls per conversation |
| Log all tool calls | Audit trail | Store tool name, arguments, result, timestamp |
| Block path traversal | Prevent file system access | Reject .. and absolute paths in file tools |
| Sandbox code execution | Prevent system access | Use containers or restricted builtins |
| Validate return size | Prevent context stuffing | Truncate results over 10KB |
asyncio.gather() or concurrent.futuresgpt-4o-mini or claude-3-5-haiku for tool selection, then pass results to a stronger model for synthesis| Failure | Cause | Fix |
|---|---|---|
| Wrong tool selected | Ambiguous descriptions | Rewrite descriptions with specific trigger words |
| Missing required args | Model forgot a parameter | Add clear examples in parameter descriptions |
| Infinite tool loop | Model keeps calling same tool | Set max iterations (5-10) and detect repeated calls |
| Hallucinated arguments | Model invents plausible but wrong values | Use enums, validate against known values |
| Tool result too large | API returned 100KB of data | Truncate or summarize before feeding back |
| Model ignores tool result | Result format confusing | Return clean JSON with clear field names |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.npx claudepluginhub anubhavg-icpl/vibe --plugin vibeOther plugins' skills for the same job