json-mode-patterns

json-mode-patterns is a skill for Claude Code from softspark/ai-toolkit. It costs 42 tokens per session (1,054 once invoked), scanned A, original, Apache-2.0.

A guide to returning structured JSON from Claude, an AI model, by defining a tool whose input schema describes the required data. It also covers parsing results and recovering from incomplete output.

In plain words
What is it for?
Use it to design JSON schemas, force a model to return a specific structure, parse tool results, and handle partial responses.
Why use it?
It helps applications receive predictable machine-readable data when the model does not provide a dedicated JSON-response setting. This reduces errors when validating or processing model responses.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ai-toolkit plugin — 115 skills, 44 agents, 14 hooks shipped together

Good fit Use it to design JSON schemas, force a model to return a specific structure, parse tool results, and handle partial responses.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/softspark/ai-toolkit/json-mode-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add softspark/ai-toolkit --skill json-mode-patterns
Clone the repo
git clone --depth 1 https://github.com/softspark/ai-toolkit

Made for: Claude Code.

Or install ai-toolkit, the plugin that ships this one along with the rest of its 115 skills, 44 agents, 14 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for json-mode-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/softspark/ai-toolkit/json-mode-patterns/github.svg)](https://agentmods.dev/skills/softspark/ai-toolkit/json-mode-patterns)
Your own site
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/json-mode-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/json-mode-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for json-mode-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/json-mode-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/json-mode-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,054 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.01054
Opus 5.5 $0.00017 $0.00422
Sonnet 5.5 $0.00008 $0.00211
Haiku 4.5 $0.00004 $0.00105

Measured 1mo ago against content hash 388395b094f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

json-mode-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

app/skills/json-mode-patterns/SKILL.md · 109 lines

How it starts

The opening of the file, as written. The whole thing — 109 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

import json
import math

ANALYSIS_SCHEMA = {
    "type": "object",
    "properties": {
        "sentiment": {"type": "string", "enum": ["positive", "neutral", "negative"]},
        "confidence": {"type": "number"},
        "themes": {"type": "array", "items": {"type": "string"}},
    },
    "required": ["sentiment", "confidence", "themes"],
    "additionalProperties": False,
}


def validate_analysis(result):
    if not isinstance(result, dict) or set(result) != set(ANALYSIS_SCHEMA["required"]):
        raise ValueError("Unexpected analysis fields")
    sentiment = result["sentiment"]
    if not isinstance(sentiment, str) or sentiment.casefold() not in {"positive", "neutral", "negative"}:
        raise ValueError("Unknown sentiment")
    confidence = result["confidence"]
    if (type(confidence) not in (int, float)
            or not 0 <= confidence <= 1 or not math.isfinite(confidence)):
        raise ValueError("Confidence must be finite and between zero and one")
    themes = result["themes"]
    if not isinstance(themes, list) or not 1 <= len(themes) <= 10 or not all(isinstance(t, str) for t in themes):
        raise ValueError("Expected one to ten theme strings")
    return {**result, "sentiment": sentiment.casefold()}


def analyze(client, model, text, max_tokens):
    response = client.messages.create(
        model=model,
        max_tokens=max_tokens,
        messages=[{"role": "user", "content": text}],
        output_config={"format": {"type": "json_schema", "schema": ANALYSIS_SCHEMA}},
    )
    if response.stop_reason != "end_turn":
        raise ValueError(f"Analysis incomplete: {response.stop_reason}")
    blocks = [block.text for block in response.content if block.type == "text"]
    if len(blocks) != 1:
        raise ValueError("Expected one structured response")
    return validate_analysis(json.loads(blocks[0]))

Read the full file on GitHub · 109 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -16 lines · +3 tokens per session 388395b094f0
  2. 1mo ago First seen · 125 lines · 39 tokens per session scan A c2551f80f367

Subscribe to this mod's changes

json-mode-patterns is a skill published in the GitHub repository softspark/ai-toolkit (180 stars, last pushed 9d ago), licensed Apache-2.0. It adds 42 tokens to every session and 1,054 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

roo-fix-volatile-msg

Ladder-aware Roo Code Anthropic caching — verify the rolling read/write ladder on the wire, then close the real gaps (Vertex 4-block budget, MiniMax path).

OnlyTerp/prompt-cache-skills · 42 tokens

model-strategy

Rollenbasierte Multi-Modell-Strategie. Modellkatalog liegt in einer lokalen Konfigurationsdatei statt im Skill-Text -- Rollen (Denker/Entscheider, Dauer-Worker, Entwurfsgenerator, Reviewer/Abnahme, Eskalation), Reasoning-Effort als eigene Achse, Abnahmepflicht für Entwurfsmodelle, Anbieterwechsel für unabhängige…

ellmos-ai/skills · 107 tokens

creator-prompt-engineer

Convert creative-department outputs (script, vision, cinematography, characters, sets, storyboards, shots) into producible, consistent AI image/video prompts — with tool-specific optimization, locked anchors, negative prompts, and safe alternatives. Default image tool priority for storyboard/character sheets is GPT…

ilkaydemiralay/vision_art_creator · 135 tokens

ai-agent-builder

Conception et implémentation d'agents IA autonomes avec outils, mémoire et orchestration. Se déclenche avec "agent IA", "AI agent", "autonomous agent", "tool use", "function calling", "agent framework", "LangChain agent", "CrewAI", "AutoGen", "agent loop", "ReAct". Also triggers on "build an AI agent", "agent with…

khalilbenaz/claude-skills-collection · 90 tokens

ai-workflow-orchestrator

Orchestration de workflows IA complexes avec chaînes et pipelines. Se déclenche avec "workflow IA", "LangChain", "LangGraph", "pipeline IA", "chaîne de prompts", "orchestration LLM", "AI pipeline", "multi-step AI". Also triggers on "chain LLM calls", "orchestrate AI steps".

khalilbenaz/claude-skills-collection · 77 tokens

prompt-engineer

Use this skill when the user explicitly asks to create, write, improve, or optimize a prompt for use with an AI. Trigger on phrases like "write me a prompt", "improve this prompt", "create a system prompt", "how do I ask ChatGPT/Claude to...", or "quero um prompt para...". Do NOT trigger for direct task requests where…

ericgandrade/claude-superskills · 89 tokens