agentleFS
Microsoft AzureKnown publisherAzure/mpf/AGENTS.md

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.

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
  1. Distinctive:

    When asked to analyze Azure IaC for minimum permissions, follow this process:

    line 7
  2. Distinctive:

    Create a dedicated Service Principal for MPF analysis (it should have NO roles assigned - MPF manages roles dynamically):

    line 41
  3. Distinctive:

    After analysis, delete the Service Principal:

    line 178

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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:

  1. Identify the IaC type (ARM, Bicep, or Terraform)
  2. Execute the Azure MPF utility to determine minimum required permissions
  3. List the minimum permissions needed for deployment
  4. 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|delete
    • Microsoft.Authorization/roleAssignments/read|write|delete
    • Microsoft.Resources/subscriptions/resourcegroups/read|write|delete
  • MPF Utility (azmpf): Download from Azure/mpf releases
  • For Bicep: Bicep CLI installed (bicep or az 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 TypeFile PatternsIdentifying Markers
ARM*.json (with $schema containing deploymentTemplate)"$schema": "https://schema.management.azure.com/schemas/...deploymentTemplate.json"
Bicep*.bicepBicep syntax: resource, param, var, output keywords
Terraform*.tf, *.tf.jsonterraform {} 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/null

Step 2: Execute MPF Analysis

ARM Template Analysis

azmpf arm \
  --templateFilePath ./path/to/template.json \
  --parametersFilePath ./path/to/parameters.json \
  --jsonOutput \
  --verbose

Bicep Analysis

export MPF_BICEP_EXEC_PATH=$(which bicep)

azmpf bicep \
  --bicepFilePath ./path/to/main.bicep \
  --parametersFilePath ./path/to/parameters.json \
  --jsonOutput \
  --verbose

Terraform 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 \
  --verbose

Common 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 ProviderSuggested RoleRole ID
Microsoft.ComputeVirtual Machine Contributor9980e02c-c2be-4d73-94e8-173b1dc7cf3c
Microsoft.NetworkNetwork Contributor4d97b98b-1d4f-4787-a291-c67834d212e7
Microsoft.StorageStorage Account Contributor17d1049b-9a84-46fb-8f53-869881c3d3ab
Microsoft.ContainerServiceAzure Kubernetes Service Contributored7f3fbd-7b88-4dd4-9017-9adb7ce333f8
Microsoft.ContainerRegistryAcrPush8311e382-0749-4cb8-b61a-304f252e45ec
Microsoft.KeyVaultKey Vault Contributorf25e0fa2-a7c8-4377-a976-54943a77a395
Microsoft.WebWebsite Contributorde139f84-1756-47ae-9be6-808fbbe84772
Microsoft.SqlSQL DB Contributor9b7fa17d-e63e-47b0-bb0a-15c516ac86ec
Microsoft.AuthorizationUser Access Administrator18d7d88d-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

  1. Use in Dev/Test Only: MPF actually deploys resources to determine permissions. Always run in a development or test environment.
  2. Resource Cleanup: MPF automatically cleans up resources it creates, but verify cleanup completed successfully.
  3. Execution Time: Analysis can take several minutes depending on template complexity.
  4. Terraform State: For Terraform, MPF may import existing resources into state. Use isolated environments.

Additional Resources

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.