Official agent skill

Code Snippets

by MicrosoftDocs in MicrosoftDocs/semantic-kernel-docs

How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes.

OfficialMITAuto-check passedAI & LLM Engineering

Install Code Snippets

skills CLI
$ npx skills add MicrosoftDocs/semantic-kernel-docs --skill code-snippets -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install MicrosoftDocs/semantic-kernel-docs code-snippets --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/MicrosoftDocs/semantic-kernel-docs.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/code-snippets .claude/skills/code-snippets && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-snippets
GitHub stars
264
Token cost
~1.4k tokens
SKILL.md length
468 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
MIT

At a glance

How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes.

  • Works in 3 steps: The sample repo structure is stable… → The sample file has proper snippet tags → You want to eliminate inline code…
  • Tasks that involve Building AI agents
  • SKILL.md covers Purpose, :::code Directive Syntax, Out-of-repo snippet references and Snippet Tags in Source Files, plus 4 more sections
  • Calls python; reaches github.com

What it does

Code Snippets is an agent skill from MicrosoftDocs/semantic-kernel-docs, published by the product's own GitHub organization. How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Building AI agents. It works with Python. The repository describes itself as: Semantic Kernel (SK) is a lightweight SDK enabling integration of AI Large Language Models (LLMs) with conventional programming languages. The licence is MIT.

When your agent uses it

  • Tasks that involve Building AI agents

Example prompts

  • “/code-snippets”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. The sample repo structure is stable (samples merged to main)
  2. The sample file has proper snippet tags
  3. You want to eliminate inline code duplication

What it can do on your machine

Read from SKILL.md and the folder at commit 6997e10. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com

    Also links to:

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Snippets loads about 1.4k tokens when it runs. Until then it costs about 41 tokens; SKILL.md has 468 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~41
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from MicrosoftDocs/semantic-kernel-docs at commit 6997e10, republished under its MIT licence (© MicrosoftDocs). 468 words, ~1,434 tokens.

Download SKILL.mdSave it as .claude/skills/code-snippets/SKILL.md (or your agent's skills folder).
name
code-snippets
description
How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes.

Skill: Code Snippets in Docs

Purpose

This skill describes how to reference code from sample repos in Agent Framework docs pages, eliminating inline code duplication.

:::code Directive Syntax

markdown
:::code language="python" source="~/../agent-framework-code/python/samples/01-get-started/01_hello_agent.py" id="create_agent" highlight="1-4":::
Parameters
ParameterRequiredDescription
languageYes"python" or "csharp"
sourceYesSnippet file path using docset-relative syntax (for example ~/... or ~/../<dependent-repo>/...)
idNoMatches a snippet tag in source (# <name> / # </name> for Python, // <name> / // </name> for C#)
rangeNoLine range (e.g. "2-24,26"). Cannot coexist with id
highlightNoLines to highlight, relative to the displayed snippet (not the file)
Source Path Conventions
  • In-repo snippets: ~/agent-framework/<path-to-file>
  • Out-of-repo snippets (dependent repositories): ~/../<path_to_root>/<path-to-file>
  • Agent Framework code samples in this repo: ~/../agent-framework-code/python/samples/<section>/<file>.py

Out-of-repo snippet references

If the code file you want to reference is in a different repository, set up that code repository as a dependent repository in .openpublishing.publish.config.json. The path_to_root you assign acts like a folder name for snippet source paths.

Dependent repositories metadata

The dependent_repositories list is required in .openpublishing.publish.config.json for cross-repository references (CRR):

json
{
  "dependent_repositories": [
    {
      "path_to_root": "<relative path to repository root>",
      "url": "<referenced repository url>",
      "branch": "<branch name of referenced repository>",
      "branch_mapping": {
        "<source repository branch>": "<referenced repository branch>",
        "<source repository branch>": "<referenced repository branch>"
      }
    },
    {
      "path_to_root": "token",
      "url": "https://github.com/Microsoft/token",
      "branch": "main",
      "branch_mapping": {
        "main": "main",
        "develop": "test"
      }
    }
  ]
}
MetadataMeaningRequired
dependent_repositoriesThe CRR relationship list nameYes
path_to_rootRelative folder path to the repository root (folder can be virtual)Yes
urlURL of the reference repository this repo depends onYes
branchDefault branch of the reference repository for buildsYes
branch_mappingOptional source-branch to reference-branch mapNo
Snippet reference syntax

Use the same :::code syntax for CRR snippets as in-repo snippets. Only the source path changes.

  • Start paths with ~ for docset-root-relative references.
  • Use .. segments to move up directories when needed (for example ../../).
  • Prefer readable paths; deeply nested .. chains are harder to maintain.

Example CRR source path:

~/../xamarin-forms-samples/WebServices/TodoREST/TodoAPI/TodoAPI/Startup.cs

[!NOTE] The dependent repository alias is rooted at repo root, but ~ is rooted at the docset's build_source_folder. In this repo, Agent Framework docs use "build_source_folder": "agent-framework", so dependent repositories are referenced like ~/../agent-framework-code/....

[!IMPORTANT] Updating an external code snippet does not automatically trigger a content build. Trigger a build by changing doc content or starting a build manually.

Show full SKILL.md (148 more words)Show less

Snippet Tags in Source Files

Python
python
# <create_agent>
client = OpenAIResponsesClient(...)
agent = client.as_agent(name="...", instructions="...")
# </create_agent>
C#
csharp
// <create_agent>
var agent = await client.CreateAIAgentAsync(...);
// </create_agent>
Rules
  • Tag names use snake_case
  • Tags must be unique within a file
  • Tags cannot overlap or nest
  • Keep snippet regions small and focused (5-20 lines ideal)
  • Include all necessary imports within the snippet OR document them separately

Zone Pivots

Every page showing code for both languages uses zone pivots:

markdown
:::zone pivot="programming-language-csharp"
:::code language="csharp" source="~/../agent-framework-code/dotnet/samples/..." id="...":::
:::zone-end

:::zone pivot="programming-language-python"
:::code language="python" source="~/../agent-framework-code/python/samples/..." id="...":::
:::zone-end

When to Apply This Skill

Apply :::code references when:

  1. The sample repo structure is stable (samples merged to main)
  2. The sample file has proper snippet tags
  3. You want to eliminate inline code duplication

Until then, use inline code blocks (python / csharp) as a temporary measure.

Common Snippet IDs

IDPurposeTypical file
create_agentAgent instantiation01_hello_agent.py
run_agentNon-streaming run01_hello_agent.py
run_agent_streamingStreaming run01_hello_agent.py
define_toolTool definition02_add_tools.py
create_agent_with_toolsAgent + tools02_add_tools.py
multi_turnThread-based conversation03_multi_turn.py
context_providerMemory/context setup04_memory.py
create_workflowWorkflow builder05_first_workflow.py

Reference

© MicrosoftDocs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/code-snippets of MicrosoftDocs/semantic-kernel-docs.

Open the folder on GitHubat commit 6997e10

Compare with similar skills

Code Snippets next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Snippets compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Snippets this skillMicrosoftDocs/semantic-kernel-docs264—~1.4kAutomated safety check: PassMIT
Azure AI Projects Python SDKmicrosoft/skills3.1k6 repos~2.8kAutomated safety check: PassMIT
Senior Prompt Engineermaslennikov-ig/claude-code-orchestrator-kit2594 repos~1.4kAutomated safety check: PassCustom licence
Google Agents CLI Adk Codepifferologo/cloud-agents-cli1291 repos~768Automated safety check: PassApache-2.0
DSPy Language Model ProgrammingOrchestra-Research/AI-Research-SKILLs13k10 repos~3.8kAutomated safety check: PassMIT
E2b Code Interpreteragent-sandbox/agent-sandbox218—~2.3kAutomated safety check: PassApache-2.0

Similar skills

  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Senior Prompt Engineer

    maslennikov-ig/claude-code-orchestrator-kit

    Provides reference guides and Python scripts for prompt optimization, RAG evaluation, and agent orchestration when building or tuning LLM systems.

    259 GitHub starsUsed in 4 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Google Agents CLI Adk Code

    pifferologo/cloud-agents-cli

    This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management", or needs ADK (Agent…

    129 GitHub starsUsed in 1 repo~768 tokens
    AI & LLM EngineeringAuto-check passed
  • DSPy Language Model Programming

    Orchestra-Research/AI-Research-SKILLs

    Teaches an agent to build LM pipelines, RAG systems and agents in DSPy using signatures, modules and optimizers instead of hand-tuned prompts.

    13k GitHub starsUsed in 10 repos~3.8k tokens
    AI & LLM EngineeringAuto-check passed
  • E2b Code Interpreter

    agent-sandbox/agent-sandbox

    Execute code in E2B sandboxes and integrate with LLMs for tool calling.

    218 GitHub stars~2.3k tokensUpdated 17 days ago
    AI & LLM EngineeringAuto-check passed
  • Run Eval

    hidai25/eval-view

    Run EvalView regression checks against golden baselines to detect regressions in AI agent behavior after code, prompt, or model changes.

    137 GitHub stars~557 tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed

More from MicrosoftDocs/semantic-kernel-docs

  • Breadcrumbs

    MicrosoftDocs/semantic-kernel-docs

    Official

    How breadcrumbs work on Microsoft Learn: structure, creation, configuration in docfx.json, and best practices for documentation repos.

    264 GitHub stars~1.7k tokensUpdated 5 days ago
    Auto-check passed
  • Cross Repository References

    MicrosoftDocs/semantic-kernel-docs

    Official

    How to configure cross-repository references (CRR) and create API class links for Microsoft Learn docs in this repository.

    264 GitHub stars~1k tokensUpdated 5 days ago
    Auto-check passed
  • Redirection

    MicrosoftDocs/semantic-kernel-docs

    Official

    How to delete, rename, or move articles on Microsoft Learn while preserving Platform IDs, preventing broken links, and managing redirects.

    264 GitHub stars~1.5k tokensUpdated 5 days ago
    Auto-check passed
  • Sample Structure

    MicrosoftDocs/semantic-kernel-docs

    Official

    Conceptual organization of Agent Framework documentation and samples.

    264 GitHub stars~1.4k tokensUpdated 5 days ago
    Auto-check passed
  • Toc

    MicrosoftDocs/semantic-kernel-docs

    Official

    How to create, structure, and configure table of contents (TOC) files for Microsoft Learn documentation using toc.yml and docfx.json.

    264 GitHub stars~2.2k tokensUpdated 5 days ago
    Auto-check passed
  • Per Concept Documentation

    MicrosoftDocs/semantic-kernel-docs

    Official

    Required when reviewing, updating, auditing, or creating any concept documentation page.

    264 GitHub stars~1k tokensUpdated 5 days ago
    Auto-check passed

Works with

Questions about Code Snippets

What does Code Snippets do?

How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes. Code Snippets is an agent skill from MicrosoftDocs/semantic-kernel-docs, published by the product's own GitHub organization. How to reference code from sample repos in Agent Framework docs pages using :::code directives, snippet tags, zone pivots, and highlight attributes.

When should I use Code Snippets?

Code Snippets fits situations like: tasks that involve Building AI agents.

How do I install Code Snippets in Claude Code?

Run `npx skills add MicrosoftDocs/semantic-kernel-docs --skill code-snippets -a claude-code`. Or copy the skill folder (.github/skills/code-snippets in MicrosoftDocs/semantic-kernel-docs) into .claude/skills/code-snippets in your project. Claude Code loads it when a task matches its description.

How do I install Code Snippets in Codex?

Run `npx skills add MicrosoftDocs/semantic-kernel-docs --skill code-snippets -a codex`. Or copy the skill folder (.github/skills/code-snippets in MicrosoftDocs/semantic-kernel-docs) into .agents/skills/code-snippets in your project. Codex loads it when a task matches its description.

Can I use Code Snippets in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add MicrosoftDocs/semantic-kernel-docs --skill code-snippets -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-snippets, .gemini/skills/code-snippets, .github/skills/code-snippets and .opencode/skills/code-snippets in your project.

What does Code Snippets need to run?

Going by SKILL.md and its folder, Code Snippets needs the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Code Snippets access the network?

SKILL.md names 2 domains. In commands or code: github.com; the agent is likely to contact it when it follows the instructions. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.

Is Code Snippets safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Code Snippets use?

Code Snippets is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Snippets use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Code Snippets?

Skills that share tags, products or a category with Code Snippets: Azure AI Projects Python SDK (microsoft/skills, 3.1k stars), Senior Prompt Engineer (maslennikov-ig/claude-code-orchestrator-kit, 259 stars), Google Agents CLI Adk Code (pifferologo/cloud-agents-cli, 129 stars) and DSPy Language Model Programming (Orchestra-Research/AI-Research-SKILLs, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Snippets?

MicrosoftDocs (a GitHub organization, an official publisher) maintains it in MicrosoftDocs/semantic-kernel-docs, which has 264 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 2, 2026.

Source: MicrosoftDocs/semantic-kernel-docs on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.