Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build and deploy AI applications on Azure AI Foundry using Microsoft's model catalog and AI services
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
foundry-agent/create/references/skill-management.md
1# Skills (azd ai)23How to create, manage, and version **skills** (reusable behavioral guidelines) in a Foundry project using `azd ai skill` and the Python SDK.45A **skill** is a Markdown file with YAML front matter (`SKILL.md`), uploaded to a Foundry project, and attached to agents at runtime. Skills enable updating agent behavior **without code changes**.67> ๐ For attaching skills to a toolbox (`azd ai toolbox skill add/remove/list`) and the raw MCP protocol, see [skill-toolbox.md](skill-toolbox.md).8>9> ๐ For consuming skills in agent code (Agent Framework SDK integration, progressive disclosure, `load_skill`), see [use-skills-in-hosted-agent.md](use-skills-in-hosted-agent.md).1011## Install the extension1213```bash14azd extension install azure.ai.skills15```1617## Skill authoring format1819Each skill lives in its own directory with `SKILL.md` at the root:2021```22skills/23my-skill/24SKILL.md # YAML front matter + Markdown body25```2627```yaml28---29name: my-skill-name30description: What this skill does and when the agent should load it31---3233# My Skill3435Instructions the agent follows when this skill is loaded on demand...36```3738> **The `name` and `description` values must be unquoted** in YAML front matter โ quoting causes HTTP 500 on import.3940The `description` field drives skill discovery at runtime: the Agent Framework SDK uses it to decide when to load the skill. Write descriptions that clearly state **when** the agent should use the skill. See [use-skills-in-hosted-agent.md ยง How progressive disclosure works](use-skills-in-hosted-agent.md) for details.4142## CLI surface โ `azd ai skill`4344| Command | What it does |45|---------|--------------|46| `azd ai skill create <name> --file <path>` | Create skill + publish v1. Accepts SKILL.md, .zip, or directory. |47| `azd ai skill create <name> --description "..." --instructions "..."` | Inline create (no file). |48| `azd ai skill create <name> --file <path> --force` | Delete existing + recreate. Safe to re-run after edits. |49| `azd ai skill update <name> --file <path>` | New immutable version, promoted to default. |50| `azd ai skill update <name> --set-default-version <ver>` | Repoint default (rollback) without uploading new content. |51| `azd ai skill show <name>` | Show metadata (default_version, latest_version). |52| `azd ai skill list` | List skills in the project. |53| `azd ai skill download <name>` | Extract to `./.agents/skills/<name>/`. |54| `azd ai skill download <name> --version <ver>` | Download a specific version. |55| `azd ai skill download <name> --raw` | Write raw ZIP without extracting. |56| `azd ai skill delete <name> [--force]` | Delete skill. |5758Every mutation creates a new immutable version. `create` promotes v1 to default; `update` promotes the new version to default.5960Four mutually exclusive input modes for `create` and `update`:61621. **Directory:** `--file ./skills/my-skill/` (CLI packages as ZIP; requires `SKILL.md` at root)632. **SKILL.md:** `--file ./SKILL.md` (CLI parses YAML front matter + body)643. **ZIP:** `--file ./skill.zip` (uploaded as multipart/form-data)654. **Inline:** `--description "..." --instructions "..."` (no file)6667## Recipe: create a skill6869```bash70azd ai skill create support-style --file ./skills/support-style/71```7273## Recipe: batch provision (safe to re-run)7475```bash76for dir in skills/*/; do77name=$(basename "$dir")78azd ai skill create "$name" --file "$dir" --force79done80```8182## Recipe: update a skill8384```bash85# Edit SKILL.md locally, then:86azd ai skill update my-skill --file ./skills/my-skill/87```8889After update:90- Toolbox skill references (without pinned version) follow the new `default_version` โ live immediately, no toolbox republish needed.91- `SkillsProvider` downloads at agent startup โ redeploy agent to pick up the new version.9293## Recipe: rollback a skill version9495```bash96azd ai skill update my-skill --set-default-version 197```9899## Python SDK operations100101The SDK uses `AIProjectClient.beta.skills` (preview API surface, requires `allow_preview=True`).102103```python104import os105from azure.ai.projects.aio import AIProjectClient106from azure.identity.aio import DefaultAzureCredential107108async with (109DefaultAzureCredential() as credential,110AIProjectClient(111endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],112credential=credential,113allow_preview=True,114) as project,115):116# Create from package (in-memory ZIP)117imported = await project.beta.skills.create_from_package(zip_bytes)118119# List120async for skill in project.beta.skills.list():121print(f"{skill.name}: {skill.description}")122123# Download124stream = await project.beta.skills.download("my-skill")125zip_bytes = b"".join([chunk async for chunk in stream])126127# Delete128await project.beta.skills.delete("my-skill")129```130131Full provisioning script: [provision_skills.py](https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/provision_skills.py).132133## RBAC134135Skills require **Foundry User** on the Foundry project scope (for both the developer identity and the deployed agent's managed identity).136137## Versioning138139- Every `create` produces version 1 as the default.140- Every `update` creates a new immutable version and promotes it to default.141- `azd ai skill update <name> --set-default-version <ver>` repoints without uploading new content.142- Toolbox skill references without a pinned version follow the skill's `default_version`.143- Toolbox skill references with a pinned version (`skill@2`) stay on that version regardless.144- `SkillsProvider` downloads the `default_version` at agent startup.145146## Troubleshooting147148| Symptom | Likely cause | Fix |149|---------|------------|-----|150| HTTP 500 on skill create | Quoted `name` or `description` in YAML front matter | Remove quotes from front matter values |151| `403 Forbidden` | Missing RBAC | Grant **Foundry User** on the project scope |152| `azd ai skill` not recognized | Extension not installed | `azd extension install azure.ai.skills` |153| Skill attached but agent doesn't use it | Description too vague for progressive disclosure | Improve `description` in SKILL.md front matter |154| Agent still uses old skill content after `update` | Toolbox skill pinned to old version, or `SkillsProvider` caches at startup | Use consumer endpoint (no version pin), or redeploy agent |155| `create_from_package` fails | SDK client missing preview flag | `AIProjectClient(allow_preview=True)` |156