AI Stack
AI reliability lessons
Learn five practical controls for AI workflows, with examples and sources.
AI Stack / Learn
Learn the stack, one step at a time
Use a single example: an assistant summarizes a public incident report. Each step adds a control you can test.
1. Define the job
Ask for three cited points from one specified report. Write down what counts as done before asking the model.
In the builder, name the task and an independent success check.
Read the practical guideOriginal reference: Anthropic · evaluations
2. Check the output
Require the expected fields and check that each citation actually supports its claim. Valid JSON alone does not establish truth.
Try an example with a missing citation and decide whether to reject it.
Read the practical guideOriginal reference: OWASP · prompt injection
3. Set action boundaries
Summarizing does not require the ability to publish. Keep publication and messaging behind application-level authorization and, when appropriate, human approval.
List actions that require approval; never rely on the model to grant itself permission.
Read the practical guideOriginal reference: OWASP · prompt injection
4. Test both paths
Check a valid result and a known-bad result. A test that passes both cannot distinguish success from a defect.
Run the downloadable boundary example and inspect the failing assertion.
Read the practical guideOriginal reference: Node.js · test runner
5. Recover safely
A timeout after an external write can leave the outcome unknown. Check the operation status or idempotency mechanism before retrying.
Record a safe next step for unknown results and omit private data from traces.
For example, Stripe API v1 may retain an idempotency key for at least 24 hours; after pruning, reuse can create a new request. It also checks that parameters match and may return a saved 500 response. Other services have different rules: check their documentation before retrying.
Read the practical guideOriginal reference: Stripe · idempotent requests
AI Stack / Example
Worked example: valid JSON, rejected action
This separate local example uses synthetic record IDs. A proposal can have the right format and still fail the permission check.
1. The proposal
The request asks to update record-2. Its two fields have the expected shape.
{"action":"update","recordId":"record-2"}2. Trusted state
The application supplies separate allowed and approved lists. Neither list includes record-2.
{"allowedRecordIds":["record-1"],
"approvedRecordIds":["record-1"]}3. The decision
The function rejects the request before any update. The reason comes from the permission check, not from a model.
{"ok":false,"reason":"not_authorized"}Try it locally
Download both files into one folder and run the tests with Node.js. They make no network request and change no database.
node --test decision.test.mjsDownload the function · Download the tests · Read the full walkthrough
AI Stack / Coding agents
Make coding agents easier to verify
A practical workflow informed by Claude Code’s documentation and the community collection. Adapt it to your own agent.
- Define done
Give the agent a concrete task, relevant files and a check that can fail.
- Separate checks from prompts
Run tests in your own environment; use permissions or hooks for rules that must be enforced. Review hook code before enabling it.
- Keep context useful
After a long session, carry forward verified decisions, changed files and remaining checks. Exclude secrets.