llm-json-output

llm-json-output is a skill for Claude Code, Codex from vikasudasi/skill-vault. It costs 26 tokens per session (383 once invoked), scanned A, original, Apache-2.0.

A guide for making language models return machine-readable JSON that follows a defined shape. It covers schemas, cleanup, validation, and retrying invalid responses.

In plain words
What is it for?
Use it when model output feeds tools, settings, APIs, or other programs that need validated JSON.
Why use it?
It prevents downstream code from breaking when a model adds extra text, uses the wrong data type, or returns malformed JSON.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when model output feeds tools, settings, APIs, or other programs that need validated JSON.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vikasudasi/skill-vault/llm-json-output
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 vikasudasi/skill-vault --skill llm-json-output
Clone the repo
git clone --depth 1 https://github.com/vikasudasi/skill-vault

Made for: Claude Code, Codex.

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 llm-json-output

README.md
[![agentmods](https://agentmods.dev/badge/skills/vikasudasi/skill-vault/llm-json-output/github.svg)](https://agentmods.dev/skills/vikasudasi/skill-vault/llm-json-output)
Your own site
<a href="https://agentmods.dev/skills/vikasudasi/skill-vault/llm-json-output"><img src="https://agentmods.dev/badge/skills/vikasudasi/skill-vault/llm-json-output/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 llm-json-output

Your own site · 80×15
<a href="https://agentmods.dev/skills/vikasudasi/skill-vault/llm-json-output"><img src="https://agentmods.dev/badge/skills/vikasudasi/skill-vault/llm-json-output.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 383 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.00026 $0.00383
Opus 5 $0.00013 $0.00192
Sonnet 5 $0.00005 $0.00077
Haiku 4.5 $0.00003 $0.00038

Measured 8d ago against content hash 690ed7e533a9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

llm-json-output 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 8d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/json_parser.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skill_vault/data/skills/llm-json-output/SKILL.md · 48 lines

What it actually says

Reliable Structured JSON from LLMs

Use when an LLM must return machine-parseable JSON — for tool results, configs, or data you validate downstream.

Prefer native structured output when available

Many providers offer a JSON schema / structured-output mode that constrains generation. If available, pass your Pydantic schema and skip manual prompt hacks.

Fallback: prompt with a schema

Return a JSON object with exactly these keys:
{"name": string, "port": int, "enabled": bool}
No other text, no markdown fences.

Add 1-2 examples of the exact shape you want.

Always validate + retry

Never trust the raw string. Parse, validate against your model, and on failure re-prompt with the error (Invalid JSON: {e}. Please retry). Cap retries (2-3); if still failing, fall back to a degraded default.

Strip markdown fences

Models often wrap JSON in ```json fences — strip them before json.loads.

Pitfalls

  • JSON is order-sensitive to the model's tokens, not to you: keep the schema small.
  • Booleans/numbers coerce surprisingly; validate types, not just that it parses.
  • Don't paste secrets or huge schemas into the prompt — it costs tokens and dilutes output.
Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 48 lines · 26 tokens per session scan A 690ed7e533a9

Subscribe to this mod's changes

llm-json-output is a skill published in the GitHub repository vikasudasi/skill-vault (0 stars, last pushed 23d ago), licensed Apache-2.0. It adds 26 tokens to every session and 383 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-08-31.

Related

Other skills, from other repositories

llm-integration

LLM integration patterns for function calling, streaming responses, local inference with Ollama, and fine-tuning customization. Use when implementing tool use, SSE streaming, local model deployment, LoRA/QLoRA fine-tuning, or multi-provider LLM APIs.

yonatangross/orchestkit · 58 tokens

prompt-engineering

Use when one prompt must give the same right answer across reruns, models, and pasted-in hostile input: forcing a fixed schema, picking the few-shot set, ordering the prompt blocks, or the inline cases you run while tuning. NOT the agent loop, tools, or retrieval (that is building-agents), NOT a standing CI eval…

ericrisco/rsc-harness · 83 tokens

llm-engineering-expert

Build reliable applications on large language models: prompt design, structured output, evaluation, guardrails, and cost and latency control. Use when the user mentions LLMs, prompts, prompt engineering, few-shot examples, structured or JSON output, function calling, hallucination, model evaluation, token costs…

personamanagmentlayer/pcl · 92 tokens

openai-patterns

Production OpenAI API patterns — model selection, prompt engineering, function calling, streaming, error handling, cost control, and structured outputs.

chandrudp29/skillhub · 31 tokens

prompt_engineering

Expert guide on prompt engineering for 2024-2025 models (GPT-4o, Claude 3.5, o1, o3, Gemini 2.0). Covers reasoning models, delimiters, structured output, and context engineering.

ApexIQ/skillsmith · 55 tokens

prompt-engineering

Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability in production. Use when optimizing prompts, improving LLM outputs, designing production prompt templates, or building AI-powered features.

wpank/ai · 44 tokens