Edictum

Contract Generator

Generate edictum contract bundles using AI. Copy the prompt, paste it into your AI assistant, describe your agent's tools and constraints, and get valid YAML.

AI Assistance

You are an expert at writing edictum contract bundles -- YAML files that enforce runtime contracts on AI agent tool calls. Generate a valid edictum/v1 ContractBundle based on my requirements. First, ask me: 1. What tools does my agent have? (e.g., read_file, write_file, bash, query_database, send_email, deploy_service, web_fetch) 2. What behaviors do I want to deny or constrain? 3. What environment does the agent run in? (development, staging, production) 4. Do I need approval workflows for any operations? 5. Do I use role-based access (principals)? Then generate the YAML following the edictum/v1 schema. Here is the complete schema reference: DOCUMENT STRUCTURE: ```yaml apiVersion: edictum/v1 kind: ContractBundle metadata: name: <slug> # [a-z0-9][a-z0-9._-]* description: "optional" defaults: mode: enforce # or observe tools: # optional, tool side-effect classifications <tool_name>: side_effect: pure|read|write|irreversible idempotent: true|false observability: # optional otel: enabled: true endpoint: "http://localhost:4317" protocol: grpc|http service_name: my-agent stdout: true file: /path/to/events.jsonl contracts: - ... ``` CONTRACT TYPES: 1. Precondition (type: pre) -- evaluates BEFORE tool execution: ```yaml - id: unique-id # [a-z0-9][a-z0-9_-]* type: pre tool: tool_name # or glob like mcp_*, or "*" for all when: <selector>: <operator>: <value> then: effect: deny # or approve (for human-in-the-loop) message: "max 500 chars, supports {args.path} placeholders" tags: [optional, tags] ``` For approval: add timeout (seconds, default 300) and timeout_effect (deny|allow). 2. Postcondition (type: post) -- evaluates AFTER tool execution: ```yaml - id: unique-id type: post tool: tool_name when: output.text: # output.text ONLY available in postconditions <operator>: <value> then: effect: warn # warn, redact, or deny message: "message" tags: [tags] ``` redact/deny only work on pure/read tools. write/irreversible fall back to warn. 3. Session (type: session) -- cumulative limits: ```yaml - id: unique-id type: session limits: # at least one required max_tool_calls: 50 max_attempts: 120 max_calls_per_tool: deploy_service: 3 then: effect: deny # MUST be deny message: "message" ``` 4. Sandbox (type: sandbox) -- allowlist boundaries: ```yaml # File paths - id: unique-id type: sandbox tools: [read_file, write_file] # tool or tools within: [/workspace, /tmp] not_within: [/workspace/.git] outside: deny # deny or approve message: "msg with {args.path}" # Commands - id: unique-id type: sandbox tool: bash allows: commands: [git, npm, node, python] outside: deny message: "msg with {args.command}" # Domains - id: unique-id type: sandbox tools: [web_fetch] allows: domains: ["api.github.com", "*.googleapis.com"] not_allows: domains: ["internal.googleapis.com"] outside: deny message: "msg with {args.url}" ``` Sandbox does NOT use when/then. Uses outside and message directly. SELECTORS: args.<key>, tool.name, environment, principal.user_id, principal.service_id, principal.org_id, principal.role, principal.ticket_ref, principal.claims.<key>, env.<VAR>, metadata.<key>, output.text (post only) OPERATORS: exists (bool), equals, not_equals, in (array), not_in (array), contains (string), contains_any (array), starts_with, ends_with, matches (regex), matches_any (array), gt, gte, lt, lte BOOLEAN COMBINATORS: all (AND array), any (OR array), not (negation) RULES: - Single-quote regex in YAML: '\b' = word boundary, "\b" = backspace - Message placeholders: {args.path}, {tool.name}, {principal.role}, etc. - Prefer sandbox over long deny-lists when attack surface is open-ended - Include helpful messages that tell the agent what to do instead - output.text is INVALID in preconditions (causes load error) - Contract IDs must be unique within the bundle After generating, explain each contract briefly.

Copy the prompt above and paste it into Claude, ChatGPT, Codex, Cursor, or any AI assistant. Describe your agent's tools and the behaviors you want to constrain. The AI will generate a valid edictum/v1 ContractBundle YAML file.

What the Prompt Does

The prompt contains the complete edictum contract schema -- all four contract types, all 15 operators, all selectors, and the expression grammar. Any AI assistant with this prompt can generate valid contract bundles without hallucinating fields or inventing syntax.

Contract Types at a Glance

TypePurposeKey Fields
preDeny tool calls before executiontool, when, then.effect: deny|approve
postInspect tool output after executiontool, when (with output.text), then.effect: warn|redact|deny
sessionEnforce cumulative limitslimits.max_tool_calls, limits.max_calls_per_tool
sandboxAllowlist boundaries (files, commands, domains)within, allows, outside: deny|approve

Examples: What You Might Say

Don't know where to start? Just list your tools and ask:

Here are the tools my agent has: read_file, write_file, bash, query_database, send_email, deploy_service. Which ones should I create contracts for, and what risks should I consider?

The AI will analyze each tool's risk profile and recommend contracts before generating any YAML.

Already know what you want? Be specific:

My agent has read_file, write_file, bash, and web_fetch tools. It should only access files in /workspace and /tmp. It should only run git, npm, node, and python commands. Block reads of .env and credential files. Detect SSN patterns in output. Cap total tool calls at 100 per session.

The AI will generate a complete contract bundle with sandbox contracts for file and command boundaries, a precondition for sensitive file reads, a postcondition for PII detection, and a session limit.

Writing Contracts by Hand

If you prefer writing contracts manually:

Last updated on

On this page