softspark/ai-toolkit/json-mode-patterns
Claude Code and agent skill by softspark/ai-toolkit
- community
Checking that the SKILL.md file is still in the repository.
Structured JSON output from Claude: native JSON schemas, strict tools, local validation, refusal and truncation handling. Triggers: JSON mode, structured output, schema validation, JSON parsing.
Install
npx vskill@latest install softspark/ai-toolkit/json-mode-patternsSKILL.md
The same SKILL.md was published earlier as softspark/ai-toolkit/json-mode-patterns.
JSON Mode Patterns
Use native JSON outputs through output_config.format for a structured response. Use strict: true on a tool when its arguments need constrained decoding. Forcing a tool call alone does not guarantee schema compliance.
Native JSON response
This example uses the current Messages API shape. The caller supplies the approved model and output budget. Numeric limits are checked locally because raw structured output schemas do not support minimum and maximum.
Treat the returned confidence as an uncalibrated score until evaluated on labeled data. Schema compliance does not establish factual correctness.
Strict tool arguments
For a real tool, put "strict": True beside name and input_schema. Require additionalProperties: False on each object and validate business rules before executing any side effect. Check the expected tool name, content block type and stop_reason == "tool_use".
Forced tool_choice has thinking-mode restrictions. Verify the selected model's tool-choice contract before combining it with adaptive or extended thinking; do not silently disable thinking or change models to force a function call.
Failure handling
- Check
refusalandmax_tokensbefore parsing. Neither is a successful structured result. - Retry only within the caller's approved attempt and token limits. Never increase a spending limit automatically.
- Do not close truncated braces or extract the first regex-matched object and treat it as valid.
- If a proxy lacks native structured outputs, parse the entire response and validate it locally; failure is an explicit error or review item.
- For streaming, wait for completion and the final stop reason before validating assembled text.
Schema and SDK details
Raw schemas support a subset of JSON Schema. Numeric ranges, string length bounds, recursive schemas and most array-length constraints are unsupported. Apply these locally or use client.messages.parse(output_format=YourPydanticModel), whose SDK helper translates the schema and validates the original model afterward.
The SDK helper's output_format argument is not the raw Messages API field: messages.create uses output_config.format. No structured-output beta header is required. Check enum casing locally; avoid labels differing only by case.
Sources and related skills
Reviewed 2026-09-23:
Use content-moderation-patterns for decision routing and model-routing-patterns for choosing among approved models.
Security
- Security scanPassed, 100 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 repositoryCheckingapp/skills/json-mode-patterns/SKILL.md
Popularity
- Repository stars
- 177
- Repository forks
- 21
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
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/softspark/ai-toolkit/json-mode-patterns)