agentleFS
Red-empty-potatoRed-empty-potato/ai-agent-skills/skills/structured-output-validation/SKILL.md

structured-output-validation

Skill0 starsChanged 3 months agoMITView on GitHub

Validate and repair JSON / structured output from an LLM before it is used downstream. 校验并修复 LLM 输出的 JSON 等结构化结果。

The file

Files
SKILL.md

Structured Output Validation | 结构化输出校验

Make LLM output you can parse — validate it, and repair it when the model emits broken JSON.

让模型的输出可被程序放心解析:校验,坏了就修。

When to use | 适用场景

  • 下游要解析 LLM 返回的 JSON / 表格
  • 解析偶尔报错、想让它更稳

Workflow | 工作流程

  1. 定义 schema:字段、类型、必填项。
  2. 拿到输出后先解析(json.loads / 对应解析器)。
  3. 校验类型与取值范围。
  4. 失败时带着「解析错误信息」让模型重试一次(给它看它自己输出的哪行坏了)。
  5. 仍失败则走兜底(返回错误 / 用默认值),别让程序崩溃。

Tips | 提示

  • 重试时把错误信息原样回喂,修复率远高于重新生成。
  • 能用「输出 JSON」+ schema 说明,就比纯让模型自由发挥稳得多。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.