Skip to content

Commit b6f66a6

Browse files
authored
Add customization workflow to generate-sdk-locally skill (#14821)
1 parent 74dc59c commit b6f66a6

File tree

9 files changed

+224
-10
lines changed

9 files changed

+224
-10
lines changed

.github/skills/generate-sdk-locally/SKILL.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
name: generate-sdk-locally
33
license: MIT
44
metadata:
5-
version: "1.0.0"
5+
version: "1.1.0"
66
distribution: shared
7-
description: "Generate, build, and test Azure SDKs locally from TypeSpec. **UTILITY SKILL**. USE FOR: \"generate SDK locally\", \"build SDK\", \"run SDK tests\", \"update changelog\". DO NOT USE FOR: publishing to package registries, CI pipeline configuration, API design review. INVOKES: azure-sdk-mcp:azsdk_package_generate_code, azure-sdk-mcp:azsdk_package_build_code, azure-sdk-mcp:azsdk_package_run_tests."
7+
description: "Generate, build, and test Azure SDKs locally from TypeSpec, with automatic customization to resolve build errors and apply SDK changes. **UTILITY SKILL**. USE FOR: \"generate SDK locally\", \"build SDK\", \"run SDK tests\", \"update changelog\", \"fix SDK build errors\", \"fix breaking changes\", \"resolve SDK generation errors\", \"customize TypeSpec\", \"apply TypeSpec customization\", \"rename SDK client\", \"rename SDK model\", \"hide operation from SDK\", \"fix analyzer errors\", \"fix compilation errors\", \"resolve customization drift\", \"create subclient\", \"apply client.tsp changes\". DO NOT USE FOR: publishing to package registries, CI pipeline configuration, API design review. INVOKES: azure-sdk-mcp:azsdk_package_generate_code, azure-sdk-mcp:azsdk_package_build_code, azure-sdk-mcp:azsdk_package_run_tests, azure-sdk-mcp:azsdk_customized_code_update."
88
compatibility:
99
requires: "azure-sdk-mcp server, local azure-sdk-for-{language} clone, language build tools"
1010
---
@@ -19,25 +19,38 @@ compatibility:
1919
| `azure-sdk-mcp:azsdk_package_build_code` | Build package |
2020
| `azure-sdk-mcp:azsdk_package_run_check` | Validate package |
2121
| `azure-sdk-mcp:azsdk_package_run_tests` | Run tests |
22+
| `azure-sdk-mcp:azsdk_customized_code_update` | Apply TypeSpec and code customizations to resolve build errors, breaking changes, or SDK modification requests (includes regeneration and build internally) |
2223

2324
**Prerequisites:** azure-sdk-mcp server must be running. Without MCP, use `npx tsp-client` CLI.
2425

2526
## Steps
2627

2728
1. **Verify** — Run `azure-sdk-mcp:azsdk_verify_setup` to confirm environment.
2829
2. **Generate** — Run `azure-sdk-mcp:azsdk_package_generate_code` with `tspconfig.yaml` or `tsp-location.yaml` path.
29-
3. **Build** — Run `azure-sdk-mcp:azsdk_package_build_code`. On failure, use typespec-customization.
30-
4. **Validate** — Run `azure-sdk-mcp:azsdk_package_run_check` and `azure-sdk-mcp:azsdk_package_run_tests`.
31-
5. **Metadata** — Update metadata, changelog, and version. _(Note: For .NET data plane, skip this step — metadata, changelog, and version updates are per-commit tasks, not part of the generate/build/test workflow.)_
30+
3. **Build** — Run `azure-sdk-mcp:azsdk_package_build_code`. If the build succeeds, proceed to step 5.
31+
4. **Customize** — If build fails, or if the user requests SDK modifications, run `azure-sdk-mcp:azsdk_customized_code_update` with the build errors or user request. The tool handles the full workflow internally: it classifies the issue, applies TypeSpec decorators and/or code patches, regenerates the SDK, and builds — all in one call. See [customization workflow](references/customization-workflow.md).
32+
5. **Validate** — Run `azure-sdk-mcp:azsdk_package_run_check` and `azure-sdk-mcp:azsdk_package_run_tests`.
33+
6. **Metadata** — Update metadata, changelog, and version. _(Note: For .NET data plane, skip this step — metadata, changelog, and version updates are per-commit tasks, not part of the generate/build/test workflow.)_
3234

3335
[SDK repos](references/sdk-repos.md)
36+
[Customization workflow](references/customization-workflow.md)
3437

3538
## Examples
3639

3740
- "Generate the SDK locally for my TypeSpec service"
3841
- "Build and test the Python SDK package"
42+
- "Fix the SDK build errors on this PR"
43+
- "The SDK generation has breaking changes, resolve them"
44+
- "Rename FooClient to BarClient for .NET"
45+
- "Hide the internal polling operation from the Python SDK"
46+
- "Fix .NET analyzer errors AZC0030 and AZC0012"
47+
- "The build is failing because a customization references a renamed property"
48+
- "Create a subclient architecture for the Python SDK"
49+
- "Apply TypeSpec customizations to fix compilation errors"
3950

4051
## Troubleshooting
4152

4253
- Run `azure-sdk-mcp:azsdk_verify_setup` to confirm MCP and tools.
54+
- If build fails with type conflicts, breaking changes, analyzer errors, or customization drift, use `azure-sdk-mcp:azsdk_customized_code_update` to apply customizations.
55+
- The customization tool uses a two-phase approach: TypeSpec decorators first (Phase A), then code repairs if needed (Phase B).
4356
- Without MCP, use `npx tsp-client` CLI.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# TypeSpec Customization Workflow
2+
3+
The customization workflow is an AI-assisted process that applies TypeSpec decorators and code repairs to ensure SDK functionality. It uses a two-phase approach: **Phase A** applies `client.tsp` decorators (~80% of issues), **Phase B** applies code-level repairs when builds still fail (~10%), and the remaining ~10% receive manual guidance.
4+
5+
## Entry Points
6+
7+
The customization tool (`azure-sdk-mcp:azsdk_customized_code_update`) can be triggered from multiple sources:
8+
9+
| Entry Point | Description | Example |
10+
|-------------|-------------|---------|
11+
| **Build failures** | Compilation errors, analyzer violations, linting failures after SDK generation | `error CS0246: The type or namespace name 'FooModel' could not be found` |
12+
| **Breaking changes** | Output from breaking changes analysis tools detecting renamed/removed properties, changed types | `Breaking changes detected: FooOptions.timeout property type changed from int to Duration` |
13+
| **User prompts** | Natural language requests to modify SDK behavior | "Rename FooClient to BarClient for .NET" |
14+
| **API review feedback** | Feedback from APIView or PR comments on SDK naming/structure | "Model name doesn't follow .NET casing conventions" |
15+
| **.NET analyzer errors** | AZC0030 (naming violations), AZC0012 (generic type names), etc. | `AZC0030: Model name ends with 'Parameters'` |
16+
| **Customization drift** | Existing customization code references renamed/removed TypeSpec entities | `cannot find symbol: method getField(String)` |
17+
| **Duplicate field conflicts** | TypeSpec adds a property that already exists in manual customization code | `variable operationId is already defined in class AnalyzeOperationDetails` |
18+
19+
## When to Use
20+
21+
- Build fails after `azure-sdk-mcp:azsdk_package_build_code` with compilation errors
22+
- Type name conflicts with reserved keywords or existing types
23+
- Breaking changes from spec updates (renamed/removed properties, changed types)
24+
- API surface changes that require `client.tsp` customizations
25+
- .NET analyzer violations (AZC0030, AZC0012, etc.)
26+
- Renaming clients, models, or operations for specific language SDKs
27+
- Hiding internal operations from public SDK APIs
28+
- Restructuring client architecture (e.g., creating subclients)
29+
- Customization files reference entities that no longer exist after TypeSpec regeneration
30+
- Duplicate fields between generated code and manual customization code
31+
32+
## Customization Steps
33+
34+
1. **Capture context** — Collect the build error output, user request, or API review feedback.
35+
2. **Apply customization** — Run `azure-sdk-mcp:azsdk_customized_code_update` with the error/request context. The tool handles the full workflow internally:
36+
- Classifies the request (TypeSpec fix, code patch, or manual guidance)
37+
- Applies `client.tsp` decorators (Phase A)
38+
- Regenerates the SDK automatically
39+
- Builds to validate
40+
- If build still fails and customization files exist, applies code patches (Phase B)
41+
- Regenerates again (Java) and rebuilds
42+
3. **Validate** — Run `azure-sdk-mcp:azsdk_package_run_check` and `azure-sdk-mcp:azsdk_package_run_tests` to verify no regressions.
43+
4. **Review changes** — The tool leaves all changes uncommitted. Review with `git status`/`git diff` across both repos.
44+
45+
## Common Scenarios
46+
47+
| Scenario | Phase | Customization |
48+
|----------|-------|--------------|
49+
| Type name conflict with reserved keyword | A | Rename via `@@clientName` in `client.tsp` |
50+
| Property renamed in new API version | A | Add `@@clientName` to preserve backward compatibility |
51+
| .NET analyzer error (AZC0030, AZC0012) | A | Apply scoped `@@clientName` decorators to fix naming violations |
52+
| Hide internal operation from SDK | A | Apply `@@access` decorator with language scope |
53+
| Create subclient architecture | A | Use `@client` and `@clientInitialization` decorators |
54+
| API review naming feedback | A | Apply scoped `@@clientName` for specific language |
55+
| Duplicate field from customization conflict | B | Remove duplicate `addField()` from customization class |
56+
| Customization references renamed property | B | Update references in `_patch.py`, `*Customization.java`, or partial classes |
57+
| Feature request with no TypeSpec solution | Manual | Tool provides guidance to create customization infrastructure |
58+
59+
## Two-Phase Workflow
60+
61+
**Phase A — TypeSpec Customizations:**
62+
Apply `client.tsp` decorators (e.g., `@@clientName`, `@@access`, `@client`), regenerate SDK, validate build. Handles ~80% of issues.
63+
64+
**Phase B — Code Customizations:**
65+
Activates automatically when Phase A build fails AND customization files exist (Java: `*Customization.java`, Python: `*_patch.py`, .NET: partial classes). Applies mechanical code repairs: duplicate removal, reference updates, import fixes. Handles ~10% of issues.
66+
67+
**Manual Guidance:**
68+
When neither phase resolves the issue, or no customization files exist, the tool returns structured guidance for manual implementation.
69+
70+
## Retry Logic
71+
72+
The tool handles retries internally with a two-pass classification approach:
73+
1. First pass: classify feedback → apply TypeSpec fixes → regenerate → build
74+
2. Second pass: re-classify remaining items with build error context → apply code patches → rebuild
75+
3. If the tool response indicates build still failing, you can re-run `azure-sdk-mcp:azsdk_customized_code_update` with the updated error output
76+
4. Max 2 attempts per phase (4 total iterations within the tool)

.github/skills/generate-sdk-locally/references/sdk-repos.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
If build fails:
2121

22-
- Check for TypeSpec customization needs → use `typespec-customization` skill
23-
- Regenerate SDK after fixing issues
22+
- Run `azure-sdk-mcp:azsdk_customized_code_update` — it handles classification, TypeSpec fixes, regeneration, and build internally
23+
- See [customization workflow](customization-workflow.md) for full details
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
id: sdk-local-analyzer-errors-001
2+
name: Fix .NET Analyzer Errors via Customization
3+
description: |
4+
Test that the skill triggers customization when .NET build fails
5+
with analyzer errors like AZC0030 (naming violations) or AZC0012
6+
(generic type names).
7+
tags:
8+
- customization
9+
- analyzer
10+
- dotnet
11+
inputs:
12+
prompt: "The .NET SDK build is failing with analyzer errors: AZC0030 says the model name ends with 'Parameters' and AZC0012 says type name 'Tasks' is too generic. Can you fix these?"
13+
expected:
14+
output_contains:
15+
- "customiz"
16+
- "clientName"
17+
output_excludes:
18+
- "cannot help"
19+
outcomes:
20+
- type: tool_called
21+
tool_name: azsdk_customized_code_update
22+
behavior:
23+
max_tool_calls: 10
24+
max_response_time_ms: 60000
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
id: sdk-local-breaking-changes-001
2+
name: Resolve Breaking Changes After Spec Update
3+
description: |
4+
Test that the skill triggers customization when breaking changes
5+
are detected after a TypeSpec specification update — properties
6+
renamed, types changed, or customization code drifts.
7+
tags:
8+
- customization
9+
- breaking-changes
10+
- full-workflow
11+
inputs:
12+
prompt: "After regenerating the Java SDK, the build is failing because the service team renamed 'displayName' to 'name' in the TypeSpec. Our customization class still references getField('displayName') and it can't find the symbol. Can you fix this?"
13+
expected:
14+
output_contains:
15+
- "customiz"
16+
- "TypeSpec"
17+
output_excludes:
18+
- "cannot help"
19+
outcomes:
20+
- type: tool_called
21+
tool_name: azsdk_customized_code_update
22+
- type: tool_called
23+
tool_name: azsdk_package_build_code
24+
behavior:
25+
max_tool_calls: 12
26+
max_response_time_ms: 120000
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
id: sdk-local-customization-001
2+
name: Duplicate Field Conflict After TypeSpec Addition
3+
description: |
4+
Test that the skill triggers TypeSpec customization when SDK build
5+
fails because TypeSpec now generates a field that already exists
6+
in manual customization code, causing a duplicate field error.
7+
tags:
8+
- customization
9+
- error-handling
10+
- full-workflow
11+
inputs:
12+
prompt: "The Java SDK build is failing after regeneration. The error says 'variable operationId is already defined in class AnalyzeOperationDetails'. It looks like the service team added operationId to the TypeSpec, but our DocumentIntelligenceCustomizations.java already injects that field manually. Can you fix this?"
13+
expected:
14+
output_contains:
15+
- "customiz"
16+
- "duplicate"
17+
output_excludes:
18+
- "cannot help"
19+
outcomes:
20+
- type: tool_called
21+
tool_name: azsdk_customized_code_update
22+
- type: tool_called
23+
tool_name: azsdk_package_build_code
24+
behavior:
25+
max_tool_calls: 12
26+
max_response_time_ms: 120000

.github/skills/generate-sdk-locally/tasks/edge-case.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ id: sdk-local-edge-001
22
name: Build Failure Recovery
33
description: |
44
Test that the skill handles SDK build failures gracefully
5-
and suggests TypeSpec customization if needed.
5+
and uses TypeSpec customization to resolve errors.
66
tags:
77
- edge-case
88
- error-handling
@@ -14,6 +14,9 @@ expected:
1414
- "client.tsp"
1515
output_excludes:
1616
- "cannot help"
17+
outcomes:
18+
- type: tool_called
19+
tool_name: azsdk_customized_code_update
1720
behavior:
18-
max_tool_calls: 5
19-
max_response_time_ms: 30000
21+
max_tool_calls: 8
22+
max_response_time_ms: 60000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
id: sdk-local-hide-operation-001
2+
name: Hide Internal Operation from SDK
3+
description: |
4+
Test that the skill triggers customization when user requests
5+
hiding an internal operation from a specific language SDK.
6+
tags:
7+
- customization
8+
- user-prompt
9+
- access-control
10+
inputs:
11+
prompt: "Remove the get_create_project_status polling operation from the Python SDK public API. It's an internal operation that shouldn't be exposed to users."
12+
expected:
13+
output_contains:
14+
- "access"
15+
- "client.tsp"
16+
output_excludes:
17+
- "cannot help"
18+
outcomes:
19+
- type: tool_called
20+
tool_name: azsdk_customized_code_update
21+
behavior:
22+
max_tool_calls: 10
23+
max_response_time_ms: 60000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
id: sdk-local-rename-client-001
2+
name: Rename SDK Client via TypeSpec Customization
3+
description: |
4+
Test that the skill triggers TypeSpec customization when user
5+
requests renaming a client or model for a specific language SDK.
6+
tags:
7+
- customization
8+
- user-prompt
9+
- typespec
10+
inputs:
11+
prompt: "Rename the AIProjectConnectionEntraIDCredential model to use 'Id' instead of 'ID' in the .NET SDK. This was flagged in API review."
12+
expected:
13+
output_contains:
14+
- "clientName"
15+
- "client.tsp"
16+
output_excludes:
17+
- "cannot help"
18+
outcomes:
19+
- type: tool_called
20+
tool_name: azsdk_customized_code_update
21+
behavior:
22+
max_tool_calls: 10
23+
max_response_time_ms: 60000

0 commit comments

Comments
 (0)