ADR 009
The AI coding agent runs with least privilege
Context
Much of this platform was built with an AI coding agent (Claude Code), often directed from a phone. AI agents are productive, but they make mistakes, and their behaviour can be steered by text they read in files, web pages or tool output (prompt injection). An agent with root on a production server is a single bad instruction away from an outage or a data leak.
Options considered
| Option | For | Against |
|---|---|---|
| Agent runs as root | Can fix anything immediately | Unbounded blast radius; no review step; the agent could read every secret |
| No agent on the server; work only on a laptop | Safe | Loses most of the speed; can't check live logs or health |
| Unprivileged user; changes reach production only through Git and the normal pipeline | Every change is a commit; production apps are read-only to the agent; sudo is limited to two audited scripts | Some tasks (root clean-ups, protected apps) need the human |
Decision
- The agent runs as a normal user. Live apps in
/docker/are root-owned and read-only to it. sudoallows exactly two commands: the deploy script and the key-setup script. The key-setup script refuses protected apps (proxy, blog, workflow engine) and hostnames already in use, and logs every call.- Changes reach production only through the pipeline (ADR 002): commit, push, health check. That leaves a full Git history of what the agent changed.
- Written project rules tell the agent to ask before deleting anything, force-pushing or changing other containers.
Consequences
- Good: AI-assisted delivery speed (this platform went from empty to 18 services in about a week) with a bounded blast radius.
- Good: every change is auditable, attributable and revertible through Git.
- Cost: the agent can still push broken code to
main. The health check catches outages but not logic bugs. Planned next: pull requests with automated checks and auto-merge only on green; see gaps.
At bank scale
This is the pattern I'd propose for rolling out AI coding agents in a regulated enterprise:
- Agents get identities of their own, separate from their user's.
- Permissions are scoped per repository, with no production credentials.
- All output goes through the same pull-request, review and CI controls as human code.
- Network egress is limited to an allow-list.
- Every action is logged and linked to a human approver.
Treat the agent like a fast, capable contractor on day one: productive, supervised and unable to touch production on its own.