microsoft / microsoft/GitHub-Copilot-for-Azure
Replace azure-prepare skill per-resource quota check loop with a script
- Dominant language
- Python
- Stars
- 250
- Forks
- 204
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 67
Description
## Summary
Copilot has identified a portion of a skill that is a good candidate for replacement with a script.
The candidate is the **per-resource quota check loop** in the `azure-prepare` skill (`plugin/skills/azure-prepare/references/resources-limits-quotas.md`, with the same algorithm duplicated in `plan-template.md` Step 6 Phase 2).
> ⚠️ **Cross-skill overlap:** This same quota-checking logic also lives in the **`azure-quotas`** skill — in fact `plan-template.md` already mandates invoking `azure-quotas` to perform exactly this check (see lines 108, 141, 223). Any script created here should be designed as a **shared** asset that both `azure-prepare` and `azure-quotas` can reference, rather than two divergent copies. The two skills likely need the same script(s). Please coordinate the script's home (e.g., owned by `azure-quotas` and linked from `azure-prepare`) when implementing.
## Candidate description
The skill describes the same deterministic, looped-per-resource quota check in multiple places:
1. **Discover** — `az extension add --name quota`, then `az quota list --scope /subscriptions/{id}/providers/{provider}/locations/{region}` to find the correct quota resource names.
2. **Branch on provider support:**
- **Supported** → `az quota show` (limit) + `az quota usage show` (current usage).
- **`BadRequest` (unsupported)** → `az extension add --name resource-graph`, then `az graph query "resources | where type == '{type}' and location == '{loc}' | count"`, and look up the documented limit.
3. **Compute** — `Available = Limit − Current Usage`.
4. **Emit a checklist row** per resource and produce an overall pass / insufficient verdict.
This is a strong script candidate because it is:
- **Repeated** — the full algorithm appears in `resources-limits-quotas.md` (the Process steps, the CLI Reference, and the fully worked "Complete Check Workflow" example) and again as `plan-template.md` Step 6 Phase 2.
- **Looped and deterministic** — the same fixed sequence runs once per resource type with deterministic branching (supported vs `BadRequest`); no human judgment in the mechanical steps.
- **Output-heavy where little is needed** — `az quota list` / `usage show` / `show` and `az graph query` return verbose objects, but only a few numeric fields feed the `Limit − Usage` arithmetic.
- **Error-prone manually** — the per-resource arithmetic, scope construction, and supported/unsupported branching are easy to get wrong by hand and must be repeated identically for every resource.
**Sketch — `check-quota.{sh,ps1}`:**
- **Input:** subscription id, region, and a list of `{provider, quota-resource-name, count}` entries.
- **Output:** a compact, self-describing table — one row per resource with current usage, limit, available, and status — plus an overall pass / near-limit / insufficient verdict, so the agent can fill the plan's Provisioning Limit Checklist without re-parsing raw CLI output.
## Affected file and lines
- [`resources-limits-quotas.md` — "Process" 6-step loop (L38–L44)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-prepare/references/resources-limits-quotas.md#L38-L44)
- [`resources-limits-quotas.md` — unsupported-provider (BadRequest) fallback (L46–L60)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-prepare/references/resources-limits-quotas.md#L46-L60)
- [`resources-limits-quotas.md` — CLI Reference (L104–L126)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-prepare/references/resources-limits-quotas.md#L104-L126)
- [`resources-limits-quotas.md` — "Example: Complete Check Workflow" (L216–L305)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-prepare/references/resources-limits-quotas.md#L216-L305)
- [`plan-template.md` — Step 6 Phase 2 quota loop (L106–L124)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-prepare/references/plan-template.md#L106-L124)
## Next steps
1. **Evaluate the candidate** — confirm the steps are stable and parameterizable, and that the script captures everything the skill needs.
2. **Coordinate with `azure-quotas`** — decide where the shared script lives so both skills reference one tested implementation instead of duplicating it.
3. **Create both a bash _and_ a PowerShell version** of the script so the skill works across platforms.
4. **Run integration tests** to verify the scripts behave correctly and the skill still completes end-to-end.
## Background Information
### Why replace regular steps with scripts
Replacing a regular, well-defined series of steps with a script can:
- **Reduce token usage** — the skill no longer needs to spell out each command and parse large command output inline; the agent invokes one script and reads a compact result.
- **Improve reliability** — the logic is written and tested once, instead of being re-derived by the agent on every run.
- **Improve determinism** — the same inputs always produce the same steps and output, removing run-to-run variation.
- **Improve speed of execution** — a single script call replaces multiple round-trips of command generation, execution, and large-output parsing.
### Authoring notes for the scripts
- **Reference scripts with markdown links**, not just a bare path to the script file.
- **Include examples** in the skill showing how to run each script (sample invocation with arguments).
- **Briefly explain what each script does** where it is referenced.
- **The script output should explain what it did**, so the agent and user can understand the result without re-inspecting raw command output.
Contributor guide
Assessment
This issue has not been assessed yet.