JSON, XML, and structured data generation patterns
Generates structured data in JSON, XML, YAML, CSV, or Markdown table formats with schema validation. Use when you need machine-readable output or when Claude needs to return data with specific fields and types.
/plugin marketplace add pluginagentmarketplace/custom-plugin-prompt-engineering/plugin install prompt-engineering-assistant@pluginagentmarketplace-prompt-engineeringThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlreferences/GUIDE.mdscripts/helper.pyBonded to: advanced-techniques-agent
Skill("custom-plugin-prompt-engineering:structured-output")
parameters:
output_format:
type: enum
values: [json, yaml, xml, csv, markdown_table]
default: json
schema_validation:
type: boolean
default: true
strict_mode:
type: boolean
default: false
description: "Fail on any schema violation"
Respond with valid JSON only. No additional text before or after.
Schema:
{
"field1": "string value",
"field2": 123,
"field3": ["array", "items"],
"field4": {
"nested": "object"
}
}
Respond with valid YAML only.
field1: string value
field2: 123
field3:
- array
- items
field4:
nested: object
Respond with valid XML only.
<root>
<field1>string value</field1>
<field2>123</field2>
<field3>
<item>array</item>
<item>items</item>
</field3>
</root>
Output must strictly match this JSON Schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"score": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"tags": {
"type": "array",
"items": {"type": "string"},
"maxItems": 5
}
},
"required": ["name", "score"],
"additionalProperties": false
}
Output must match this TypeScript interface:
interface Response {
name: string; // Required, non-empty
score: number; // 0-100
tags?: string[]; // Optional, max 5 items
metadata?: {
created: string; // ISO date format
version: number;
};
}
Output must match this Pydantic model:
class Response(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
score: float = Field(..., ge=0, le=100)
tags: Optional[List[str]] = Field(default=None, max_items=5)
## Output Schema
[Define exact schema]
## Task
[What to do]
## Input
[Data to process]
Remember: Output ONLY valid [format] matching the schema above.
## Task
Extract entities from text.
## Example
Input: "Apple CEO Tim Cook announced iPhone 15"
Output: {
"entities": [
{"name": "Apple", "type": "ORG"},
{"name": "Tim Cook", "type": "PERSON"},
{"name": "iPhone 15", "type": "PRODUCT"}
]
}
## Your Turn
Input: "[actual_text]"
Output:
Generate output following these STRICT rules:
1. Valid JSON only
2. No markdown code blocks
3. No explanatory text
4. Exactly these fields: [field_list]
5. All strings in quotes
6. No trailing commas
validation_layers:
syntax:
- JSON/YAML/XML parse check
- Well-formed structure
- Proper encoding
schema:
- Required fields present
- Types match
- Constraints satisfied
semantic:
- Values make sense
- References are valid
- Business rules met
recovery:
on_parse_error: "Request regeneration with error details"
on_schema_error: "Identify specific violations, request fix"
on_semantic_error: "Flag for review"
{
"entities": [
{"text": "extracted text", "type": "ENTITY_TYPE", "confidence": 0.95}
]
}
{
"label": "category_name",
"confidence": 0.87,
"alternatives": [
{"label": "other_category", "confidence": 0.10}
]
}
{
"summary": "Brief summary",
"findings": [
{"id": 1, "description": "Finding", "severity": "high"}
],
"recommendations": ["Action 1", "Action 2"],
"metadata": {"analyzed_at": "2025-01-01T00:00:00Z"}
}
| Issue | Cause | Solution |
|---|---|---|
| Invalid JSON | Missing quotes/commas | Add syntax examples |
| Extra text | Not enforced | Add "JSON only" constraint |
| Missing fields | Schema not clear | Use required field markers |
| Wrong types | Type confusion | Add type examples |
| Nested issues | Complex structure | Flatten or simplify schema |
integrates_with:
- prompt-design: Structure prompt for output
- prompt-evaluation: Validate output quality
- react-pattern: Tool return formats
parsing_libraries:
python: json, pydantic, jsonschema
javascript: ajv, zod
go: encoding/json, gojsonschema
See references/GUIDE.md for advanced schema patterns.
See assets/config.yaml for configuration options.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.