Skip to main content
There are two ways to write a policy: let Failproof AI draft it — from an audit finding or from your own words — or write the source yourself. Nothing is published or deployed until you choose to.

Write a policy from an audit

An audit finds a failure; a policy stops it happening again. Failproof AI drafts the policy from the finding’s own evidence.

1. Run an audit

Run an audit over the sessions where the failure happens. Each finding carries its evidence sessions, a root cause, and a suggested prevention path. Work from a finding with a repeatable action pattern — a policy can only stop what it can recognize in a hook event.

2. Generate the draft

  1. Open the finding’s insight under analyse → insights and check its cited sessions, root cause, and recommendation.
  2. Read its prevent it with a policy card. Failproof AI first says whether a policy can express the problem at all. no policy fits this one means the fix is an alert, a workflow change, or a person — not a policy.
  3. Select prevent this →. The insight’s title, finding, root cause, and recommendation become a draft in fix → policies → new policy. The button stays available when you disagree with the card’s verdict. The Policy editor compose view with policy identity, AI-assisted drafting, source validation, and publishing controls.

3. Review the draft

A draft is a starting point, not a verdict. Before publishing, check that it:
  1. Names the failure mode in operational language.
  2. Matches only the hook events and tools that carry enough evidence to decide.
  3. Uses the narrowest condition that catches the unsafe action.
  4. Returns a reason that tells the agent what to do instead.
  5. Uses instruct where the agent can safely correct course, and deny only where allowing the action is unacceptable or irreversible.
In the dashboard, review shows the rule as numbered conditions under when — remove one, or + add a condition — and what happens then: allow, instruct, or deny, with what to tell the agent. The code written for it sits beside them. When it reads right, select looks right, test it →.

4. Test it, then turn it on

test replays the draft against calls your agents already made and shows the ones it would have acted on; mark a wrong one to add an exception. Test a policy covers that and the other checks. When it behaves, select continue →. On turn on, name it, choose its mode — enforcing now, or observing first — and its machines, and select publish v… with its version number. That mints an immutable version and puts it on the machines you chose; with no machine connected it applies once it is deployed. From a terminal, publishing mints the version and deploys nothing:
publish parse-checks the source before sending it, so a syntax error surfaces here instead of on a machine at enforcement time.

Describe it in plain words

Go to fix → policies → new policy. Under what should failproof enforce?, describe the rule, pick the agent whose past calls the test replays and the machines it will run on, and select draft the policy →. Or start from one we flagged in your agents’ tool calls this week, or pick a common one. Then review, test, and turn it on as in steps 3 and 4 above.

Write it yourself

A policy is JavaScript or TypeScript against the failproofai API:
This matches production/config.yml, /srv/production/config.yml, /srv/production, and C:\\production\\config.yml for both Write and Edit, but not production-backup: production has to be a whole path segment. The context also carries the event type, normalized payload, session metadata, parameters, and source CLI when available — see the policy SDK. To publish it as a version, open fix → policies → new policy, select write it yourself or upload a file, and follow steps 3 and 4 above, or publish the file from a terminal with fp policies publish. To run it on a machine without Cloud, save it under .failproofai/policies/ with a name ending in policies.js, policies.mjs or policies.ts — those load automatically at project and user scope — or install it by path:
Give every policy a name that is unique across convention, custom, pack, and Cloud-managed policies.