# Safety rules

URL: https://code.ml.ai/docs/safety-rules

> ML AI Code safety rules live in a policy file in your repository. See an example policy and the actions the agent always refuses.

Rules live in a file in your repository, so they are reviewed like any other change. A team can tighten them for everyone, never loosen them.

## Example policy

```yaml title=".mlai/policy.yml"
production:
  branch: main
  require_pr: true            # no direct pushes to production
  require_ci_green: true      # every check must pass before promotion
  min_approvals: 1
  block_paths_without_review: ["infra/**", "payments/**"]
agent:
  modes_allowed: [plan, brief, guided]
  commands:
    allow: ["npm test", "pytest*"]     # run without asking
    deny:  ["terraform apply*"]        # never run, in any mode
secrets:
  scan: true
  ignore_paths: ["tests/fixtures/**"]
```

## Always refused

These are refused for the agent in every mode, including Auto. Force pushes are not on this list: they ask first, in every mode.

| Always refused for the agent | Why |
| --- | --- |
| Piping a download into a shell inside a workspace | Runs code nobody has read. The CLI install command is for you to run on your own computer; to read it first, download install.sh, open it, then run sh install.sh. |
| Publishing packages | Releases go through the release flow. |
| Reading SSH keys | Credentials stay out of the conversation. |
| Production deploys from the terminal | Production goes through the deploy review only. |