Policy Generation¶
Generate Preloop policy YAML using AI from natural-language descriptions or historical audit-log patterns.
Overview¶
Instead of writing policy YAML by hand, you can describe what you want in plain English and let an AI model generate a valid policy for you. You can also generate policies based on your actual tool usage patterns from audit logs.
Requirements
At least one AI model must be configured in your Preloop account (Settings → AI Models).
CLI Usage¶
Generate from a Prompt¶
Or read the prompt from a file:
Generate from Audit Logs¶
Analyse your historical tool-call patterns:
With a date range:
Write to File¶
Then apply it:
Flags¶
| Flag | Description |
|---|---|
-o, --output |
Write output to a file instead of stdout |
-f, --file |
Read prompt from a file |
--from-audit-logs |
Generate from audit-log patterns |
--start-date |
Filter audit logs after this date (ISO format) |
--end-date |
Filter audit logs before this date |
--no-context |
Don't include current account config as LLM context |
Web UI Usage¶
- Navigate to Tools → click Generate Policy button
- Choose From Description or From Audit Logs tab
- Enter your prompt or select date range
- Click Generate
- Review the generated YAML
- Click Apply Policy to activate it
API Endpoints¶
Generate from Prompt¶
Generate from Audit Logs¶
Response¶
How It Works¶
- Context gathering — The system collects your account's MCP servers, registered tools, and current policy (optional)
- LLM generation — Your default AI model generates valid policy YAML matching the Preloop schema
- Validation — The output is validated against the PolicyDocument schema
- Preview — You review and optionally edit the YAML before applying
For audit-log generation: 1. Pattern analysis — Historical tool calls are summarised (frequency, users, outcomes) 2. LLM generation — The summary is sent to the LLM with instructions to create appropriate rules 3. Same validation and preview flow