mpf
AGENTS.md66 starsChanged 12 months agoMITView on GitHub
This document provides instructions for AI agents (such as GitHub Copilot CLI) to analyze Azure Infrastructure as Code (IaC) repositories using the MPF (Minimum Permissions Finder) utility. When asked to analyze Azure IaC for minimum permissions, follow this process: Create a dedicated Service Principal for MPF analysis (it should have NO roles assigned - MPF manages roles dynamically):
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
When asked to analyze Azure IaC for minimum permissions, follow this process:
- Distinctive: line 41
Create a dedicated Service Principal for MPF analysis (it should have NO roles assigned - MPF manages roles dynamically):
- Distinctive: line 178
After analysis, delete the Service Principal:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Agent Instructions for Azure MPF
This document provides instructions for AI agents (such as GitHub Copilot CLI) to analyze Azure Infrastructure as Code (IaC) repositories using the MPF (Minimum Permissions Finder) utility.
Overview
When asked to analyze Azure IaC for minimum permissions, follow this process:
- Identify the IaC type (ARM, Bicep, or Terraform)
- Execute the Azure MPF utility to determine minimum required permissions
- List the minimum permissions needed for deployment
- Suggest Azure built-in RBAC roles that cover those permissions
Prerequisites
Required Tools
- Azure CLI (
az): Must be logged in with an account that has the following permissions:Microsoft.Authorization/roleDefinitions/read|write|deleteMicrosoft.Authorization/roleAssignments/read|write|deleteMicrosoft.Resources/subscriptions/resourcegroups/read|write|delete
- MPF Utility (
azmpf): Download from Azure/mpf releases - For Bicep: Bicep CLI installed (
biceporaz bicep) - For Terraform: Terraform CLI installed (
terraform)
Environment Variables (Required)
# Preferred snake_case form (legacy concatenated names like MPF_SUBSCRIPTIONID still work)
export MPF_SUBSCRIPTION_ID="<your-subscription-id>"
export MPF_TENANT_ID="<your-tenant-id>"
export MPF_SP_CLIENT_ID="<service-principal-client-id>"
export MPF_SP_CLIENT_SECRET="<service-principal-secret>"
export MPF_SP_OBJECT_ID="<service-principal-object-id>"Service Principal Setup
Create a dedicated Service Principal for MPF analysis (it should have NO roles assigned - MPF manages roles dynamically):
MPF_SP=$(az ad sp create-for-rbac --name "MPF-Analyzer-SP" --skip-assignment)
export MPF_SP_CLIENT_ID=$(echo $MPF_SP | jq -r .appId)
export MPF_SP_CLIENT_SECRET=$(echo $MPF_SP | jq -r .password)
export MPF_SP_OBJECT_ID=$(az ad sp show --id $MPF_SP_CLIENT_ID --query id -o tsv)
export MPF_TENANT_ID=$(az account show --query tenantId -o tsv)
export MPF_SUBSCRIPTION_ID=$(az account show --query id -o tsv)Step 1: Identify IaC Type
Detection Patterns
| IaC Type | File Patterns | Identifying Markers |
| ARM | *.json (with $schema containing deploymentTemplate) | "$schema": "https://schema.management.azure.com/schemas/...deploymentTemplate.json" |
| Bicep | *.bicep | Bicep syntax: resource, param, var, output keywords |
| Terraform | *.tf, *.tf.json | terraform {} block, provider "azurerm" {} |
Detection Commands
# Check for ARM templates
find . -name "*.json" -exec grep -l 'deploymentTemplate.json' {} \; 2>/dev/null
# Check for Bicep files
find . -name "*.bicep" 2>/dev/null
# Check for Terraform files
find . -name "*.tf" -o -name "*.tf.json" 2>/dev/nullStep 2: Execute MPF Analysis
ARM Template Analysis
azmpf arm \
--templateFilePath ./path/to/template.json \
--parametersFilePath ./path/to/parameters.json \
--jsonOutput \
--verboseBicep Analysis
export MPF_BICEP_EXEC_PATH=$(which bicep)
azmpf bicep \
--bicepFilePath ./path/to/main.bicep \
--parametersFilePath ./path/to/parameters.json \
--jsonOutput \
--verboseTerraform Analysis
export MPF_TF_PATH=$(which terraform)
# Ensure terraform is initialized
cd ./terraform-module-dir
terraform init
azmpf terraform \
--workingDir $(pwd) \
--varFilePath ./terraform.tfvars \
--jsonOutput \
--verboseCommon Optional Flags
--location <region>- Azure region (default: eastus2)--resourceGroupNamePfx <prefix>- Resource group prefix (default: testdeployrg)--showDetailedOutput- Shows per-resource permissions
Step 3: Parse MPF Output
MPF outputs permissions in JSON format when using --jsonOutput:
{
"permissions": [
"Microsoft.Storage/storageAccounts/read",
"Microsoft.Storage/storageAccounts/write",
"Microsoft.Resources/deployments/read",
"Microsoft.Resources/deployments/write"
]
}Step 4: Suggest Azure Built-in Roles
Match discovered permissions against Azure built-in roles:
| Resource Provider | Suggested Role | Role ID |
| Microsoft.Compute | Virtual Machine Contributor | 9980e02c-c2be-4d73-94e8-173b1dc7cf3c |
| Microsoft.Network | Network Contributor | 4d97b98b-1d4f-4787-a291-c67834d212e7 |
| Microsoft.Storage | Storage Account Contributor | 17d1049b-9a84-46fb-8f53-869881c3d3ab |
| Microsoft.ContainerService | Azure Kubernetes Service Contributor | ed7f3fbd-7b88-4dd4-9017-9adb7ce333f8 |
| Microsoft.ContainerRegistry | AcrPush | 8311e382-0749-4cb8-b61a-304f252e45ec |
| Microsoft.KeyVault | Key Vault Contributor | f25e0fa2-a7c8-4377-a976-54943a77a395 |
| Microsoft.Web | Website Contributor | de139f84-1756-47ae-9be6-808fbbe84772 |
| Microsoft.Sql | SQL DB Contributor | 9b7fa17d-e63e-47b0-bb0a-15c516ac86ec |
| Microsoft.Authorization | User Access Administrator | 18d7d88d-d35e-4fb5-a5c3-7773c20a72d9 |
Generate Custom Role Definition
For least-privilege access, generate a custom role:
{
"Name": "Custom Deployment Role",
"Description": "Minimum permissions for IaC deployment",
"Actions": ["<permissions-from-mpf-output>"],
"NotActions": [],
"AssignableScopes": ["/subscriptions/<subscription-id>"]
}Cleanup
After analysis, delete the Service Principal:
az ad sp delete --id "$MPF_SP_CLIENT_ID"Important Notes
- Use in Dev/Test Only: MPF actually deploys resources to determine permissions. Always run in a development or test environment.
- Resource Cleanup: MPF automatically cleans up resources it creates, but verify cleanup completed successfully.
- Execution Time: Analysis can take several minutes depending on template complexity.
- Terraform State: For Terraform, MPF may import existing resources into state. Use isolated environments.
Additional Resources
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

