Claude and Claude Code 2027Section 5 · lesson 1 of 4
1234section 5 lessons
Section 5. Skills, Custom Commands, Hooks, and Plugins

Claude Skills Architecture — Progressive Disclosure, Self-Improvement, and Verification via evals.md

≈ 13 minNeuroBober

When you open a new session in the terminal or web interface, the model doesn't yet know your pricing policies, copy-editing rules, or payment-debugging procedures. The intuitive solution—dumping ten detailed SOPs into CLAUDE.md or pasting them into every chat—backfires: tens of thousands of extra tokens sit in the context before your first prompt, and the model's attention gets diluted across rules irrelevant to the task at hand.

In this lesson, we look under the hood of Claude Skills and see how it packages recurring workflows into isolated folders built on the open Agent Skills standard. You'll learn how three-level progressive disclosure keeps startup overhead under 1% of the context window, why dumping a hundred downloaded skills breaks , how to restore order with /skill-doctor, and how to build a quality verification loop with evals.md and official evaluation tools.

The Agent Skills Standard: Anatomy of a Skill Folder and SKILL.md

A Skill isn't a long prompt saved in your notes—it's a self-contained folder housing the SOP for a single, narrow, recurring task. Developed by Anthropic and published as the open cross-platform specification agentskills.io, the exact same structure works across Claude Code, the Claude.ai web client, the Skills API, and compatible agent runtimes.

At the root of the folder, a SKILL.md file is required—it defines the skill's passport in YAML frontmatter and its step-by-step execution algorithm in Markdown. Alongside it, you can place optional subdirectories: scripts/ for executable Python or Bash code, references/ for price lists, brand guidelines, and API schemas, and assets/ for document templates.

When skill names collide, Claude Code enforces a strict priority hierarchy:

  1. Enterprise level — organization-wide policies in <managed-settings>/.claude/skills/<name>/SKILL.md, which override everything else.
  2. Personal level — your universal skills in ~/.claude/skills/<name>/SKILL.md, available across all projects on your machine.
  3. Project level — repository-specific SOPs in .claude/skills/<name>/SKILL.md, ideal for version-controlling in Git for the whole team.

Beyond these three tiers, the agent also picks up skills from nested subdirectories (<subdir>/.claude/skills/), external directories attached via --add-dir, installed plugins (under a /plugin-name:skill-name ), and the web-sync directory ~/.claude/skills/synced/. Earlier versions used .claude/commands/ for custom commands, but Anthropic has officially unified it with Skills: legacy Markdown files still work, yet new workflows should always live in .claude/skills/<name>/SKILL.md because the old format lacks nested file support and fields like name and paths.

Let's put together a working example—a project skill called sales-proposal that turns raw call notes into a commercial proposal strictly grounded in an up-to-date price list. We'll extract rates into references/pricelist.md and keep a compact instruction in .claude/skills/sales-proposal/SKILL.md:

---
name: sales-proposal
description: Builds a commercial proposal from call notes using the current price list. Trigger on requests to estimate a quote or draft a proposal.
allowed-tools: Read
---

# Drafting a Commercial Proposal
1. Extract the client's objective, requested services, and target timeline from the call notes.
2. Verify every rate strictly against `references/pricelist.md`.
3. Never invent discounts or line items outside the price list; if inputs are missing, stop and ask clarifying questions.
4. Structure the draft as: Objective, Estimate, Timeline, Next Step.

Pay close attention to the frontmatter and body details in this file. According to the Claude Code Skills documentation, the name field is capped at 64 characters (only lowercase Latin letters, digits, and hyphens are allowed—no XML tags or reserved words like claude or anthropic). The description field is written in the third person and acts as the entry filter: it is what the model reads to decide whether to open the folder for a given prompt.

In addition to name and description, Claude Code's YAML frontmatter supports powerful control flags. Setting disable-model-invocation: true forbids the model from triggering the skill on its own—an essential safeguard for high-impact operations with side effects like production deployments, which should only run via your explicit /deploy command. The opposite flag, user-invocable: false, hides the skill from the / menu while keeping it available as a background reference for the model.

If a task is heavy and shouldn't pollute the main chat history with intermediate searches, add context: fork to the frontmatter. Keep in mind this does not clone the ongoing conversation: Claude Code spawns an isolated subagent with a clean window that receives only the body of SKILL.md (and when paired with agent: Explore or agent: Plan, doesn't even load CLAUDE.md). Also note that an allowed-tools permission grant inside a skill applies for a single turn only and resets on the next user message, even though the SKILL.md text remains in the dialogue.

Inside the skill body, dynamic substitutions work out of the box: $ARGUMENTS (plus positional $ARGUMENTS[0] / $0 or named parameters from arguments), environment variables ${CLAUDE_SKILL_DIR}, ${CLAUDE_PROJECT_DIR}, ${CLAUDE_SESSION_ID}, ${CLAUDE_EFFORT}, and pre-prompt local command output injection via !`cmd`. However, if you plan to upload the same package to the Claude.ai web UI or the Skills API, watch out for compatibility constraints: the cross-platform validator package_skill.py allows only six frontmatter keys (name, description, license, compatibility, metadata, allowed-tools), so extended keys like argument-hint will fail validation there.

One more critical boundary concerns privacy: the Agent Skills feature on the platform is not covered by Zero Data Retention (ZDR), where the provider does not store request payloads on its servers. Never store passwords, private API tokens, or client PII inside SKILL.md or references/.

Three Levels of Progressive Disclosure and Post-Compaction Limits

Why doesn't a dozen well-designed skills overwhelm the model's memory? Under the hood, Claude Code uses progressive disclosure, structured like a filing cabinet: only thin index tabs sit on the desk, while heavy folders are opened only when a matching request arrives.

A skill's lifecycle in a session breaks down into three distinct tiers, each paying a different context-window cost.

Loading LevelWhat Enters ContextWhen It TriggersBudget & Hard Limits
1. Discovery name, description, and when_to_useAutomatically at session startUp to 1% of the context window total (skillListingBudgetFraction: 0.01); each skill's description string is truncated at 1,536 characters (skillListingMaxDescChars)
2. ActivationFull body of SKILL.mdOn manual /skill-name invocation or auto-invocation via the Skill toolKeep files under 500 lines; after auto-compaction, only the first 5,000 tokens of the skill are retained
3. ExecutionFiles from references/, assets/, and output of scripts/When explicitly referenced by steps in SKILL.mdReferences are read on demand, and script source code never enters context—the model sees only stdout

The diagram below illustrates how these three tiers keep startup listing overhead within 1% of the window and protect your conversation from overflow.

Three-tier progressive disclosure in Claude Skills: Level 1 Discovery (1% window budget), Level 2 Activation (SKILL.md up to 500 lines), and Level 3 Execution (references/, assets/, scripts/ without loading script code into context).

The startup budget for the skill catalog scales dynamically with the model's context window at 1% (fraction 0.01), which you can fine-tune via skillListingBudgetFraction in settings or the SLASH_COMMAND_TOOL_CHAR_BUDGET environment variable. If the combined descriptions exceed this ceiling, Claude Code doesn't crash—it silently drops the descriptions of your least-frequently used skills, leaving only their names, which quietly disables auto-triggering for them.

And once a configured skill actually activates during a long working session, a second hidden limit kicks in that you need to design around upfront.

The 5,000-Token Post-Compaction Threshold

When a conversation hits auto-compaction, Claude Code re-attaches the most recently invoked skills to the compressed context so the agent doesn't lose the workflow. However, only the first 5,000 tokens of each such skill are preserved within a shared 25,000-token post-compaction budget, prioritized by most recent invocation. Anything you bury at the bottom of a sprawling SKILL.md beyond that limit disappears after compaction—so always put hard invariants and prohibitions right at the top and keep the file under 500 lines.

This mechanic also explains the practical division of labor between prose and code. Whenever you need to reconcile totals, clean a table, or validate syntax with a regex, don't force the LLM to chew through it in the prompt—offload the logic to scripts/. The model spends zero tokens reading the script's source and receives only a short, verifiable execution result.

Fighting "Skill Bloat": /skill-doctor and skillOverrides

Every week, community bundles pop up with titles like "200 Ready-Made Skills for Claude Code." It's tempting to copy the entire archive into ~/.claude/skills/, expecting the agent to suddenly get smarter across every domain. In practice, the exact opposite happens: skill bloat sets in.

Casual write-ups sometimes describe this as "instantly loading 40,000 extra tokens at startup," but in modern Claude Code the failure mode is subtler and trickier. Because of the hard 1% ceiling on the description listing (skillListingBudgetFraction), a hundred third-party folders overflow the startup catalog, and the CLI starts truncating or stripping description fields from your rare yet critical work skills. At the same time, vague descriptions like "helps write clean code" create trigger collisions: on a routine request about a failing payment-gateway webhook, the agent pulls in generic better-python-dev and code-cleaner skills, dumping thousands of lines of irrelevant advice into the active window and crowding out your database schema.

Instead of pruning the directory blind, Claude Code (since v2.1.252) includes the built-in /skill-doctor diagnostic command (alongside /doctor prompt-audit since v2.1.283 for auditing total system prompt and instruction weight). Running /skill-doctor maps out your context spend:

  • shows how many characters and what percentage of the budget each installed skill consumes in the startup listing;
  • highlights "dead weight"—skills that have never been invoked across your session history;
  • flags overly long descriptions hitting the 1,536-character truncation cap or conflicting triggers.

You don't even need to delete rare quarterly folders from disk. In the /skills menu, you can press Space or define a skillOverrides map directly in your local project config .claude/settings.local.json:

{
  "skillOverrides": {
    "legacy-migration-audit": "user-invocable-only",
    "experimental-seo-writer": "name-only",
    "unused-boilerplate-pack": "off"
  }
}

This block cleanly manages the visibility of local and personal skills without editing the SKILL.md files themselves (note that skillOverrides does not apply to skills bundled inside plugins). "user-invocable-only" removes the skill's description from the model's auto-trigger radar while keeping manual /legacy-migration-audit invocation intact. "name-only" leaves only the short name in the listing, using almost zero startup budget, and "off" disables the skill completely until you switch it back to "on" and refresh via /reload-skills.

Good hygiene looks like this: in your personal ~/.claude/skills/ directory, keep only 4–5 compact, universal workflow skills (such as cross-reviewing code, summarizing the current thread, or searching docs), and keep all narrow domain SOPs—like billing debugging or deployments—strictly inside the repository's .claude/skills/. Before enabling any third-party SKILL.md, always read it top to bottom: security research shows that malicious skills rarely contain binary payloads—instead, they hide textual prompt injections that trick the agent into reading .env and exfiltrating keys.

Verifying and Self-Improving Skills via Isolated evals.md Tests

Writing SKILL.md is only half the job. Even a tidy instruction might produce a flawless answer in seven out of ten test runs and miss a critical requirement—or slip into stiff corporate prose—in the other three. To prevent a skill from regressing after edits, you attach an evaluation loop (evals) and a lessons-learned log.

In community practice, a simple, intuitive pattern uses a handful of files right inside the skill folder: examples.md (3–5 reference before/after pairs), evals.md (a checklist of binary assertions), and memory.md (a reverse-chronological log of failures and fixes). Be clear on the standard's boundary here: evals.md and memory.md are a user-land pattern for organizing a self-improving skill, not a built-in machine-readable CLI format.

Following Anthropic's guide to evaluating AI agents, this evaluation loop works in four steps:

  1. Capture a baseline (without-skill). Run a real task in a clean session with the skill disabled and save the resulting draft as your reference point.
  2. Enable the skill and run (with-skill). Execute the same task with SKILL.md active, verifying that the trigger fired automatically and the agent read the required files from references/.
  3. Evaluate in an isolated context. Never ask the same session to grade its own work—models are biased toward justifying their own choices. Open a fresh conversation (or a separate subagent) and score the output strictly on a binary Pass / Fail scale: LLMs reliably verify concrete facts ("yes/no") but wobble on subjective scores like "4 out of 5."
  4. Log the failure and update the SOP. If even one check returns Fail, trace the root cause, add an explicit rule to SKILL.md, record the post-mortem in memory.md, and re-run previous test cases so you don't break working scenarios.

For a daily copy-editor skill, a binary evals.md checklist looks crisp and unambiguous:

# Evaluation Criteria for copy-editor

1. [Binary] Output contains no invented figures, discounts, or facts outside the input notes. (Pass/Fail)
2. [Binary] The opening paragraph states the practical problem immediately with no filler intro. (Pass/Fail)
3. [Binary] Maintains a direct, professional second-person tone with zero clichés from `references/banned-words.txt`. (Pass/Fail)

There are no vague criteria like "good style" here: every item is verified unambiguously either by a deterministic script (regex, length check, linter) or by an independent judge model, with human spot-checks for high-stakes tasks.

Once you outgrow a manual evals.md checklist and want to automate , move to Anthropic's official tooling in the Agent Skills repository. The official skill-creator plugin (installed via /plugin install skill-creator@claude-plugins-official) stores test cases in evals/evals.json, automatically runs with-skill vs. without-skill pairs, generates grading.json and benchmark.json reports, and opens an interactive HTML viewer to compare outputs. And if you package skills inside a plugin, Claude Code (since v2.1.269) includes the native claude plugin eval runner: it uses its own evals/<case>/ directory layout (incompatible with evals.json), runs 3 trials with and without the skill by default, computes the quality delta Δ, verifies activation via the tool_used: Skill , and validates structure with claude plugin validate .claude/skills.

Separate Formats When Scaling Up

A custom evals.md is ideal for getting started fast and manually calibrating a single personal skill in a fresh session. As soon as you promote skills into a team plugin with automated CI checks, adopt the official evals/evals.json layout (for skill-creator) or evals/<case>/ (for the claude plugin eval CLI runner) upfront so you don't have to rewrite your test suite later.

To put this into practice right away, audit your current skills and assemble your first minimal standard-compliant package.

Apply This Right Now

  • Run /skill-doctor in your active project to see which skills consume your 1% startup budget and have never been triggered in recent sessions.
  • Switch rare or heavy third-party skills to "user-invocable-only" or "off" via skillOverrides in .claude/settings.local.json, leaving only narrow, active SOPs on autopilot.
  • Create .claude/skills/<your-task>/SKILL.md under 500 lines with a precise description trigger, extract reference data into references/, and place core prohibitions in the opening paragraphs (within 5,000 tokens).
  • Define 3–5 binary Pass/Fail assertions in evals.md (or build your first evals/evals.json case via skill-creator) and test the skill in a clean, isolated session.

HTML evaluation report from claude plugin eval showing with-plugin (WITH) vs. without-plugin (W/OUT) runs, quality delta Δ, and grader verdicts (Anthropic Claude Code Docs).

Sources · 6

Based on digests