Applications need data, not paragraphs. If your resume builder needs a list of skills, a model reply like "Sure! Here are some skills..." is useless. You need structured output, usually JSON.
Ask for a schema
Describe the exact fields, types and allowed values, and say that the reply must be JSON only.
Extract data from the resume text. Reply with JSON only, no explanation.
Schema:
{
"name": string,
"skills": string[],
"experience": [{ "title": string, "company": string, "years": number | null }]
}
If a value is unknown use null. Do not invent information.
Validate every reply
Never trust model output. Parse it and validate it against a schema with a library such as Zod (JavaScript) or Pydantic (Python). Reject or repair anything that does not match.
import { z } from "zod";
const Resume = z.object({
name: z.string(),
skills: z.array(z.string()),
experience: z.array(z.object({
title: z.string(),
company: z.string(),
years: z.number().nullable(),
})),
});
const parsed = Resume.safeParse(JSON.parse(modelText));
if (!parsed.success) {
// retry with the error message, or fall back
}
Handle bad output
- Strip code fences and extra text before parsing.
- On failure, retry once with the validation error: "Your last reply failed because X. Return corrected JSON only."
- Set a retry limit and a safe fallback so a bad reply never crashes your app.
Tool calling
Many APIs, including Claude's, let you define a tool with a JSON Schema and make the model return arguments that follow it. That is usually more reliable than asking for JSON in plain text. The Claude API course shows how.