aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock/tool-use-structured-output
Claude Code and agent skill by aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock
- community
Checking that the SKILL.md file is still in the repository.
Use Bedrock tool_use to guarantee structured JSON outputs from Claude models. Eliminates JSON parsing failures by forcing responses through typed tool schemas.
Install
npx vskill@latest install aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock/tool-use-structured-outputSKILL.md
This skill demonstrates using Amazon Bedrock's tool_use feature to get highly reliable structured JSON outputs from Claude models. Instead of hoping the model returns valid JSON, define a tool schema that forces the exact structure you need.
The Problem
Asking Claude to "return JSON" fails 10-30% of the time:
- Markdown code fences around JSON
- Truncated responses mid-object
- Extra text before/after JSON
- Invalid escaping in strings
The Solution
Define a tool with your exact output schema. Claude will call the tool with arguments that should match the schema structure. While tool use strongly steers the model toward valid structured output, you should still validate the response and have fallback handling for edge cases.
Implementation Pattern
1. Define Tool Schema
2. Invoke Bedrock with Tool
3. Parse Response
Advanced Patterns
Enum Constraints
Force specific values:
Numeric Ranges
Constrain numbers:
Nested Objects
Complex structures:
Lambda Integration
Error Handling
Tool use can still fail in edge cases. Always validate and handle errors:
Cost Considerations
Tool definitions count toward input tokens:
- Simple schema: ~200-500 tokens
- Complex schema: ~1000-2000 tokens
For high-volume workloads, keep schemas minimal.
Success Rate Comparison
| Method | JSON Parse Success Rate | |
|---|---|---|
| "Return JSON" prompt | 70-80% | |
| JSON mode (if available) | 90-95% | |
| Tool use (forced) | 99%+ |
Tool use is the most reliable method for structured outputs from Claude on Bedrock. However, always validate the response matches your expected schema before using it in production.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingassets/claude-code-plugins/plugins/bedrock/skills/tool-use-structured-output/SKILL.md
Popularity
- Repository stars
- 169
- Repository forks
- 69
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 21 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock/tool-use-structured-output)