---
title: "Give agents the fewest rights they need · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/least-privilege-agents
updated: 2026-10-20
licence: "All rights reserved"
---

# Give agents the fewest rights they need

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Safety and permissions](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions)
- Rule: Give each agent token only the rights its task needs, and make it short-lived and easy to revoke.
- How: Use fine-grained tokens, such as a repository-scoped token that can push branches but not merge or change settings. Set each token to expire, such as within 30 days. Use read-only database users for analysis. See [give agent tools the least power they need](https://agentwranglers.se/playbook/adversarial-testing/ai-agents-and-models/least-privilege-tools).
- Check: With the agent's token, try to merge to the main branch, delete the repository and read another repository. All three fail. The token shows an expiry date.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers ai development playbook: https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/least-privilege-agents`.

- Previous: [Keep production credentials away from agents](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/no-production-credentials)
- Next: [Approve destructive commands](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/approve-destructive-commands)
- [Safety and permissions](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions)
