common-legacy-non-sdk-custom-code-generation
Skill4.6k starsChanged 3 months agoMITView on GitHub
Use after routing to legacy non-SDK custom, or when adding/updating Azure CLI legacy custom command functions whose main behavior is local tools, subprocesses, data-plane APIs, raw HTTP, diagnostics, install flows, file/environment orchestration, or generated AAZ commands used only as helpers.
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about Azure/azure-cli
- NixOS/nixpkgs“Build failure: azure-cli”GitHub · Aug 27, 2025 · 39 reactions
- hashicorp/terraform-provider-azuread“azuread_group_role_management_policy throws 403 permission scope not granted error”GitHub · Jun 11, 2024 · 28 reactions
- hashicorp/terraform-provider-azurerm“[preview] Support for mutual TLS and shared ssl policy in application_gateway”GitHub · Mar 29, 2021 · 25 reactions
- A Hacker News story“Azure CLI converts local accounts to MSFT online accounts on Win11”Hacker News · Jul 16, 2024 · 6 points
- A Hacker News story“Azure CLI takes ~700MB of disk space”Hacker News · Nov 30, 2023 · 3 points
The biggest 5 of 5 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository10 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
46 rules. About 0 are common, 28 are distinctive, and 18 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈28
Distinctive · estimate
This author's own choices. Worth a look.
18
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 9
Use this workflow to generate or update hand-written Azure CLI custom command code whose primary behavior is not a simple Azure Python SDK …
- Distinctive: line 17
Use this skill for:
- Distinctive: line 25
Do not use this skill for:
- Distinctive: line 53
If the primary workflow type cannot be identified, stop and ask one focused question.
- Very specific: line 59
Read the target module's commands.py around the command group and nearby CliCommandType definitions.
- Very specific: line 60
Read the nearest non-SDK handler in custom.py or sibling manual files.
- Distinctive: line 61
Search for local helpers for tool discovery, subprocess execution, credential acquisition, endpoint construction, errors, and formatting.
- Very specific: line 62
Read _params.py only if new or changed CLI parameters are required.
- Very specific: line 63
Read _help.py or generated help only if examples/help need updates.
- Distinctive: line 64
Read tests only when the workflow has existing test patterns or high behavioral risk.
- Distinctive: line 68
Before generating code, reduce uncertainty with these gates:
- Very specific: line 70
If the command can be implemented as an AAZ subclass around a matching generated operation, route to aaz-subclass-custom instead.
- Very specific: line 71
If the primary behavior is a single Azure Python SDK client CRUD/action call, route to legacy-sdk-backed-custom instead.
- Very specific: line 72
If using raw HTTP only as a small guard around an AAZ subclass, route to aaz-subclass-custom instead.
- Distinctive: line 73
If a local tool is required, resolve how the module discovers that tool and how it reports missing tools.
- Very specific: line 74
If subprocess is required, pass arguments as a list and avoid shell=True unless an existing local pattern requires it.
- Distinctive: line 75
If credentials, tokens, passwords, or connection strings are involved, never log them and never include them in errors.
- Distinctive: line 76
If the workflow reaches an external endpoint, use existing cloud suffix, profile, proxy, verification, retry, and error-handling patterns.
- Very specific: line 77
If behavior is destructive, interactive, or expensive, follow local --yes/confirmation patterns.
- Very specific: line 81
Add or reuse a CliCommandType in the registration file.
- Very specific: line 83
Add or update parameters in _params.py only when the command UX changes require it.
- Distinctive: line 84
Add the handler function in the manual code file.
- Distinctive: line 85
Keep workflow-specific logic in small helpers: tool discovery, command execution, endpoint building, credential acquisition, response …
- Distinctive: line 88
Update help/tests only when examples, parameters, or behavior changed.
- Distinctive: line 89
Run the narrowest validation available.
- Very specific: line 93
Treat templates as patterns, not fixed implementations.
- Distinctive: line 97
Use this when registering a non-SDK custom handler.
- Distinctive: line 113
Use this when the primary behavior invokes a local executable.
- Distinctive: line 142
Follow existing module patterns for tool fallback, platform-specific behavior, prompts, warning text, and diagnostics context.
- Distinctive: line 146
Use this when the primary behavior calls an HTTP endpoint or data-plane API and no SDK-backed or AAZ subclass route fits.
- Very specific: line 158
Use existing auth helpers, cloud suffixes, request verification, and error mapping from the target module.
- Distinctive: line 162
Use this when the command runs checks and reports pass/fail results.
- Distinctive: line 172
Keep diagnostic checks independently testable.
- Distinctive: line 176
Use this only when a legacy custom workflow calls a generated AAZ command internally but the public command remains legacy non-SDK custom.
- Very specific: line 188
Do not confuse this with AAZ subclass custom.
- Distinctive: line 192
If no template matches the requested workflow, do not force it into local tool, raw HTTP, or diagnostics.
- Very specific: line 221
If blocked_on is non-empty, ask a focused question instead of generating code.
- Distinctive: line 223
After editing, report the files changed and the validation command/result.
- Distinctive: line 227
Prefer the narrowest validation available:
- Distinctive: line 235
If dependencies are unavailable in the local environment, state that clearly and provide the attempted command.
- Very specific: line 239
Do not choose this skill just because code lives in custom.py.
- Distinctive: line 240
Do not classify SDK CRUD/action handlers as non-SDK because they include local validation helpers.
- Very specific: line 241
Do not use shell=True unless a local pattern requires it and inputs are controlled.
- Distinctive: line 242
Do not log secrets, tokens, passwords, credentials, or full commands containing sensitive values.
- Distinctive: line 243
Do not run destructive local tools or external operations during validation.
- Very specific: line 244
Do not edit generated AAZ files under aaz/latest.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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
Common Legacy Non-SDK Custom Code Generation
Use this workflow to generate or update hand-written Azure CLI custom command code whose primary behavior is not a simple Azure Python SDK resource operation and not an AAZ subclass customization.
This skill starts after the route is known or strongly suspected to be legacy-non-sdk-custom. If the route is unclear, use common-custom-code-router first.
Scope
This is module-general and applies across Azure CLI command modules under src/azure-cli/azure/cli/command_modules.
Use this skill for:
- local tools and subprocesses such as
docker,podman,kubectl,helm,notary,Popen,subprocess.run, orsubprocess.check_output - data-plane APIs, custom REST calls, raw HTTP,
send_raw_request,requests, orurlopenas the primary behavior - diagnostics, install flows, archive packaging, browser/proxy behavior, kubeconfig, local files, environment variables, or credential workflows
- multi-service orchestration where no single SDK CRUD/action handler describes the command
- generated AAZ commands used only as internal helpers inside a legacy custom workflow
Do not use this skill for:
- AAZ Subclass Custom (
aaz-subclass-custom): public commands implemented by subclassing generated AAZ command classes - Legacy SDK-Backed Custom (
legacy-sdk-backed-custom): public commands whose main behavior is an Azure Python SDK client CRUD/action call - editing generated files under
aaz/latest
Slots To Resolve
Resolve these slots before editing the related code. Prefer repository evidence over asking the user. These are not all user-provided inputs; some are derived or conditional.
module_name: "<module under command_modules>"
command_group: "<az command group>"
command_verb_or_action: "<CLI verb/action>"
registration_file: "<commands.py or module loader file>"
command_type_name: "<local CliCommandType variable or new variable name>"
operations_tmpl: "<azure.cli.command_modules.<module>.<file>#{}>"
handler_file: "<custom.py or another manual module file>"
handler_name: "<Python function registered by the command>"
primary_workflow_type: "<local-tool | subprocess | data-plane | raw-http | diagnostic | install | file-workflow | multi-service-orchestration | aaz-helper>"
external_dependencies: "<tool/module/service names or not-needed>"
credential_source: "<CLI profile | AAD token | username/password | environment | not-needed>"
endpoint_or_target: "<URL/resource/tool target or derived>"
confirmation_required: "<true | false | not-needed>"
output_shape: "<plain result | dict | list | warning-only | delegated tool output | local pattern>"
validation_command: "<narrow command-load/help/test command or unknown>"If the primary workflow type cannot be identified, stop and ask one focused question. Do not turn an unknown workflow into SDK-backed or AAZ custom only to fit a template.
Evidence To Gather
Gather only the evidence needed for the slots.
- Read the target module's
commands.pyaround the command group and nearbyCliCommandTypedefinitions. - Read the nearest non-SDK handler in
custom.pyor sibling manual files. - Search for local helpers for tool discovery, subprocess execution, credential acquisition, endpoint construction, errors, and formatting.
- Read
_params.pyonly if new or changed CLI parameters are required. - Read
_help.pyor generated help only if examples/help need updates. - Read tests only when the workflow has existing test patterns or high behavioral risk.
Uncertainty Gates
Before generating code, reduce uncertainty with these gates:
- If the command can be implemented as an AAZ subclass around a matching generated operation, route to
aaz-subclass-custominstead. - If the primary behavior is a single Azure Python SDK client CRUD/action call, route to
legacy-sdk-backed-custominstead. - If using raw HTTP only as a small guard around an AAZ subclass, route to
aaz-subclass-custominstead. - If a local tool is required, resolve how the module discovers that tool and how it reports missing tools.
- If subprocess is required, pass arguments as a list and avoid
shell=Trueunless an existing local pattern requires it. - If credentials, tokens, passwords, or connection strings are involved, never log them and never include them in errors.
- If the workflow reaches an external endpoint, use existing cloud suffix, profile, proxy, verification, retry, and error-handling patterns.
- If behavior is destructive, interactive, or expensive, follow local
--yes/confirmation patterns.
Implementation Workflow
- Add or reuse a
CliCommandTypein the registration file. Non-SDK custom command types often have noclient_factory. - Register the command with the local style:
g.command,g.show_command, or another existing module pattern. - Add or update parameters in
_params.pyonly when the command UX changes require it. - Add the handler function in the manual code file.
- Keep workflow-specific logic in small helpers: tool discovery, command execution, endpoint building, credential acquisition, response parsing, and error mapping.
- Reuse local error classes, validators, formatters, and logging style.
- Sanitize logs and exceptions before surfacing subprocess commands, HTTP headers, request bodies, credentials, or tokens.
- Update help/tests only when examples, parameters, or behavior changed.
- Run the narrowest validation available.
Templates
Treat templates as patterns, not fixed implementations. Replace every placeholder with names found in the target module. Never leave angle-bracket placeholders such as <handler_name> in generated code.
Template: Command Registration Without SDK Client
Use this when registering a non-SDK custom handler.
<command_type_name> = CliCommandType(
operations_tmpl='azure.cli.command_modules.<module>.<handler_file>#{}',
table_transformer=<table_transformer>,
)
with self.command_group('<command_group>', <command_type_name>) as g:
g.command('<verb-or-action>', '<handler_name>')Omit table_transformer when not used by neighboring commands. Add client_factory only when a secondary SDK helper is truly part of the existing local pattern, not because the command is registered through CliCommandType.
Template: Local Tool Or Subprocess Workflow
Use this when the primary behavior invokes a local executable.
def _get_<tool>_command():
import shutil
from knack.util import CLIError
command = '<tool>'
if not shutil.which(command):
raise CLIError("'<tool>' is required for this command. Install it and try again.")
return command
def _run_<tool>_command(command_parts):
from subprocess import PIPE, Popen
from knack.util import CLIError
process = Popen(command_parts, stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()
if process.returncode != 0:
raise CLIError(stderr.decode().strip() or "Command failed.")
return stdout.decode().strip()
def <handler_name>(cmd, <args>):
tool_command = _get_<tool>_command()
return _run_<tool>_command([tool_command, '<subcommand>', <arg_values>])Follow existing module patterns for tool fallback, platform-specific behavior, prompts, warning text, and diagnostics context.
Template: Raw HTTP Or Data-Plane Workflow
Use this when the primary behavior calls an HTTP endpoint or data-plane API and no SDK-backed or AAZ subclass route fits.
def <handler_name>(cmd, <args>):
from azure.cli.core.util import send_raw_request
url = <build_url_from_cloud_profile_and_args>(cmd, <args>)
headers = <build_headers_without_logging_secrets>(cmd, <args>)
response = send_raw_request(cmd.cli_ctx, '<METHOD>', url, headers=headers, body=<body_or_none>)
return <deserialize_or_shape_response>(response)Use existing auth helpers, cloud suffixes, request verification, and error mapping from the target module. If the API is data-plane and uses requests, follow neighboring module patterns for token acquisition and SSL/proxy handling.
Template: Diagnostic Workflow
Use this when the command runs checks and reports pass/fail results.
def <handler_name>(cmd, <args>, yes=False):
results = []
results.append(_check_<dependency>(<args>))
results.append(_check_<connectivity>(cmd, <args>))
return <format_diagnostic_results>(results)Keep diagnostic checks independently testable. For expensive or destructive checks, follow local confirmation patterns.
Template: AAZ Command As Internal Helper
Use this only when a legacy custom workflow calls a generated AAZ command internally but the public command remains legacy non-SDK custom.
def <handler_name>(cmd, <args>):
from .aaz.latest.<resource_path>._show import Show as <AAZShow>
result = <AAZShow>(cli_ctx=cmd.cli_ctx)(command_args={
'<arg-name>': <arg-value>,
})
return <continue_legacy_workflow>(cmd, result, <args>)Do not confuse this with AAZ subclass custom. If the public command itself should be an AAZ subclass, route to aaz-subclass-custom.
Fallback: Unmatched Non-SDK Business Logic
If no template matches the requested workflow, do not force it into local tool, raw HTTP, or diagnostics. First identify:
- the workflow boundary and primary side effect
- external dependencies and how the module already discovers or authenticates them
- whether the handler needs
cmd, CLI context, profile/cloud data, credentials, confirmation, or local files - output shape and error behavior
- the smallest helper functions needed to isolate risky operations
Then generate the smallest legacy handler and helpers that match the local module pattern. If the primary service interface becomes SDK or AAZ, route back to evaluation.
Output Expectations
Before editing, report:
route: legacy-non-sdk-custom
module_name: "..."
command_group: "..."
command_verb_or_action: "..."
handler_file: "..."
handler_name: "..."
primary_workflow_type: "..."
external_dependencies: "... | not-needed"
credential_source: "... | not-needed"
registration_file: "..."
customization_goals: "..."
blocked_on: []If blocked_on is non-empty, ask a focused question instead of generating code.
After editing, report the files changed and the validation command/result.
Validation
Prefer the narrowest validation available:
az <target command> -hor the repo's equivalent command-load/help test command.- A focused existing unit test for the target module.
- A command table import/load check for the target module.
- For local-tool commands, a dry-run, mockable helper test, or help/load check rather than invoking destructive external effects.
git status --shortand a diff review only when executable validation is unavailable.
If dependencies are unavailable in the local environment, state that clearly and provide the attempted command.
Common Mistakes To Avoid
- Do not choose this skill just because code lives in
custom.py. - Do not classify SDK CRUD/action handlers as non-SDK because they include local validation helpers.
- Do not use
shell=Trueunless a local pattern requires it and inputs are controlled. - Do not log secrets, tokens, passwords, credentials, or full commands containing sensitive values.
- Do not run destructive local tools or external operations during validation.
- Do not edit generated AAZ files under
aaz/latest.
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.

