Claude Code Skills: Architecture, SKILL.md Format, and Custom Workflows

Claude Code Skills: Architecture, SKILL.md Format, and Custom Workflows

Table of content

Claude Code skills are modular, filesystem-based directories that contain a required SKILL.md file alongside optional scripts, templates, or reference files to extend Claude’s capabilities on demand. Rather than loading every workflow instruction into the initial prompt, Claude Code skills load only a lightweight YAML description at session startup and pull in the full Markdown instruction body when a matching task is triggered.

This reference is written for software engineers, DevOps leads, and technical architects standardizing AI-assisted workflows across local repositories and enterprise environments. You will learn how the progressive disclosure architecture works, how to configure SKILL.md frontmatter and dynamic shell context, and how to secure skill execution across your repositories.

What are Claude Code skills and how do they work?

Claude Code skills are modular, filesystem-based directories containing a required SKILL.md file and optional scripts or reference templates that extend Claude’s capabilities on demand. If your team is new to the CLI environment, our complete guide to the Claude Code terminal assistant covers the foundational setup before you add custom extensions. Each skill directory packages YAML frontmatter and Markdown instructions inside SKILL.md, paired with any supporting bash scripts, code templates, or documentation files your workflow requires.

Anthropic develops and maintains this system as part of Claude Code, adhering to the agent skills open standard agentskills.io so that portable skills can run across multiple compatible AI coding tools. You can inspect the official Claude Code skills documentation to see how the runtime interprets these directories. In the public anthropics/skills GitHub repository, many example skills are licensed under Apache 2.0, while Anthropic’s document creation and editing skills (docx, pdf, pptx, and xlsx) are source-available rather than open source. As of November 2026, skills are available on Claude Free, Pro, Max, Ultra, Team, and Enterprise plans when code execution is enabled, as well as in Claude Code and via the Claude API.

To keep the context window lean during long coding sessions, skills use a three-level progressive disclosure architecture:

  1. Level 1 loads only the YAML frontmatter metadata (roughly 100 tokens per skill) into context when the session starts.
  2. Level 2 loads the SKILL.md instruction body (recommended to stay under 5k tokens and under 500 lines) only when the user or model triggers the skill.
  3. Level 3 accesses bundled reference files or executes supporting scripts via bash on demand, without loading the script source code into the model context.

How do Claude Code skills compare to CLAUDE.md, slash commands, hooks, and MCP?

While CLAUDE.md injects global rules into every request and custom slash commands have been merged directly into the skills system, skills load procedural instructions on demand alongside deterministic hooks and external MCP tools. Teams evaluating terminal agents, such as in our comparison of Claude Code vs Gemini CLI, often need to decide which extension mechanism fits a given engineering rule.

When evaluating Claude Code skills vs slash commands, there is no longer a functional split. Custom slash commands have been merged into skills: a file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create the /deploy command and work the same way, while existing .claude/commands/ files remain supported for backward compatibility.

When weighing Claude Code skills vs CLAUDE.md, the deciding factor is context consumption. CLAUDE.md loads its entire content into every session and request, so you should keep it under 200 lines and reserve it for project-wide rules. Skills load only their short descriptions at startup and fetch the full body on demand, making them suited for task-specific procedural workflows and reference documentation.

Model Context Protocol (MCP) servers and Hooks solve different problems altogether. MCP connects Claude to external services and tools, whereas Hooks deterministically run scripts or actions on lifecycle events like PreToolUse or PostToolUse with zero context cost unless they return output. Skills provide the procedural instructions and domain knowledge that tell Claude how to interpret data and apply those tools.

Criterion Claude Code skills CLAUDE.md Hooks MCP servers
Primary purpose Procedural instructions and domain knowledge Project-wide rules Deterministic script or action execution on lifecycle events Connecting Claude to external services and tools
Context loading behavior Progressive: ~100 tokens at startup; full body loaded on demand Full content loaded into every session and request Zero context cost unless returning output External tool connection
Trigger mechanism Automatic via description matching or explicit /skill-name command Automatic on every session and request Lifecycle events such as PreToolUse or PostToolUse Tool invocation by the model
Execution model Markdown instructions, optional subagent fork, and on-demand bash scripts Static prompt context Deterministic lifecycle scripts External service integration
Best-fit engineering use case Task-specific workflows, /deploy scripts, and reference docs Repository-wide coding standards and build commands Enforcing security restrictions or pre-execution checks Querying external APIs or databases
Recommended size limit Under 500 lines and under 5k tokens for SKILL.md body Under 200 lines Not applicable (executes outside context unless returning output) Not applicable

Where are SKILL.md files stored and how does priority resolution work?

Claude Code loads skills from enterprise settings, personal home directories, project folders, nested monorepo subdirectories, plugins, and synced claude.ai accounts, resolving naming conflicts in the order of Enterprise, Personal, and Project. You can organize skills across seven distinct sources depending on how broadly they should apply:

  • Enterprise managed settings for organization-wide workflows.
  • Personal directories at ~/.claude/skills/<skill-name>/SKILL.md for your individual machine.
  • Project directories at .claude/skills/<skill-name>/SKILL.md checked into version control.
  • Nested subdirectories at <subdir>/.claude/skills/ inside monorepos.
  • Additional directories passed at startup via the --add-dir flag or /add-dir command.
  • Plugin directories located at <plugin>/skills/.
  • Synced claude.ai account skills stored in ~/.claude/skills/synced/.

When two skills share the same name, Claude Code resolves the conflict using the priority order Enterprise > Personal > Project. In monorepos and subdirectories, skills placed inside a nested .claude/skills/ directory below your starting working directory do not load at session startup. Instead, Claude Code loads them dynamically the first time Claude reads or edits a file in that subdirectory.

Starting in Claude Code v2.1.273, terminal sessions signed in with a claude.ai account automatically sync enabled claude.ai skills into ~/.claude/skills/synced/ in the background. The client checks for updates roughly every 10 minutes while active and every 40 minutes while idle. Because of this mechanism, Claude Code reserves the folder and namespace names synced and anthropic-skills (such as /anthropic-skills:pdf) for skills downloaded from claude.ai, skipping any user-authored skill that uses those reserved names outside a plugin.

Out of the box, claude code bundled skills are also available as prompt-based workflows. These include /doctor, /code-review, /simplify, /batch, /debug, /loop, /run, /verify, /run-skill-generator, and /claude-api. If your team prefers not to expose built-in workflows, you can disable them using the disableBundledSkills setting. Starting in Claude Code v2.1.286, when a session starts with a project, personal, or enterprise skill named verify or simplify and includeGitInstructions is enabled, Claude Code’s built-in commit instructions direct Claude to run that skill automatically right before each commit, except for documentation or test changes.

How to structure the SKILL.md format and YAML frontmatter

A valid SKILL.md file starts with YAML frontmatter defining a lowercase, hyphenated name and a third-person description, followed by optional Claude Code execution fields and a Markdown instruction body. Adhering to the official skill authoring best practices ensures your claude code SKILL.md format parses cleanly across environments.

Per the Agent Skills specification, the two core frontmatter fields have strict validation rules:

  • name: Maximum length of 64 characters, restricted to lowercase letters, numbers, and hyphens. It cannot contain XML tags and cannot include the reserved words anthropic or claude.
  • description: Maximum length of 1,024 characters and cannot contain XML tags. It must be written in the third person for accurate discovery and should state both what the skill does and when Claude should use it.

Beyond the base standard, Claude Code supports specific frontmatter fields to control execution, permissions, and visibility: disable-model-invocation, user-invocable, argument-hint, allowed-tools, model, context, agent, and hooks.

Controlling how a skill is triggered requires choosing between disable-model-invocation and user-invocable. Using the claude code disable-model-invocation field (disable-model-invocation: true) prevents Claude from automatically loading the skill and removes its description from Claude’s context window completely. You should set this on workflows with side effects, such as /deploy, so they only run when explicitly invoked by a developer. Conversely, setting user-invocable: false hides the skill from the user’s slash command (/) menu while keeping its description in context, allowing Claude to load it automatically as background knowledge when relevant.

For resource-heavy tasks, you can configure a claude code context fork subagent. Adding context: fork and an optional agent: field (such as Explore, Plan, or general-purpose) to a skill’s frontmatter runs the skill inside an isolated subagent context rather than polluting the main conversation window.

---
name: release-audit
description: Audits staged changes and verifies release readiness when preparing a deployment or running /release-audit.
disable-model-invocation: true
argument-hint: "<target-branch>"
allowed-tools: Bash, Read
context: fork
agent: Explore
---

Review the repository state and verify release criteria.

How to build a custom Claude Code skill with dynamic context and arguments

You can build a custom skill by creating a named directory under .claude/skills/, writing a SKILL.md file with positional argument variables and inline shell commands, and testing invocation from the terminal. You can also bootstrap new skills interactively using the bundled /run-skill-generator command, which acts as a built-in claude code skill creator.

Follow this claude code custom skills tutorial to create a branch diff verifier that uses claude code dynamic context injection and string substitutions:

  1. Create a skill directory inside your project repository at .claude/skills/diff-audit/.
  2. Create the required SKILL.md file inside .claude/skills/diff-audit/SKILL.md.
  3. Define the YAML frontmatter with a valid name and third-person description, and add context: fork if you want the analysis isolated from your main chat history.
  4. Add string substitution variables to the Markdown body. Skills support $ARGUMENTS for all passed arguments, $ARGUMENTS[N] or $N (such as $0 and $1) for positional arguments, ${CLAUDE_SESSION_ID} for the current session ID, and ${CLAUDE_SKILL_DIR} for the skill directory’s absolute path.
  5. Inject live terminal output using the !`command` syntax (for example, !`git diff HEAD`). Claude Code executes the shell command before Claude sees the skill and replaces the placeholder inline with the command’s live output.
---
name: diff-audit
description: Analyzes uncommitted git diffs against a target module and checks for regressions when requested by the user.
disable-model-invocation: true
argument-hint: "<module-name> <strictness-level>"
context: fork
agent: general-purpose
---

Audit the current uncommitted changes for module `$0` using strictness level `$1`.
Full argument string: `$ARGUMENTS`
Session reference: `${CLAUDE_SESSION_ID}`

Run helper script from the skill folder if needed:
`${CLAUDE_SKILL_DIR}/scripts/check.sh`

Current uncommitted diff output:
!`git diff HEAD`

When you run /diff-audit auth high in the terminal, Claude Code substitutes $0 with auth, $1 with high, executes git diff HEAD on your machine, injects the stdout directly into the prompt, and dispatches the task to an isolated general-purpose subagent.

Common authoring pitfalls, context budgets, and security controls

Maintaining reliable and secure skills requires keeping reference links one level deep, staying within the character budget for skill descriptions, and enforcing strict tool deny rules.

When authoring multi-file skills, avoid deeply nesting reference files, such as having SKILL.md link to advanced.md which then links to details.md. Because Claude may use partial reads like head -100 on nested files, it can miss instructions buried multiple hops away. Anthropic recommends keeping all reference links one level deep from SKILL.md and adding a table of contents to any reference file over 100 lines.

Installing too many active skills can also break automatic discovery. When a user has many skills installed and the combined skill listing exceeds its character budget (by default 1% of the model’s context window, adjustable with the skillListingBudgetFraction setting), Claude Code truncates or drops skill descriptions starting with the least-invoked skills. Once a description is dropped from Level 1 loading, Claude cannot auto-trigger that skill.

From a security standpoint, execution environments differ sharply between the API and the terminal. Unlike skills on the Claude API, which run in a sandboxed container with no network access and no runtime package installation, skills running in Claude Code have full network access identical to any program on the user’s computer. The allowed-tools frontmatter field only pre-approves listed tools so Claude can run them without prompting while the skill is active. It does not block unlisted tools; administrators and users must configure permission deny rules or PreToolUse hooks to enforce hard security restrictions.

Because malicious skills can direct Claude to misuse tools, execute arbitrary code, or exfiltrate sensitive data, you should audit all bundled files (SKILL.md, scripts, and external URL fetches) before enabling third-party directories. For larger teams, Claude Enterprise organizations can also turn on skill content scanning. Finally, keep compliance boundaries in mind: as of November 2026, Agent Skills are not covered by Zero Data Retention (ZDR) arrangements, and skill definitions and execution data are retained according to Anthropic’s standard data retention policy.

Frequently asked questions

Below are direct answers to common engineering questions about configuring, troubleshooting, and securing Claude Code skills.

Are slash commands and skills the same thing in Claude Code?

Yes, custom slash commands have been merged into skills in Claude Code. A command file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both register the /deploy command and behave the same way, and existing .claude/commands/ files remain supported.

How do I stop Claude Code from automatically triggering a skill with side effects?

Set disable-model-invocation: true in the YAML frontmatter of your SKILL.md file. This setting removes the skill’s description from Claude’s context window completely and prevents automatic loading, ensuring workflows with side effects (like /deploy) only execute when a user explicitly invokes them.

Why is my Claude Code skill not triggering automatically?

Automatic triggering usually fails for one of three reasons: disable-model-invocation: true is set in the frontmatter, the description field is vague or not written in the third person stating what the skill does and when to use it, or your installed skills have exceeded the skill listing character budget (1% of the context window by default), causing Claude Code to drop the descriptions of least-invoked skills.

Are Claude Code skills compatible with other AI coding agents?

Yes, base skills follow the open Agent Skills specification published at agentskills.io, allowing portable skills to work across multiple compatible AI tools. However, Claude Code extends the specification with specific frontmatter fields such as disable-model-invocation, user-invocable, argument-hint, allowed-tools, model, context, agent, and hooks that may only apply within Claude Code.

Does the allowed-tools setting block Claude from using other tools?

No, the allowed-tools frontmatter field only pre-approves the listed tools so Claude can run them without prompting while the skill is active. It does not block unlisted tools; to block tool execution, you must configure permission deny rules or PreToolUse hooks.

Are Claude Code skills covered by Zero Data Retention (ZDR)?

No, as of November 2026, Agent Skills are not covered by Zero Data Retention (ZDR) arrangements. Skill definitions and execution data are retained according to Anthropic’s standard data retention policy.

Custom AI agent workflows and enterprise engineering

Standardizing AI coding assistants across an engineering organization requires pairing procedural SKILL.md workflows with deterministic lifecycle hooks, audited scripts, and external MCP integrations. If your team is building internal developer tooling, automating multi-repo checks, or integrating LLM agents into existing software architectures, explore our custom AI development services to see how we help engineering teams design and secure production AI workflows.

Related case study

AI-Driven Logistics Software for Cargo Operations in Norway
Logistics and Transportation
A custom AI-driven logistics platform for a Norwegian cargo carrier, delivered on a fixed-price model and built around real-world daily workflows.

Related articles

Claude API Pricing Explained: Token Rates and Cost Guide
This guide breaks down Claude API pricing across all model tiers, prompt caching, batch processing, server-side tools, and Python SDK spend controls.
Cursor vs Claude Code: Which AI Coding Tool Fits Your Workflow?
Compare Cursor vs Claude Code across architecture, multi-file refactoring, project rules, pricing models, and how to run both in one workflow.
Prompt Caching: Mechanics, Pricing, and Architecture
Learn how prompt caching reuses KV attention tensors, how OpenAI, Anthropic, and Google price cache reads, and how to prevent silent cache misses.
AI Development Services

Have a project in mind?

AI assistants, agents and workflow automation, built around your data, goals and business logic.