llm-structured-output
Qué hace
Esta skill ayuda a la IA a extraer información específica y organizada (como datos en formato JSON) a partir de un texto, en lugar de generar solo texto libre. Asegura que la información extraída siga un formato definido y que sea fiable para usarla en otras partes de un programa.
Cuándo usarla
- ✓Cuando necesitas que la IA devuelva datos en un formato exacto, como una lista de elementos o datos de contacto.
- ✓Cuando construyes sistemas en los que la salida de la IA debe usarse directamente en otro software (por ejemplo, para guardarla en una base de datos).
- ✓Cuando la IA devuelve datos desordenados o con un formato incorrecto y necesitas una solución fiable.
Link de la skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/llm-structured-output/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Extrae el nombre, el correo electrónico y el teléfono de este mensaje y devuélvelos en formato JSON: 'Hola, me llamo Maria Silva y mi contacto es maria.silva@email.com, teléfono 11 98765-4321.'”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
Se indica a la IA que siga un 'esquema' (una plantilla que define cómo debe organizarse la información) y se usan herramientas específicas de cada proveedor de IA (OpenAI, Anthropic, Google) para que la salida coincida exactamente con el esquema.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
LLM Structured Output
What This Skill Does
Extract typed, validated data from LLM API responses instead of parsing free-text. This skill covers the three main approaches: OpenAI's response_format with JSON Schema, Anthropic's tool_use block for structured extraction, and Google's responseSchema in Gemini. You will learn when each approach works, when it breaks, and how to build retry logic around schema validation failures that every production system encounters.
When to Use This Skill
- The user needs to extract structured data (JSON objects, arrays, enums) from an LLM response
- The user is building a pipeline where LLM output feeds directly into code (database writes, API calls, UI rendering)
- The user asks about
response_format,json_mode,json_object, orjson_schemain OpenAI - The user asks about using Anthropic's
tool_useortool_resultblocks for data extraction (not for actual tool execution) - The user asks about Zod schemas with
zodResponseFormat()from theopenainpm package - The user needs to parse LLM output into Pydantic models using
instructor,marvin, or manual validation - The user is getting malformed JSON, missing fields, or wrong types from LLM responses and needs a fix
- The user asks about
controlled generation,constrained decoding, orgrammar-based samplingin local models
Do NOT use this skill when:
- The user wants free-form text generation (summaries, essays, chat)
- The user is asking about Zod for form validation or API input validation (use
zod-validation-expertinstead) - The user needs prompt engineering for better text quality (not structure)
- The user wants to call real external tools/APIs (this skill covers using tool_use as a structured output hack, not actual tool orchestration)
Core Workflow
Identify the target schema. Ask the user what fields they need extracted. Define every field with its type, whether it's required or optional, and valid enum values if applicable. Do not proceed without a concrete schema.
Choose the provider-appropriate method:
- OpenAI (gpt-4o, gpt-4o-mini): Use
response_format: { type: "json_schema", json_schema: { ... } }. This enables Structured Outputs with guaranteed schema conformance via constrained decoding. - Anthropic (Claude): Define a single tool with the target schema as
input_schemaand settool_choice: { type: "tool", name: "extract_data" }. Claude returns the structured data in thetool_usecontent block. - Google (Gemini): Use
generationConfig.responseSchemawith a JSON Schema object and setresponseMimeType: "application/json". - Local models (llama.cpp, vLLM): Use GBNF grammars or
--json-schemaflag for constrained decoding at the token level.
- OpenAI (gpt-4o, gpt-4o-mini): Use
Write the schema definition in the user's language. For Python, define a Pydantic
BaseModel. For TypeScript, define a Zod schema and convert it withzodResponseFormat(). For raw API calls, write JSON Schema directly.Include field-level descriptions in the schema. Every field should have a
descriptionstring that tells the model what to put there. Models use these descriptions as implicit prompt instructions — a field described as"The user's sentiment as positive, negative, or neutral"produces better results than a baresentiment: strwith no context.Set the system prompt to reinforce structure. Tell the model its job is data extraction, not conversation. Example:
"You are a data extraction system. Analyze the input and return the requested fields. Do not include explanations outside the JSON structure."If using OpenAI's
json_schemamode, set"strict": truein the schema definition. This activates constrained decoding where the model can only output tokens that conform to the schema. Withoutstrict: true, the model may still produce invalid JSON.If using Anthropic's tool_use approach, extract the structured data from
response.contentby finding the block wheretype == "tool_use"and reading itsinputfield. Do not parse the text blocks — the structured data lives exclusively in the tool_use block.Validate the response against the schema in your application code. Even with constrained decoding, validate with Pydantic's
model_validate()or Zod's.parse()before passing data downstream. This catches semantic issues (empty strings, out-of-range numbers) that schema conformance alone cannot prevent.
…
Preguntas frecuentes
¿Por qué la IA a veces devuelve un JSON no válido?
Puede pasar si la IA no recibe bien las instrucciones sobre el formato o si el proveedor de IA no tiene un mecanismo sólido para obligar a la salida a seguir el esquema. Esta skill enseña a usar esos mecanismos.
¿Qué es un 'esquema'?
Un esquema es como un molde o un plano que define la estructura de los datos esperados: qué campos deben existir, qué tipo de información contiene cada uno (texto, número, etc.) y si son obligatorios u opcionales.
¿Funciona con cualquier IA?
Esta skill se centra en cómo hacerlo con las APIs de proveedores importantes como OpenAI, Anthropic y Google. Para los modelos que se ejecutan en local también existen técnicas parecidas.
Detalles
Descripción original del autor
Get reliable JSON, enums, and typed objects from LLMs using response_format, tool_use, and schema-constrained decoding across OpenAI, Anthropic, and Google APIs.
Popularidad
- Estrellas en GitHub
- 48 mil
- Posición en el ranking
- #5091
- Licencia
- MIT
- Actualizada
- 15/10/2026
Comentarios
- …
Más skills de este repositorio
00-andruia-consultant
48 milAyuda a tu agente a iniciar o mejorar proyectos de IA. Analiza código, sugiere herramientas y crea planes de acción en español.
007
48 milPermite que tu agente realice auditorías de seguridad y modelado de amenazas. Es útil para proteger proyectos contra ataques y vulnerabilidades.
10-andruia-skill-smith
48 milAyuda a tu agente a crear o mejorar herramientas de IA. Define cómo funcionan, escribe la documentación y valida la estructura.
20-andruia-niche-intelligence
48 milPermite que tu agente cree un resumen de un sector específico. Es útil para entender su contexto, normas, patrones de uso y riesgos, usando fuentes fiables.
Skills parecidas
writing-skills
311 milEnseña a tu agente a escribir skills nuevas y a probar cada una primero, comprobando que realmente cambia la forma en que se comporta el agente.
writing-for-agents
310 milExplica cómo escribir instrucciones claras para agentes de IA, incluidas las skills y los archivos AGENTS.md y CLAUDE.md, para que el agente se comporte de forma predecible.
bengali-nlp
280 milHace que tu agente procese texto en bengalí. Ayuda a entender y trabajar con el idioma, normalizando el texto y gestionando sus características propias.