agentleFS
Microsoft AzureKnown publisherAzure/azure-cli/.github/skills/common-legacy-sdk-backed-custom-code-generation/SKILL.md

common-legacy-sdk-backed-custom-code-generation

Skill4.6k starsChanged 3 months agoMITView on GitHub

Use after routing to legacy SDK-backed custom, or when adding/updating Azure CLI legacy custom command functions that call Azure Python SDK clients through CliCommandType, client_factory, cmd.get_models, g.command, g.show_command, or generic_update_command.

Trending

Quiet this year.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the Azure/azure-cli repository that our weekly crawl found: only 5 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

Show its rules and text

We split this skill into the rules it gives an agent

41 rules. About 0 are common, 23 are distinctive, and 18 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈23

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

    Use this workflow to generate or update hand-written Azure CLI custom command code whose primary implementation calls an Azure Python SDK …

    line 9
  2. Distinctive:

    Use this skill for:

    line 17
  3. Distinctive:

    Do not use this skill for:

    line 25
  4. Very specific:

    If client_factory or the SDK operation cannot be resolved, do not invent them.

    line 53
  5. Very specific:

    Read the target module's commands.py around the command group and nearby CliCommandType definitions.

    line 59
  6. Very specific:

    Read _client_factory.py for reusable cf_* factories and client shapes.

    line 60
  7. Very specific:

    Read the nearest SDK-backed handler in custom.py or a sibling manual module.

    line 61
  8. Very specific:

    Read _params.py when the change affects command behavior or argument UX for an existing or new parameter.

    line 62
  9. Very specific:

    Read _help.py or generated help when user-facing help or examples may need to stay aligned with the behavior.

    line 63
  10. Distinctive:

    Before generating code, reduce uncertainty with these gates:

    line 68
  11. Very specific:

    If matching AAZ generated assets already implement the command and the work is only an AAZ wrapper/customization, route to …

    line 70
  12. Very specific:

    If local tools, subprocesses, data-plane calls, raw HTTP, diagnostics, install flows, or file/environment orchestration are the main …

    line 71
  13. Distinctive:

    If no SDK client factory or SDK operation can be identified, stop and ask or route back to evaluation.

    line 72
  14. Distinctive:

    If the command group already has a dominant SDK-backed style, follow its registration and handler style.

    line 73
  15. Distinctive:

    If the command group is mixed, prefer the nearest sibling command with the same resource family and verb.

    line 74
  16. Distinctive:

    Do not add broad abstractions unless the module already uses them or the new command shares real logic with existing handlers.

    line 75
  17. Very specific:

    Add or reuse a CliCommandType in the registration file.

    line 79
  18. Very specific:

    Add or update parameters in _params.py when the handler signature, command behavior, or argument UX changes require it.

    line 81
  19. Distinctive:

    Add the handler function in the manual code file.

    line 82
  20. Very specific:

    Keep the handler signature aligned with registration: include cmd when using CLI context/models, include client when using a client_factory.

    line 83
  21. Distinctive:

    Run the narrowest validation available.

    line 88
  22. Very specific:

    Treat templates as patterns, not fixed implementations.

    line 92
  23. Distinctive:

    Use this when adding or wiring a SDK-backed handler.

    line 96
  24. Distinctive:

    Use this when the primary behavior is an SDK read operation.

    line 113
  25. Distinctive:

    Use this when the command builds a SDK model and sends it through a create/update SDK method.

    line 123
  26. Very specific:

    Use the exact SDK method name from the SDK client.

    line 138
  27. Distinctive:

    Use this when the command deletes a resource through the SDK.

    line 142
  28. Very specific:

    Follow neighboring command behavior for --yes prompts and LRO return handling.

    line 153
  29. Very specific:

    Use this when the module uses g.generic_update_command for read-modify-write behavior.

    line 157
  30. Distinctive:

    Only use this template when the command group already uses generic update or when read-modify-write semantics are required.

    line 185
  31. Distinctive:

    If no template matches the requested SDK-backed behavior, do not force it into CRUD.

    line 189
  32. Very specific:

    If blocked_on is non-empty, ask a focused question instead of generating code.

    line 217
  33. Distinctive:

    After editing, report the files changed and the validation command/result.

    line 219
  34. Distinctive:

    Prefer the narrowest validation available:

    line 223
  35. Distinctive:

    If dependencies are unavailable in the local environment, state that clearly and provide the attempted command.

    line 230
  36. Very specific:

    Do not choose this skill just because code lives in custom.py.

    line 234
  37. Distinctive:

    Do not invent SDK method names, model names, or client factories.

    line 235
  38. Distinctive:

    Do not ignore the command group's existing registration style.

    line 236
  39. Distinctive:

    Do not use SDK-backed templates for data-plane, subprocess, raw HTTP, or diagnostic workflows.

    line 237
  40. Very specific:

    Do not edit generated AAZ files under aaz/latest.

    line 238
  41. Distinctive:

    Do not log secrets, tokens, credentials, or full request bodies containing sensitive fields.

    line 239

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

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

Common Legacy SDK-Backed Custom Code Generation

Use this workflow to generate or update hand-written Azure CLI custom command code whose primary implementation calls an Azure Python SDK client.

This skill starts after the route is known or strongly suspected to be legacy-sdk-backed-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:

  • command handlers registered through CliCommandType, g.command, g.show_command, or g.generic_update_command
  • handler functions in custom.py or another manual module file
  • SDK client calls such as client.get, client.list, client.list_by_resource_group, client.begin_create_or_update, client.begin_create, client.begin_update, client.begin_delete, or action methods
  • SDK model construction with cmd.get_models(...)
  • command-specific validation, normalization, model shaping, LRO handling, and output shaping around SDK operations

Do not use this skill for:

  • AAZ Subclass Custom (aaz-subclass-custom): generated AAZ command subclasses, self.ctx.args, _build_arguments_schema, pre_operations, or post_operations
  • Legacy Non-SDK Custom (legacy-non-sdk-custom): local tools, subprocesses, data-plane workflows, raw HTTP as the primary implementation, diagnostics, installs, file/environment orchestration, or browser/proxy workflows
  • 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>"
client_factory: "<cf_xxx or not-needed>"
sdk_client_methods: "<client method or methods used as primary service interface>"
sdk_model_names: "<cmd.get_models names or not-needed>"
table_transformer: "<existing transformer or not-needed>"
supports_no_wait: "<true | false | not-needed>"
customization_goals: "<crud | action | generic-update | validation | model-shaping | lro | output-shaping>"
validation_command: "<narrow command-load/help/test command or unknown>"

If client_factory or the SDK operation cannot be resolved, do not invent them. Search the module's _client_factory.py, neighboring command registrations, and SDK-backed sibling handlers first. Ask one focused question only when the SDK/API choice is a product decision.

Evidence To Gather

Gather only the evidence needed for the slots.

  1. Read the target module's commands.py around the command group and nearby CliCommandType definitions.
  2. Read _client_factory.py for reusable cf_* factories and client shapes.
  3. Read the nearest SDK-backed handler in custom.py or a sibling manual module.
  4. Read _params.py when the change affects command behavior or argument UX for an existing or new parameter.
  5. Read _help.py or generated help when user-facing help or examples may need to stay aligned with the behavior.
  6. Inspect local validators, _utils.py, _validators.py, _format.py, and tests only when the target command needs those patterns.

Uncertainty Gates

Before generating code, reduce uncertainty with these gates:

  • If matching AAZ generated assets already implement the command and the work is only an AAZ wrapper/customization, route to aaz-subclass-custom instead.
  • If local tools, subprocesses, data-plane calls, raw HTTP, diagnostics, install flows, or file/environment orchestration are the main behavior, route to legacy-non-sdk-custom instead.
  • If no SDK client factory or SDK operation can be identified, stop and ask or route back to evaluation.
  • If the command group already has a dominant SDK-backed style, follow its registration and handler style.
  • If the command group is mixed, prefer the nearest sibling command with the same resource family and verb.
  • Do not add broad abstractions unless the module already uses them or the new command shares real logic with existing handlers.

Implementation Workflow

  1. Add or reuse a CliCommandType in the registration file.
  2. Register the command with the local style: g.command, g.show_command, or g.generic_update_command.
  3. Add or update parameters in _params.py when the handler signature, command behavior, or argument UX changes require it.
  4. Add the handler function in the manual code file.
  5. Keep the handler signature aligned with registration: include cmd when using CLI context/models, include client when using a client_factory.
  6. Reuse local validators/helpers for resource group resolution, resource ID parsing, SKU checks, confirmation prompts, or cloud-specific behavior.
  7. Construct SDK models with cmd.get_models(...) only for model types actually needed.
  8. Return SDK pollers directly for LRO commands unless neighboring code wraps them with LongRunningOperation for a reason.
  9. For behavior changes, do a consistency pass over the affected command surface and update related params, help/examples, validation/errors, output expectations, and focused tests as needed.
  10. 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

Use this when adding or wiring a SDK-backed handler.

<command_type_name> = CliCommandType(
    operations_tmpl='azure.cli.command_modules.<module>.<handler_file>#{}',
    client_factory=<client_factory>,
    table_transformer=<table_transformer>,
)

with self.command_group('<command_group>', <command_type_name>) as g:
    g.command('<verb-or-action>', '<handler_name>', supports_no_wait=<TrueOrFalse>)

Omit table_transformer or supports_no_wait when not used by neighboring commands.

Template: List Or Show Handler

Use this when the primary behavior is an SDK read operation.

def <handler_name>(cmd, client, <resource_args>):
    <normalized_args> = <normalize_or_validate_args>(cmd, <resource_args>)
    return client.<get_or_list_method>(<normalized_args>)

Template: Create Or Update Handler

Use this when the command builds a SDK model and sends it through a create/update SDK method.

def <handler_name>(cmd, client, <resource_args>, <option_args>):
    <ModelName>, <NestedModelName> = cmd.get_models('<ModelName>', '<NestedModelName>')

    parameters = <ModelName>(
        <property_name>=<value>,
        <nested_property>=<NestedModelName>(<nested_values>),
    )

    <apply_optional_fields>(cmd, parameters, <option_args>)
    return client.<begin_create_or_update_method>(<resource_args>, parameters)

Use the exact SDK method name from the SDK client. Do not guess begin_create_or_update if the client uses a different method.

Template: Delete Handler

Use this when the command deletes a resource through the SDK.

def <handler_name>(cmd, client, <resource_args>, yes=False):
    from azure.cli.core.util import user_confirmation

    user_confirmation("Are you sure you want to delete '<resource display>'?", yes)
    <normalized_args> = <normalize_or_validate_args>(cmd, <resource_args>)
    return client.<begin_delete_method>(<normalized_args>)

Follow neighboring command behavior for --yes prompts and LRO return handling.

Template: Generic Update

Use this when the module uses g.generic_update_command for read-modify-write behavior.

with self.command_group('<command_group>', <command_type_name>) as g:
    g.generic_update_command(
        '<verb-or-action>',
        getter_name='<getter_handler_name>',
        setter_name='<setter_handler_name>',
        custom_func_name='<custom_update_function_name>',
        custom_func_type=<command_type_name>,
        client_factory=<client_factory>,
    )


def <getter_handler_name>(cmd, client, <resource_args>):
    return client.<get_method>(<resource_args>)


def <custom_update_function_name>(cmd, instance, <option_args>):
    if <option_arg> is not None:
        instance.<sdk_property> = <option_arg>
    return instance


def <setter_handler_name>(cmd, client, <resource_args>, parameters):
    return client.<begin_update_method>(<resource_args>, parameters)

Only use this template when the command group already uses generic update or when read-modify-write semantics are required.

Fallback: Unmatched SDK Business Logic

If no template matches the requested SDK-backed behavior, do not force it into CRUD. First identify:

  • the SDK client method or method sequence
  • the SDK model inputs and return value
  • whether the behavior is a single SDK action, read-modify-write, LRO, or multi-step SDK workflow
  • whether command UX needs parameters, validators, confirmation, or output shaping

Then generate the smallest handler and helpers that express that SDK interaction. If the primary behavior stops being SDK-backed, route back to evaluation.

Output Expectations

Before editing, report:

route: legacy-sdk-backed-custom
module_name: "..."
command_group: "..."
command_verb_or_action: "..."
handler_file: "..."
handler_name: "..."
client_factory: "... | not-needed"
sdk_client_methods: "..."
sdk_model_names: "... | 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:

  1. az <target command> -h or the repo's equivalent command-load/help test command.
  2. A focused existing unit test for the target module.
  3. A command table import/load check for the target module.
  4. git status --short and 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 invent SDK method names, model names, or client factories.
  • Do not ignore the command group's existing registration style.
  • Do not use SDK-backed templates for data-plane, subprocess, raw HTTP, or diagnostic workflows.
  • Do not edit generated AAZ files under aaz/latest.
  • Do not log secrets, tokens, credentials, or full request bodies containing sensitive fields.

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.