actrail SDK connects your agent to Actrail: it records each action
(metadata only) and checks actions against your policies. It works with
Claude Code out of the box.
Requirements
- Python 3.11 or 3.12. The system Python on macOS is 3.9 and won’t work — use a
3.11/3.12 environment (e.g.
uv venv --python 3.12). - macOS (Apple Silicon) or Linux (x86_64). On other platforms, install the source distribution (needs a Go toolchain).
Install
Commands
actrail init
actrail status
actrail doctor
actrail enforce
Whether an action is actually blocked depends on the matching policy’s mode in the
console (shadow vs. enforce).
enforce on just means the agent asks.actrail restart
actrail login
~/.actrail/config.toml (without wiring hooks or starting the
daemon).
Configuration
Config lives at~/.actrail/config.toml (permissions 0600). actrail init writes it
for you; you can also edit it directly (then actrail restart).
Environment variables
Override the file withACTRAIL_KEY and ACTRAIL_AGENT. Precedence, low to high: defaults → config file → environment →
command flags.
How it works with Claude Code
Hooks
Hooks
init writes hooks to ./.claude/settings.json:- PostToolUse → captures each action after it runs.
- PreToolUse → checks an action against policy before it runs (added by
enforce on). - SessionEnd → closes the trail so detection runs promptly.
The daemon
The daemon
A small background process holds a warm client (scanners stay loaded), so per-action
overhead stays low. It starts on
init (or on the first hook) and is managed with
actrail status / restart.Agent identity
Agent identity
Each action is attributed to
claude-code@<host>@<project> by default, so the
console can tell your agents apart. Override it with actrail init --agent <id>.Shadow vs. enforce
- Shadow (default) — actions are captured and evaluated; a matching policy reports what it would block, but nothing is blocked.
- Enforce — a matching
deny/require approvalpolicy actually stops the action.
actrail enforce on|off controls whether the
agent consults policy at all.