# Tool Use Patterns

> Patterns for Claude tool use including sequential tools, parallel execution, error handling, and agentic loops.

- Skill: `grandamenium/tool-use-patterns` (Agent Skill)
- Install (CLI): `npx skillmds@latest add grandamenium/tool-use-patterns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/grandamenium/tool-use-patterns/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: grandamenium (https://skillmd.com/u/grandamenium)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/grandamenium/tool-use-patterns

---


# Tool Use Patterns

Advanced patterns for Claude's tool use capability.

## Agentic Loop
```python
while True:
    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        tools=tools,
        messages=messages
    )

    if response.stop_reason == "end_turn":
        break

    for block in response.content:
        if block.type == "tool_use":
            result = execute_tool(block.name, block.input)
            messages.append({"role": "assistant", "content": response.content})
            messages.append({"role": "user", "content": [
                {"type": "tool_result", "tool_use_id": block.id, "content": str(result)}
            ]})
```

## Error Handling
```python
{"type": "tool_result", "tool_use_id": id, "is_error": true, "content": "File not found"}
```

## Parallel Tool Calls
Claude can request multiple tools in one response. Execute them concurrently and return all results.

## Best Practices
- Keep tool descriptions concise but complete
- Include parameter constraints in the schema
- Return structured data from tools when possible
- Use is_error for graceful failure handling

