Skip to content
Mastering Claude

Home / Techniques that change the result

Techniques that change the result6 minApplication

Structured outputs and guardrails

Forcing an exact schema on an output and checking that output before using it are two halves of the same reflex, one forces the form upstream, the other controls it downstream, and both matter more when the action that follows cannot be undone.

Structured outputs constrain Claude's answer to follow a precise schema, which guarantees a valid output that a downstream automated process can use. Two distinct mechanisms combine here: forcing the format of an answer according to a defined schema on one side, forcing the arguments of a tool call on the other. Both impose the form before the answer leaves, neither says anything about what happens once it has arrived.

The schema forces the form, not the content

Defining a schema amounts to drawing a template: these fields, these types, this order, nothing else. A first name field expects a string, an amount field expects a number, an answer that does not fit this template is rejected before it even reaches the programme that uses it.

schema attendu : { "nom": string, "quantite": number, "urgent": boolean }
sortie recue   : { "nom": "gants de protection", "quantite": 12, "urgent": true }

The schema guarantees that the form above arrives every time, it does not guarantee that twelve is the right figure. The number of valid fields says nothing about the accuracy of any single one of them: that is exactly what a schema cannot see.

The guardrail checks what the schema cannot see

The second reflex takes over where the first stops: reading the output again once received, before passing it on to the next step. A guardrail can be a simple rule, this amount stays under a ceiling, this quantity stays positive, or a second pass that compares the output to the original request. Either way, the structured output passes through a second gate before acting, it does not just have to have the right shape.

This second gate matters more when the action that follows cannot be undone: sending a message, confirming an order, editing a shared file. A malformed output that just stays on screen gets fixed with a glance, a malformed output that triggers an action already carried out no longer gets fixed. This guardrail connects with the point already made in a green light proves nothing until it has been proven itself: a check that has never been caught out by a false output has not yet proven anything.

Figure 1

A free output against a forced output that is then reread

Free text, no schema or reread

Il faudrait sans doute une douzaine de gants de protection, et c'est plutôt urgent je pense.

Schema imposed, then reread before use
{ "nom": "gants de protection", "quantite": 12, "urgent": true } -> quantite > 0 : verifie
The figure sets a free text answer that has to be reworked by hand against the same task with an imposed schema and a rule that rereads the output before using it.
Calibrate it yourself

A warehouse worker asks Claude to read a photographed paper order form and return the item name, the quantity and an urgency flag according to a schema set in advance. The answer obtained respects the three fields and their types, with the quantity twelve and the urgency flag set to true.

Write in one sentence what this situation establishes, and in one sentence what it does not establish.

What to remember
  • An output schema guarantees the form of an answer, never the accuracy of its content, the two are checked separately.
  • The guardrail steps in after the answer, not before: it rereads what has just arrived rather than stopping a bad form from leaving.
  • An action that cannot be undone deserves a stricter guardrail than an output simply displayed on screen.
  • Forcing the form and checking the content are two distinct steps in the same flow, not two different ways of doing the same thing.
Do this now

Choose a task where you regularly ask Claude for a list or an amount, write down the three exact fields the answer must contain, and add a rule sentence you will apply yourself before using that answer.

What still needs checking

These points depend on an interface or a rule that may have changed since this was written. Check them on your own screen before relying on them.

  • The list of models that support structured outputs changes over time: open the structured outputs page on your screen and check that the model you use appears on it before building a schema on top of it.
Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.