The CLI is published on npm (npm i -g @aex-lang/cli). APIs are experimental and may change before v1.0. Roadmap →
Skip to content

The Agent Contract Layer

Policies. Contracts. Checkpoints.
One format, enforced at runtime.

Prompts are not permissions. Plans are not contracts.

How It Works

aex draft
aex review
aex run
checkpoint
resume

The model drafts. The human reviews. AEX enforces. Sessions persist.

Claude Codeor Codex CLIor any MCP clientAEX Proxydeny network.*, secrets.*allow file.*, tests.runconfirm file.writebudget calls=100meta: checkpoint, resumeUpstreamMCP Server(your tools)

Without AEX

User: "Fix the failing test in src/foo.ts"

Agent: reads src/foo.ts                    ✓
Agent: reads .env (has DB credentials)     ✓
Agent: edits src/auth.ts (unrelated)       ✓
Agent: runs `curl` to post diagnostics     ✓

Without constraints, the agent can read secrets, modify unrelated files, and make network calls — all to "help" with a test fix.

With AEX

bash
aex draft "fix the failing test in src/foo.ts"
aex review .aex/runs/fix-test.aex --run
json
{"event":"tool.allowed","tool":"tests.run"}
{"event":"tool.allowed","tool":"file.read"}
{"event":"check.passed","condition":"patch touches only target_files"}
{"event":"confirm.approved","tool":"file.write"}
{"event":"check.passed","condition":"final.passed"}
{"event":"run.finished","status":"success"}

Every tool call is gated. Every check is enforced. The contract defines the boundary.

Two Modes

AEX supports two modes of operation:

Prompt typeModeEnforcement
"Explain this code"ExploratoryPolicy via aex gate / aex proxy
"Help me debug"ExploratoryPolicy guards, no contract needed
"Fix the failing test"Contractaex draftaex reviewaex run
"Update dependency"ContractFull runtime enforcement
"Deploy to production"Contract + approvalsPolicy + task + confirmations + budget

Explore freely under policy. Execute changes through contracts.

Quick Start

bash
npm install -g @aex-lang/cli

# Set up repo policy
aex init --policy

# Generate a contract from natural language
aex draft "fix the failing test in src/foo.ts" --model anthropic

# Review what it will do
aex review .aex/runs/20260502-fix-failing-test.aex

# Approve and execute
aex review .aex/runs/20260502-fix-failing-test.aex --run

Or write contracts by hand:

bash
aex init --task fix-test                # scaffold a contract
aex check tasks/fix-test.aex           # validate it
aex effective --contract tasks/fix-test.aex  # preview permissions
aex run tasks/fix-test.aex --inputs inputs.json

Three Layers

repo/
  .aex/
    policy.aex          ← always-on repo guardrails
    runs/               ← generated one-off contracts
      fix-test.aex
      fix-test.audit.jsonl
  tasks/
    fix-test.aex        ← reusable checked-in workflows
    review-pr.aex

Policy (ambient boundary)

aex
policy workspace v0

goal "Default security boundary."

allow file.read, file.write, tests.run, git.*
deny network.*, secrets.read

confirm before file.write

budget calls=100

Task Contract (specific job)

aex
task fix_test v0

goal "Fix the failing test."

use file.read, file.write, tests.run
deny network.*, secrets.read

need test_cmd: str
need target_files: list[file]

do tests.run(cmd=test_cmd) -> failure
do file.read(paths=target_files) -> sources

make patch: diff from failure, sources with:
  - fix the failing test
  - preserve public behavior

check patch is valid diff
check patch touches only target_files
confirm before file.write

do file.write(diff=patch) -> result
do tests.run(cmd=test_cmd) -> final

check final.passed

return {
  status: "fixed",
  patch: patch
}

When both are active, effective permissions are the most restrictive combination:

Policy
allow file.*, tests.*, git.*deny network.*, secrets.*budget calls=100
+
Task
use file.read, file.write, tests.rundeny secrets.readbudget calls=20
=
Effective
allow file.read, file.write, tests.rundeny network.*, secrets.*budget calls=20

Allow is intersected. Deny is unioned. Budget takes the minimum.

Why AEX?

Draft → Review → Run

Generate contracts from natural language with aex draft. Review permissions before executing. The model proposes, AEX enforces.

Runtime Enforcement

Tool calls, file scopes, diff checks, confirmations, and budgets are enforced at runtime — not by asking the model nicely.

Readable & Diffable

Contracts are text files. Diff them, review them in PRs, reformat with aex fmt. Security policies that live with your code.

Works With Your Stack

Claude Code, Codex CLI, MCP servers, OpenAI Agents SDK, LangGraph, GitHub Actions. AEX wraps what you already use.

Audit Trail

Every tool call, check, confirmation, and budget decision is logged as structured JSON. Full observability for every execution.

Session Checkpoints

Save mid-session progress with aex.checkpoint. Resume in any MCP client with aex.resume. Cross-client, cross-session continuity.

Integrations

aex gate + aex proxy

Gate Claude Code built-in tools with hooks, MCP tools with the proxy — full coverage.

json
// .claude/settings.json
{
  "hooks": {
    "PreToolUse": [{ "matcher": ".*", "command": "aex gate" }]
  },
  "mcpServers": {
    "tools": {
      "command": "aex",
      "args": ["proxy", "--", "your-mcp-server"]
    }
  }
}

aex draft + aex review

Generate and review contracts from natural language. The model drafts, human reviews, AEX runs.

bash
aex draft "fix the failing test" --model anthropic
aex review .aex/runs/fix-test.aex --run

@aex-lang/openai-agents

Wrap OpenAI Agents SDK workflows with an AEX guardrail.

ts
import { AEXGuardedAgent } from "@aex-lang/openai-agents";

const agent = new AEXGuardedAgent({
  taskPath: "tasks/support-ticket.aex",
  tools: { "crm.lookup": crmLookup }
});

What's New

  • Draft → Review → Runaex draft generates contracts from prompts, aex review shows what a contract will do, aex review --run executes with approval.
  • aex classify — classifies prompts as exploratory or contract-requiring.
  • .aex/runs/ — generated contracts and audit logs stored alongside your policy.
  • Claude Code hookaex gate enforces policy on every built-in tool call.
  • MCP Proxyaex proxy sits between your client and upstream MCP servers.
  • Session Checkpointsaex.checkpoint and aex.resume meta-tools let agents save and reload sessions across conversations.
  • Policy filespolicy workspace v0 defines ambient security boundaries.
  • Merge semantics — allow = intersection, deny = union, budget = min.

Track ongoing work in the Roadmap.

Learn More

Prompts are not permissions. Plans are not contracts.