Skip to lesson
Exit
Evals & Production Reliability1 / 2

1 min lesson

Guardrails - assume the model will sometimes be wrong

Match each case in "Guardrails - assume the model will sometimes be wrong" to the signal and response that fit it.

Step 1 of 2

Guardrails - assume the model will sometimes be wrong

Validation

Reject outputs that don't compile, type-check or match the expected shape before they ever land.

Allow / deny lists

Constrain which files, paths and actions the agent may touch. No edits to migrations or secrets.

Human-in-the-loop

High-risk actions stop for review. The agent proposes, a senior engineer approves, until trust is earned.

Guardrails aren't a lack of confidence in the model. They're the reason a customer lets the model near anything that matters.

Hooks are the deterministic layer

The strongest guardrail isn’t a prompt asking the model to behave - it’s real code. Cursor hooks run shell scripts at ~a dozen lifecycle trigger points: prompt submit, agent reads a file, agent writes a file, MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. tool call, terminal tool call, file deletion, before MCP access and the stop hook when a run finishes.

Canonical use: scan every prompt for PIIPersonally Identifiable Information. Data that can identify a person (names, emails, SSNs); regulated and sensitive. Press Enter for the full definition. / API keys / secrets and, if found, halt it before it reaches the model and return a custom error. A cloud agent can’t do anything that violates the hook. Build once, share across the team and agent types - hooks work in cloud agents too. (A before-prompt hook can also log which rules are actually in context, which is how you audit rule compliance.)