Blog

Prompting Claude Code for IAM: Make the Task Reviewable

November 2026 · 6 min read · Technical

Hand-drawn request note with an arrow to a checklist where one item is marked in terracotta
← Back to all posts

A pattern keeps turning up in AI builder communities. Someone asks a coding agent to give their agent permission to run workers. The agent returns a working IAM policy. It gets shipped. Only later does anyone ask whether it was the minimum permission the job needed. The policy was never wrong in an obvious way; it was just never checked against a clear statement of what the job was.

Most advice on this problem focuses on the policy that comes out. This post is about the other half: the request that goes in. A vague request produces a policy you have to trust. A specific one produces a policy you can review.

How do you prompt Claude Code to write least-privilege IAM policies?

Describe the job, not the permission. Tell Claude Code exactly what the component does, ask for the minimum permissions for that job only, require it to explain rather than silently add any permission to create resources or pass a role, and ask it to list the assumptions you still need to confirm. That gives the reviewer a written scope to check the policy against.

The difference is easiest to see side by side. A typical request reads: give my agent permission to run X. A reviewable request reads more like this:

This orchestrator only invokes an existing worker. Identify the minimum permissions for that job. Explain any permission to create resources, or to pass a role, rather than adding it by default. State the assumptions you still need me to confirm.

Nothing about the model changed between those two requests. What changed is that the second one states a boundary, so the output can be measured against it.

Why a vague request produces a policy you cannot review

A request such as give my agent permission to run workers has no stated limit. The agent has to guess what running workers includes. Does it need to create the worker, or only invoke one that already exists? Should it be able to change the worker's role? A helpful agent tends to resolve those questions by granting enough to make the task succeed, because a policy that fails is the obvious failure and an over-broad policy is not.

The reviewer then faces the same problem in reverse. Without a written statement of the job, there is nothing to compare the policy to, so review becomes a matter of reading each action and asking whether it feels reasonable. That is slow, and it is how broad permissions get approved.

Three questions the specific prompt lets you answer

Once the request names the job, review turns into three concrete checks:

  • Did the generated policy stay inside the job you asked for? Every action should map to something the component actually does.

  • Did it invent capabilities you did not request? Look in particular for create, delete, attach and pass-role actions that the job description did not mention.

  • If the orchestrator itself were compromised, could you explain the blast radius? If you cannot say in a sentence what an attacker could do with this role, it is still too broad.

The third question links to the policy-side controls we covered in the IAM PassRole trap, which explains how a single wildcard on pass-role turns a worker into an account administrator. That piece fixes the output. This one is about making the output checkable in the first place.

Vague versus reviewable requests for agent IAM policies
ElementVague requestReviewable request
ScopeRun workersInvoke one existing worker only
Create permissionsAdded if usefulExplained, not added by default
Pass-roleAdded if usefulExplained, not added by default
AssumptionsUnstatedListed for you to confirm
What review checksEach action on instinctPolicy against the stated job

Why this matters more as agents do more

A permission review that took five minutes when an agent only read a spreadsheet takes far longer once the same agent provisions cloud resources, runs workers or touches production data. In our experience, the gap between the agent asked for admin so it got admin, and the agent asked for exactly what the job needed, is where many of the AI agent security incidents we hear about begin.

For Australian firms the stakes are also regulatory. APRA-regulated entities are expected to show access controls that match the role, and a breach involving personal information brings Privacy Act obligations. A short written job description attached to each agent role is cheap evidence that someone thought about scope. As an illustrative comparison, a structured review of agent roles might cost $5,000 to $10,000 in engineering time for a mid-market team, while cleaning up after a cloud incident commonly runs well past $45,000. Both figures are illustrative, not quotes.

What specific prompting does not replace

This is guidance for how you prompt a coding assistant. It is not a runtime permission boundary. A tighter generated policy still has to be validated against your actual environment before it goes anywhere near production, and the controls around the agent itself still matter. Our guide to Claude Code permissions and sandboxing for Australian CISOs covers that layer.

Least-privilege prompting narrows what you have to check. It does not replace checking it. Treat the assumptions the agent lists as open questions, not as facts, and confirm each one before the policy is merged.

A short routine for your team

To make this a habit rather than a one-off, as at November 2026 we suggest teams adopt a simple routine for any agent-generated access policy:

  • Write one or two sentences describing the component's job before asking for a policy, and keep it with the code.

  • Use a prompt that asks for the minimum for that job, explanations for create and pass-role actions, and a list of assumptions.

  • Review the policy against the job description, then confirm each listed assumption in your real environment.

  • Record a one-line blast-radius statement for each role, and revisit it whenever the component's job changes.

If you are scoping agent permissions for a build and want a second pair of eyes on whether a generated policy is actually minimal, that is the kind of review our services cover before anything reaches production. Get in touch before you ship it.

FAQ

Frequently asked questions

Can Claude Code write IAM policies?

Yes. Claude Code can draft IAM policies from a description of what a component needs to do. The quality of the result depends heavily on how specifically you describe the job in the request.

How do I get Claude Code to follow least privilege?

Describe the exact job, ask for the minimum permissions for that job only, require explanations for any create or pass-role permission, and ask it to list assumptions you need to confirm.

Is a Claude Code generated IAM policy safe to deploy?

Not without review. Treat it as a draft, check it against the stated job, confirm every listed assumption in your real environment, and test it before it reaches production.

Does a better prompt replace runtime permission controls?

No. Specific prompting narrows what you have to review, but runtime boundaries such as sandboxing, scoped credentials and approval gates are still needed around any agent that touches real systems.

Ready to move from AI pilot to production?

We help mid-market Australian businesses deploy AI automations that actually reach production and deliver measurable ROI.