structured-output-doctor

structured-output-doctor is a command for Claude Code from sigistry/marketplace. It costs 23 tokens per session (837 once invoked), scanned A, original, MIT.

A command that finds LLM calls whose responses are expected to be JSON and makes those responses safer to process. It uses provider-supported schemas where available, validates the result, and retries with error feedback when needed.

In plain words
What is it for?
Use it to locate fragile JSON parsing in supported LLM SDKs and harden the calls with structured output, validation, and bounded retries.
Why use it?
It reduces failures caused by malformed JSON, markdown fences, missing fields, or unexpected values reaching application code.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: model in frontmatter.

Part of the llm-app-hardener plugin — 4 skills, 4 commands, 2 agents shipped together

Good fit Use it to locate fragile JSON parsing in supported LLM SDKs and harden the calls with structured output, validation, and bounded retries.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/sigistry/marketplace/structured-output-doctor
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.

Clone the repo
git clone --depth 1 https://github.com/sigistry/marketplace

Made for: Claude Code.

Or install llm-app-hardener, the plugin that ships this one along with the rest of its 4 skills, 4 commands, 2 agents.

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 structured-output-doctor

README.md
[![agentmods](https://agentmods.dev/badge/commands/sigistry/marketplace/structured-output-doctor/github.svg)](https://agentmods.dev/commands/sigistry/marketplace/structured-output-doctor)
Your own site
<a href="https://agentmods.dev/commands/sigistry/marketplace/structured-output-doctor"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/structured-output-doctor/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 structured-output-doctor

Your own site · 80×15
<a href="https://agentmods.dev/commands/sigistry/marketplace/structured-output-doctor"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/structured-output-doctor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 837 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.
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.00023 $0.00837
Opus 5 $0.00012 $0.00418
Sonnet 5 $0.00005 $0.00167
Haiku 4.5 $0.00002 $0.00084

Measured 7d ago against content hash 390f3085e1a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

structured-output-doctor 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 7d 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.

plugins/llm-app-hardener/commands/structured-output-doctor.md · 39 lines

How it starts

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

Find every LLM call at $ARGUMENTS (default: the LLM call sites in the current diff, or src//app//lib/) whose response is parsed as JSON, and harden it. Plain "JSON mode" or prompt-and-pray produces invalid JSON on a meaningful fraction of calls; provider-native structured output drops that failure rate by one to two orders of magnitude. This command applies the structured-output skill: switch to native schema-constrained output where the provider supports it, add a validated parse, and wrap it in a retry-with-error-feedback loop.

Process

Step 1: Detect provider and locate fragile parses

Identify the SDK (Anthropic, OpenAI, Gemini/Vertex, LangChain, Vercel AI SDK, Pydantic AI), then grep the call sites for the fragile shapes:

Smell Pattern
Blind parse JSON.parse(, json.loads(, json.loads(resp...) right after a completion
Regex extraction re.search(r"\{.*\}", /json/, .split("```"), "strip the markdown fence"
Prompt-only JSON "Respond ONLY with JSON", "return valid JSON" with no schema enforcement
Unvalidated dict access data["field"] with no schema/model between the parse and the use
Bare JSON mode response_format={"type": "json_object"} / json mode with no schema

Step 2: Choose the strongest available mechanism (apply the structured-output skill)

Per references/structured-output-apis.md, pick the best option the provider offers:

  • Schema-constrained output: Anthropic output_config.format (json_schema) or strict tool use (strict: true); OpenAI response_format: json_schema with strict: true; Gemini responseSchema; Vercel AI SDK generateObject; Pydantic AI result_type. These guarantee schema-valid output.
  • Tool/function schema: when the value is really a function argument, route it through a strict tool schema instead of free-text JSON.
  • Fallback: if the provider/model lacks native support, keep JSON mode but add strict validation + retry (below).

Read the full file on GitHub · 39 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. 7d ago First seen · 39 lines · 23 tokens per session scan A 390f3085e1a5

Subscribe to this mod's changes

structured-output-doctor is a command published in the GitHub repository sigistry/marketplace (3 stars, last pushed today), licensed MIT. It adds 23 tokens to every session and 837 once invoked, about $0.0001 per session on Opus 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.