@withboundary/contract package. It does not require a Boundary account, API key, or hosted dashboard.
Install the Boundary skill in your AI coding agent.
Install
Define what correct means
A contract is a schema plus rules. The schema checks the shape. Rules check the values your product cares about.lead-contract.ts
debug: true turns on the built-in console logger. It prints attempts, failures, repairs, and the final result locally. No data leaves your process.
Wrap your model call
contract.accept() takes your existing LLM call as a function. Return the raw model output as a string. Boundary parses it, validates it, repairs failures when possible, and returns a typed result.
score-lead.ts
attempt.repairs is empty. If the output fails, Boundary builds repair messages from the schema and rule violations. Your next model call receives those messages.
Handle the result
result.ok is true, result.data is typed from your schema and every rule has passed. When result.ok is false, no data is returned. You decide whether to fail the request, retry with different context, or send it to a human review queue.
What local debugging shows
Withdebug: true, a failed first attempt gives you the important parts:
Next steps
Local development
Use console logging, tests, and custom hooks without an API key
Add Boundary to an LLM feature
Adapt this pattern to your existing provider code
OpenAI guide
Use Boundary with OpenAI structured outputs
Production observability
Send contract events to the hosted dashboard