azure/azure-ai-projects-emit-from-typespec
Emit the azure-ai-projects Python SDK from TypeSpec, apply post-emitter fixes, and create a Pull Request. WHEN: \"emit SDK from TypeSpec\", \"generate azure-ai-projects SDK\", \"update azure-ai-projects from TypeSpec\", \"emit from TypeSpec\", \"regenerate azure-ai-projects\". DO NOT USE FOR: other Azure SDK packages, manual code edits without TypeSpec. INVOKES: PostEmitter.ps1 script, git commands, gh CLI for PR creation.
npx skills add https://github.com/Azure/azure-sdk-for-python --skill azure-ai-projects-emit-from-typespec
This skill guides Copilot through emitting the azure-ai-projects Python SDK from TypeSpec,
applying post-emitter fixes, updating the changelog, installing package from sources and creating a Pull Request.
Working directory: sdk/ai/azure-ai-projects
Before asking workflow questions, validate prerequisites in this section.
If any required check fails:
Run these checks in order:
Run:
pwsh --version
git --version
gh --version
python --version
pip --version
node --version
npm --version
tsp-client --version
If any command is missing, stop and show the matching install command:
winget install --id Microsoft.PowerShell --source wingetwinget install --id Git.Git --source wingetwinget install --id GitHub.cli --source wingetwinget install --id Python.Python.3 --source wingetwinget install --id OpenJS.NodeJS.LTS --source wingetnpm install -g @azure-tools/typespec-client-generator-cliRun:
git rev-parse --show-toplevel
git rev-parse --show-prefix
Expected:
git rev-parse --show-prefix returns exactly sdk/ai/azure-ai-projects/If not, stop and ask the user to switch to the sdk/ai/azure-ai-projects folder.
Run:
python -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 9) else 1)"
If this fails, stop and ask the user to install or activate Python 3.9+.
Run:
gh auth status
If not authenticated, stop and ask the user to run:
gh auth login
Run:
git config user.name
git config user.email
If either value is empty, stop and ask the user to run:
git config user.name "<your-name>"
git config user.email "<your-email>"
Run:
git status --porcelain
If output is not empty, stop and ask the user to commit/stash/discard local changes before continuing.
Run:
python -m pip install -r dev_requirements.txt
If this command fails, stop and report the error to the user.
Important:
az) is not required for this skill workflow and must not be checked in preflight.Ask the user the following questions one at a time, waiting for each answer before proceeding.
Ask the user to choose one of the following two options for the target topic branch:
github-userid is the user's personal GitHub ID (not the Microsoft Enterprise Managed User (EMU) account!) and DD-MM-HHMM is the current date-time using date, month, hour and minute. For example, if the GitHub ID is "dargilco" and the current date and time is May 1st, 2026 at 8:13am, the default branch name would be dargilco/emit-from-typespec-01-05-0813. This should be the default option, and the default branch name should be displayed. If you press enter without typing anything, this option will be selected.feature/azure-ai-projects/vnext then stop and report that they cannot emit directly to the current feature branch.feature/azure-ai-projects/vnext then stop and report that they cannot emit directly to the current feature branch.Ask the user to choose one of the following three options for the TypeSpec source:
feature/foundry-release – Automatically find the latest commit to the feature/foundry-release branch in Azure/azure-rest-api-specs that touched files under specification/ai-foundry/data-plane/Foundry, and use that commit hash. This should be the default option. If you press enter without typing anything, this option will be selected.\specification\ai-foundry\data-plane\Foundry\src\sdk-python-js-azure-ai-projects. If it does not end with that string, stop and report the error to the user. Do not continue.Before creating the topic branch, record the name of the current Git branch. This is the branch that the topic branch will be created from, and the branch the PR will target.
git branch --show-current
Save this as BASE_BRANCH.
Create the topic branch off the current branch and switch to it:
git fetch
git switch -c <topic-branch> origin/<BASE_BRANCH>
Replace <topic-branch> with the name provided by the user in Step 2a.
If you are emitting from latest commit or a given commit number, edit file tsp-location.yaml to update the full hash commit number, then in the folder sdk/ai/azure-ai-projects run the command: tsp-client update --debug
If you are emitting from a local TypeSpec folder, do not edit the file tsp-location.yaml. Run the command: tsp-client update --debug --local-spec-repo <local-folder-path>, where <local-folder-path> is the full path to the local TypeSpec folder ending with specification\ai-foundry\data-plane\Foundry\src\sdk-python-js-azure-ai-projects.
Note:
tsp-client update command. Do not use any of the other tsp-client commands.After the emit, there will be changes to pyproject.toml and MANIFEST.in that are not needed. Revert any changes to these files by running:
git restore pyproject.toml MANIFEST.in
Stage all changes (excluding file names that start with .env), commit, and push the topic branch:
git add -A -- ':!.env*'
git commit -m "Part 1: Emit SDK from TypeSpec"
Co-authored-by: Copilot <[email protected]>"
git push -u origin <topic-branch>
After a successful emit, run the PowerShell script named PostEmitter.ps1 located in the sdk/ai/azure-ai-projects folder.
This script applies azure-ai-projects specific corrections to the emitted code (restores pyproject.toml, fixes enum names, patches Sphinx doc-string issues, and runs black formatting).
If the script fails, stop and report the error to the user. Do not continue. Do not attempt to analyze the script failures and fix them with Copilot. The script should be fixed by the engineering team if it is not working.
Stage all changes (excluding file names that start with .env), commit, and push the topic branch:
git add -A -- ':!.env*'
git commit -m "Part 2: Apply post-emitter-fixes.cmd"
Co-authored-by: Copilot <[email protected]>"
git push -u origin <topic-branch>
The emitted code may have introduced another beta sub-client (a new property on class BetaOperations). It may have also added another enum value to the existing internal class _FoundryFeaturesOptInKeys. This means that the client library needs to set a new HTTP request header when making REST API calls to the service, to opt-in to the new service features which are still in preview. If that's the case, do the following:
_BETA_OPERATION_FEATURE_HEADERS defined in azure\ai\projects\models\_patch.py, to include a new key-value pair to map the new beta sub-client name to the proper value from _FoundryFeaturesOptInKeys. If no new beta sub-client was introduced, but a new enum value was added to _FoundryFeaturesOptInKeys, you will need to update one of the existing key-value pairs in _BETA_OPERATION_FEATURE_HEADERS to a comma-separated join of multiple values from _FoundryFeaturesOptInKeys.EXPECTED_FOUNDRY_FEATURES defined in the test file tests\foundry_features_header\foundry_features_header_test_base.py: add a new key-value pair if a new beta sub-client was introduced, or update an existing key-value pair to include the new enum value if no new beta sub-client was introduced.azure\ai\projects\operations\_patch.py and azure\ai\projects\aio\operations\_patch.py. They define the public BetaOperations classes for the sync and async clients. To support a new sub-client, you will need to add a new property to this class with the proper doc string. You will need to update the import statement at the top of the file to import the new sub-client class. And you will need to update __all__ statement at the bottom of the file to include the new sub-client class name. Follow the examples you see there for BetaDatasetsOperations or BetaSkillsOperations.If a new enum value was added to _AgentDefinitionOptInKeys, please print a note on screen that mentions which value was added, and tell the user that a review is needed to make sure this new value is properly used. But otherwise continue on.
Important: Under the azure\ai\projects folder, you are only allowed to edit Python source files that start with "_patch". If you see that changes are needed in other files, stop and report this to the user instead of making the changes yourself.
If there were any breaking changes in existing APIs, like class or method renames:
azure\ai\projects folder.sdk/ai/azure-ai-projects/samples folder.sdk/ai/azure-ai-projects/tests folder.In the folder sdk\ai\azure-ai-projects, run pip install -e . to install the package from sources. If there are any errors, stop and report the error to the user. Do not continue.
apiview-stub-generator to update api.md and api.metadata.yml filesIn the folder sdk\ai\azure-ai-projects, run the following command:
azpysdk apistub .
This will update the api.md and api.metadata.yml files under in local folder.
If it fails, stop and do not continue. If succeeded, do the following cleanup and continue to the next step:
rmdir /s /q build
Stage all changes (excluding file names that start with .env), commit, and push the topic branch:
git add -A -- ':!.env*'
git commit -m "Part 3: Additional edits"
Co-authored-by: Copilot <[email protected]>"
git push -u origin <topic-branch>
Create a draft PR from the topic branch to the base branch (recorded in Step 3):
gh pr create --draft --base <BASE_BRANCH> --head <topic-branch> --assignee @me --title "<PR title>" --body "<PR body>"
[azure-ai-projects] Emit SDK from TypeSpec (<short description>).You must show the user the resulting PR URL on screen when done, before you continue to the next step.
Open a new tab in the default operating system browser and navigate to the PR URL (do not use the built-in browser in VS Code, if running this skill in the VS Code GitHub CoPilot chat window).
Take azure/azure-ai-projects-emit-from-typespec from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip, npm.
Without those the skill loads but fails at the first command.