azv-bicep-diagram-sync
Skill101 starsChanged 3 months agoMITView on GitHub
Compare Bicep templates against a Draw.io Azure architecture diagram to detect resource-level divergence. Reports differences and offers resolution — update Bicep to match the diagram, update the diagram to match Bicep, or selectively resolve per resource.
In this repository8 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
39 rules. About 0 are common, 20 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Verify the folder exists
- Distinctive: line 40
Use it as the solution folder
- Distinctive: line 43
Use the current workspace directory
- Very specific: line 44
Search for folders containing both a .drawio file and a main.bicep file
- Distinctive: line 45
If exactly one such folder is found, use it (announce which folder)
- Distinctive: line 46
If multiple are found, present the list and ask the user to select one
- Distinctive: line 47
If none are found, ask the user to provide a solution folder
- Very specific: line 52
Verify the file exists and is a .drawio or .drawio.xml file
- Distinctive: line 53
Read the file contents
- Very specific: line 56
Search the solution folder for .drawio files
- Distinctive: line 57
If exactly one is found, use it (announce which file)
- Distinctive: line 59
If none are found, report an error:
- Very specific: line 70
Search the solution folder for main.bicep
- Very specific: line 71
If found, also scan for modules/*.bicep files
- Very specific: line 72
If main.bicep is not found, report an error:
- Very specific: line 83
Follow the procedure in .github/skills/shared/procedures/diagram-parsing.md to parse the Draw.io XML into a structured resource model.
- Very specific: line 89
Follow the procedure in .github/skills/shared/procedures/bicep-parsing.md to parse all .bicep files in the solution folder.
- Very specific: line 95
Follow the matching procedure in .github/skills/shared/procedures/resource-matching.md to compare the diagram resource model (Step 2) …
- Distinctive: line 144
When drift is detected, present resolution options to the user.
- Distinctive: line 159
Wait for the user's choice before proceeding.
- Distinctive: line 163
If the user chooses to update Bicep to match the diagram:
- Distinctive: line 183
Wait for explicit confirmation.
- Very specific: line 187
Before generating Bicep, read and run the verification rules from .github/skills/shared/azure-deployment-verification.md:
- Distinctive: line 202
If no matching module exists, create one
- Very specific: line 204
Use configuration defaults from .github/skills/shared/azure-resource-configs.md
- Very specific: line 205
Add parameters to main.bicep and the .bicepparam file with descriptive comments
- Very specific: line 206
Follow Bicep best practices: parent: for child resources, @secure(), @description(), symbolic references
- Very specific: line 209
Remove the resource block from the module file
- Very specific: line 210
Remove associated parameters from main.bicep and the .bicepparam file
- Very specific: line 211
Remove module references in main.bicep if the module file is now empty
- Distinctive: line 212
Remove empty module files
- Distinctive: line 235
If the user chooses to update the diagram to match Bicep:
- Very specific: line 261
Look up each resource type in .github/skills/shared/azure-stencil-mapping.json for the correct icon and style
- Very specific: line 262
Add new mxCell elements with proper Azure icons
- Distinctive: line 263
Place new resources in the correct container based on their module file and any parent relationships in Bicep
- Very specific: line 266
Remove the corresponding mxCell elements from the XML
- Distinctive: line 268
Remove any edges connected to removed cells
- Distinctive: line 286
If the user chooses selective resolution:
- Distinctive: line 304
After all resources are resolved, present a summary:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
Compare Bicep templates in a solution folder against their source Draw.io diagram and resolve divergence.
Input: A solution folder containing Bicep templates (main.bicep, modules/*.bicep) and a Draw.io diagram file (.drawio or .drawio.xml). The user can specify the folder and diagram file, or the skill will auto-discover them.
Tools required: File system tools (read/write files), Draw.io MCP (mcp_drawio_create_diagram or mcp_draw_io_create_diagram), Bicep MCP server (for best-practice validation when regenerating Bicep)
Reference files:
.github/skills/shared/azure-resource-model.md— Shared resource metadata model definition.github/skills/shared/azure-stencil-mapping.json— Azure resource type to Draw.io stencil mapping (used for reverse-lookup and diagram generation).github/skills/shared/azure-resource-configs.md— Per-resource-type configuration schemas with defaults.github/skills/shared/azure-deployment-verification.md— Pre-deployment verification rules (MUST run before generating Bicep updates)
Shared procedures (MUST follow):
.github/skills/shared/procedures/diagram-parsing.md— Diagram-to-resource-model parsing procedure.github/skills/shared/procedures/bicep-parsing.md— Bicep template parsing procedure.github/skills/shared/procedures/resource-matching.md— Resource matching algorithm
Steps
1. Accept Inputs
Identify the solution folder, the Bicep templates, and the Draw.io diagram to compare.
1a. Identify the Solution Folder
If the user specifies a folder path:
- Verify the folder exists
- Use it as the solution folder
If no folder is specified:
- Use the current workspace directory
- Search for folders containing both a
.drawiofile and amain.bicepfile - If exactly one such folder is found, use it (announce which folder)
- If multiple are found, present the list and ask the user to select one
- If none are found, ask the user to provide a solution folder
1b. Identify the Draw.io Diagram
If the user specifies a diagram file:
- Verify the file exists and is a
.drawioor.drawio.xmlfile - Read the file contents
If no diagram file is specified:
- Search the solution folder for
.drawiofiles - If exactly one is found, use it (announce which file)
- If multiple are found, present the list and ask the user to select one
- If none are found, report an error:
## No Diagram Found
No `.drawio` files found in the solution folder `<folder-path>`.
This skill requires a Draw.io diagram to compare against the Bicep templates.- Stop execution
1c. Identify the Bicep Templates
- Search the solution folder for
main.bicep - If found, also scan for
modules/*.bicepfiles - If
main.bicepis not found, report an error:
## No Bicep Templates Found
No `main.bicep` file found in the solution folder `<folder-path>`.
This skill requires Bicep templates to compare against the diagram.- Stop execution
2. Parse Diagram into Resource Model
Follow the procedure in .github/skills/shared/procedures/diagram-parsing.md to parse the Draw.io XML into a structured resource model.
Display the parsed resource model as a table with columns: #, Resource, Type, Container.
3. Parse Bicep Templates into Resource Model
Follow the procedure in .github/skills/shared/procedures/bicep-parsing.md to parse all .bicep files in the solution folder.
Display the parsed Bicep resource model as a table with columns: #, Resource, Type, Source File, Notes.
4. Compare Resource Models
Follow the matching procedure in .github/skills/shared/procedures/resource-matching.md to compare the diagram resource model (Step 2) against the Bicep resource model (Step 3).
Additional classifications for this skill:
- In Sync (name differs) — single-instance type match with name mismatch
- Bicep Only — exists in Bicep templates but not in the diagram
- Diagram Only — exists in the diagram but not in the Bicep templates
Bicep-specific rules:
- Container resources: VNet containers in diagram should match
Microsoft.Network/virtualNetworksin Bicep - Conditional resources: Resources with
ifconditions are classified normally but noted as "conditional"
5. Present Drift Report
Display a clear drift report summarizing all differences.
Report format:
## Bicep-Diagram Sync Report: <diagram-name>
### Summary
- **In Sync:** N resources
- **Bicep Only:** N resources (in Bicep, not in diagram)
- **Diagram Only:** N resources (in diagram, not in Bicep)
### Details
| Resource | Type | Status | Notes |
|----------|------|--------|-------|
| my-vnet | VNet | ✅ In Sync | |
| my-vm | Virtual Machine | ✅ In Sync | |
| redis-cache | Redis Cache | ⬜ Bicep Only | In modules/data.bicep |
| cosmos-db | Cosmos DB | 🔷 Diagram Only | Not in Bicep templates |
| my-subnet | Subnet | ✅ In Sync (name differs) | Diagram: "default", Bicep: "snet-default" |If fully in sync:
## Bicep-Diagram Sync Report: <diagram-name>
✅ **Fully in sync!** All N resources in the diagram match the Bicep templates.
No action needed.If drift is detected, proceed to Step 6.
6. Offer Resolution Options
When drift is detected, present resolution options to the user.
### Resolution Options
Drift detected — how would you like to resolve it?
1. **Update Bicep** — Add diagram-only resources to Bicep templates, remove Bicep-only resources
2. **Update Diagram** — Add Bicep-only resources to diagram, remove diagram-only resources
3. **Selective** — Choose per-resource which direction to resolve
4. **No action** — Keep the report for reference, don't change anything
Which option? (1/2/3/4)Wait for the user's choice before proceeding.
7. Resolution: Update Bicep
If the user chooses to update Bicep to match the diagram:
7a. Confirm changes
## Confirm Bicep Changes
The following changes will be made to the Bicep templates:
**Add to Bicep** (Diagram-only resources):
- cosmos-db (Microsoft.DocumentDB/databaseAccounts)
**Remove from Bicep** (Bicep-only resources):
- redis-cache (Microsoft.Cache/redis) — in modules/data.bicep
⚠️ Removing resources from Bicep templates means they will no longer be part of deployments.
Proceed? (yes/no)Wait for explicit confirmation. If the user says no, return to Step 6.
7b. Run deployment verification
Before generating Bicep, read and run the verification rules from .github/skills/shared/azure-deployment-verification.md:
- SKU dependency rules — verify companion resources exist
- Resource compatibility rules — verify backend protocols, DNS zones
- Networking rules — verify subnet sizing, no overlaps
- Security rules — verify TLS 1.2+, HTTPS,
@secure()decorators - Version currency rules — verify runtime stacks and API versions are current
7c. Apply Bicep changes
For Diagram-only resources (add to Bicep):
- Determine the appropriate module file based on resource type:
- Networking resources →
modules/networking.bicep - Compute resources →
modules/compute.bicep - Data/storage resources →
modules/data.bicep - If no matching module exists, create one
- Networking resources →
- Generate the resource block following the rules in
.github/skills/shared/bicep-best-practices.md - Use configuration defaults from
.github/skills/shared/azure-resource-configs.md - Add parameters to
main.bicepand the.bicepparamfile with descriptive comments - Follow Bicep best practices:
parent:for child resources,@secure(),@description(), symbolic references
For Bicep-only resources (remove from Bicep):
- Remove the
resourceblock from the module file - Remove associated parameters from
main.bicepand the.bicepparamfile - Remove module references in
main.bicepif the module file is now empty - Remove empty module files
7d. Present result
## Bicep Updated ✓
**Added:** 1 resource (cosmos-db)
**Removed:** 1 resource (redis-cache)
The Bicep templates now match the diagram.
| File | Changes |
|------|---------|
| main.bicep | Added cosmos-db module reference; removed redis-cache reference |
| modules/data.bicep | Added Cosmos DB resource; removed Redis Cache resource |
| <name>.bicepparam | Added cosmos-db parameters; removed redis-cache parameters |
⚠️ Review the updated `.bicepparam` file — new parameters use defaults that you may want to customize.8. Resolution: Update Diagram
If the user chooses to update the diagram to match Bicep:
8a. Confirm changes
## Confirm Diagram Changes
The following changes will be made to the diagram:
**Add to diagram** (Bicep-only resources):
- redis-cache (Redis Cache)
**Remove from diagram** (Diagram-only resources):
- cosmos-db (Cosmos DB)
⚠️ Removing resources from the diagram is irreversible unless you have a backup.
Proceed? (yes/no)Wait for explicit confirmation. If the user says no, return to Step 6.
8b. Generate updated diagram
- Load the existing diagram XML
- For Bicep-only resources (add to diagram):
- Look up each resource type in
.github/skills/shared/azure-stencil-mapping.jsonfor the correct icon and style - Add new
mxCellelements with proper Azure icons - Place new resources in the correct container based on their module file and any parent relationships in Bicep
- For container resources (VNets, Subnets), create both the container cell and its icon child cell using the dual icon pattern
- Look up each resource type in
- For Diagram-only resources (remove from diagram):
- Remove the corresponding
mxCellelements from the XML - Also remove any associated icon cells (cells with
idending in-icon) - Remove any edges connected to removed cells
- Remove the corresponding
- Re-layout the diagram to accommodate changes (adjust container sizes, reposition as needed)
- Save the updated diagram via the Draw.io MCP tool
8c. Present result
## Diagram Updated ✓
**Added:** 1 resource (redis-cache)
**Removed:** 1 resource (cosmos-db)
The diagram now matches the Bicep templates.
Saved to `<diagram-path>`.9. Resolution: Selective
If the user chooses selective resolution:
For each drifted resource, present the options:
### Resource: cosmos-db (Cosmos DB) — Diagram Only
This resource exists in the diagram but not in the Bicep templates.
1. **Add to Bicep** — Generate a Cosmos DB resource block in modules/data.bicep
2. **Remove from Diagram** — Remove this resource from the diagram
3. **Skip** — Leave this resource unresolved
Choice? (1/2/3)Apply the user's choice for each resource following the same logic as Steps 7 and 8.
After all resources are resolved, present a summary:
## Selective Resolution Complete ✓
| Resource | Type | Action |
|----------|------|--------|
| cosmos-db | Cosmos DB | Added to Bicep |
| redis-cache | Redis Cache | Removed from Bicep |
| old-function | Function App | Skipped |
Remaining drift: 1 resource (old-function)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.

