跪拜 Guibai
← Back to the summary

Agent Skills Fail at Five Stages: A Marker Test for Claude Code's Skill Pipeline

Agent Skills are stuck at 5 breakpoints

A normal prompt LOADPROBE: say hi sent, the local mock receives 96,871 characters: it has oversize-test's name and description, but not the BEGIN_MARKER_LOADPROBE from the body.

Switching to /oversize-test say hi, the request grows to 108,008 characters, and both the start and end markers of the body appear; REFERENCE_MARKER_SHOULD_NOT_LOAD in references/note.md and SCRIPT_MARKER_SHOULD_NOT_LOAD in scripts/probe.py still do not appear in either request.

A 10,832-character, 152-line SKILL.md is read in, but a 2-line references and a 1-line script are not. After installing a Skill, it still needs five steps to actually participate in the work: discovery, trigger, retrieval, execution, verification. If any segment breaks, the Agent will appear "as if it didn't use the Skill".

Tests were done on Windows 11 with Claude Code 2.1.177, the mock interface at 127.0.0.1:18082, and requests written to requests.jsonl.

Phenomenon: the same Skill, two kinds of requests

The test Skill is called oversize-test. SKILL.md contains two unique markers: BEGIN_MARKER_LOADPROBE at the start, TAIL_MARKER_LOADPROBE at the end, padded with repetitive descriptions to reach 10,832 characters. The directory also contains references/note.md and scripts/probe.py, each with a marker belonging only to that file.

The normal request is 96,871 characters. The skill list has oversize-test - ..., with only the name and description; all body markers are False. The request's tools field includes the Skill tool, but there is no Skill call in the messages. The mock model only returns text and does not proactively trigger the skill.

After explicit invocation, the request is 108,008 characters. The start and end markers of the body both become True, with a difference of 11,137 characters. SKILL.md itself is 10,832 characters, and the extra 305 characters are the cost of JSON escaping and message wrapping.

The reference and script markers remain False. They do not automatically enter the request just because the body was read in.

Here's a clarification: 96,871 and 108,008 are the character counts of the entire request JSON, not token counts. Character counts can indicate how much text was added in a call, but cannot be directly converted to context usage. I didn't separately measure SKILL.md's token count, and I won't put token estimates in the body.

Figure 1 | Local mock's two request records: normal prompt 96,871 characters, body markers all False; explicit call 108,008 characters, body start and end True, references and scripts still False.

Old approach: treating SKILL.md as a bundle of prompts

My initial approach to writing a Skill was naive: stuff all steps, examples, and edge cases into SKILL.md, and add a line at the end saying "see references for details". Install it into ~/.claude/skills/ (on Windows %USERPROFILE%\.claude\skills\), and once the name appears in the list, the task is considered connected.

This approach works for short Skills. When a Skill is invoked, the body enters context, and the model follows along. The problem is that it treats "having read the body" as "having read the whole bundle".

Anthropic's Agent Skills documentation splits a Skill into three layers. At startup, only the name and description of each Skill are loaded; after triggering, the SKILL.md body is read; references are read only after the body references them; scripts are run via Bash, and only their output enters context. The layers are not a packaging term; they determine which content is visible at what moment.

Claude Code's skills documentation also gives a number: when auto-compressing, each Skill keeps only the first 5,000 tokens of its last invocation, with 25,000 tokens shared across multiple Skills; Skills invoked earlier may lose their entire content. The longer SKILL.md is, the earlier its tail leaves context.

Another number is on the skill list. The list is allocated a budget of 1% of the context window, and if exceeded, descriptions are dropped starting from the least-used Skill; a single description plus when_to_use has a 1,536-character cap. The more Skills installed, the less description the model has to match against.

Cramming everything into one file compresses the three layers into one. Short sessions won't reveal the problem; once Skills multiply and sessions lengthen, discovery and triggering fail first, not the model's capability.

Mechanism: a five-stage chain, where does it break?

Decompose a Skill's active participation into five stages, each with an observable exit.

  1. Discovery. The skill list enters context; only then does the model know this Skill exists. The list has only names and descriptions, and descriptions can be cut by budget. The exit is the Skills line in /context, or the skill list in the request. If the name is not in the list, the model has no chance to match.
  2. Trigger. The model calls the Skill tool, or the user enters /skill-name. In a normal request, there is only a description and no body; that's this stage not happening. The exit is whether the request contains a Skill call, or whether an explicit command gets expanded.
  3. Retrieval. The SKILL.md body enters context. The exit is a unique marker in the body. My two requests diverge here: False and True.
  4. Execution. The model reads references according to paths in the body, or runs scripts via Bash. References only enter context when read; scripts' code does not enter context, only their stdout/stderr and exit codes come back. The exit is the reference marker, script output, and exit code.
  5. Verification. If the Skill claims it modified files, ran checks, generated reports, there must be artifacts. The exit is file diffs, report paths, CI results. The model replying "done" is not an exit.

These five stages are not a theoretical classification. My probes cover only part of the first four: discovery looks at the skill list in the request, trigger looks at the difference between normal and explicit commands, retrieval looks at the body marker, execution looks at reference/script markers. The actual running of scripts and artifact verification were not fault-injected; they remain untested.

The boundary of the third stage is the easiest to overlook. The body entering context does not mean references enter. The official docs are clear: references are read on demand after being referenced in the body; if the model doesn't read them, the file stays on disk, costing zero, and yielding zero. Same for scripts: the code doesn't enter context; the model has to decide to run it.

The fourth stage also has a often-skipped prerequisite: paths. The Skill directory is on disk; relative paths for references, script cwd, Python dependencies, line endings across Windows and Linux: any of these can be wrong, and the script may fail after the Skill was "invoked". The failure output returns to context, but the Skill body won't fix paths for you.

Figure 2 | Five-stage chain and two tested breakpoints: without triggering, the body doesn't enter; after triggering, references and scripts may still not enter; the later two stages can only be verified via tool calls and artifact acceptance.

Two explanations: didn't enter context, or entered but didn't follow

When a Skill seems ineffective, don't blame the model first. At least two candidate explanations exist.

Candidate A: The body did not enter context. Causes might be: skill not in the list, description truncated, model didn't trigger, explicit command not expanded, or compression dropped the tail. The observable signal is whether the body marker appears in the request. The normal request of 96,871 characters lacks it; the explicit call of 108,008 has it. This set rules out A for the explicit entry point.

Candidate B: The body entered context, but the model did not continue to read references or execute scripts. The observable signal is the reference marker, script marker, and tool call records. In my two requests, the body marker went from False to True, while the reference and script markers stayed False. This supports B in part: the body is there, the extension didn't happen.

The existing evidence cannot distinguish between "the model read the body but chose not to read the reference" versus "the model never realized the reference exists". One would need to see whether it issued Read/Bash calls and what paths those calls point to. The request body can only prove whether text is present, not why the model chose as it did.

This also explains why asking the model to "recite the steps in the Skill" sometimes gets correct answers. Recitation only proves the body is in context; it doesn't prove that subsequent files were executed. To verify extension, one needs the unique marker from the reference to appear in the result, or look at the tool call records.

Fix: install an observable exit for each stage

Treat a Skill as a call chain for acceptance. First, add three markers. Write BODY_MARKER=BODY_7F3A in the first line of SKILL.md; write REFERENCE_MARKER=REF_91C2 in references/check.md; put a directly runnable check in scripts/check.py:

from pathlib import Path

print("SCRIPT_MARKER=SCRIPT_4D8E")
print(Path.cwd())

Then do a smoke test. Explicitly call /your-skill, and ask the model to return only the markers it actually read, without guessing. The expected results come in three tiers:

If you stop at the first tier, fix the reference position in the body first. Put "read references/check.md and return REFERENCE_MARKER" at the beginning of SKILL.md, not after 10,000 characters. Compression keeps only the first 5,000 tokens; putting key instructions at the tail means putting them in the part that gets dropped.

If the second tier passes but the third fails, check the script path and cwd. Having the script print its own marker and Path.cwd() is easier to locate than writing "please run the script" in the body. The script's exit code must be visible to the outside; don't swallow it with except: pass.

There are also three structural rules. Keep SKILL.md under 500 lines, move details to references; references should be a single-level index, not A references B, B references C: each additional hop increases the chance the model "doesn't read". Scripts handle deterministic actions; the body handles judgment; don't mix the two in one large file.

The last step is to verify artifacts. If the Skill says it changed a config, look at git diff; if it generated a report, check the file exists and its beginning matches expectations; if it ran checks, look at the exit code and output. The model's self-claim "Skill used" has no evidentiary value.

Do a destruction test: remove the three marker tests. The Skill can still read the body, but references not read, scripts not run, artifacts unchanged: all three failure modes collapse back into "the model didn't follow instructions". Keeping the three exits at least lets you know which stage broke.

Boundaries: this test only covers one entry point

The environment for this experiment: Windows 11 Home 10.0.26300, Claude Code 2.1.177, Python 3.13.18, and a local mock model that does not call paid APIs. It demonstrates what text the client puts into the request under two entry points; it does not prove that a real model would auto-trigger, nor that a real model would follow the body after reading it.

Only one Skill, one explicit entry point, and one call were tested. No multi-Skill competition for budget, no difference before and after auto-compression, no script failure under wrong cwd, missing dependencies, or insufficient permissions, and no quality of execution after reading references.

The official documentation's 5,000 / 25,000 tokens, 1% list budget, and 1,536-character description cap come from the docs, not from my measured compression results. SKILL.md's 10,832 is a character count, not token count; whether it's under the 5,000-token budget depends on tokenization. I didn't mix these two measurements.

This set of checks is suitable for deciding whether a segment "happened", not for scoring the quality of the Skill's content. When there is a single Skill, short session, explicit call, and a very short body, the first segments often pass together; with multiple Skills, long sessions, and auto-matching, the number of breakpoints increases.

Migration: run these five steps when switching projects

When moving to your own project, the order stays the same; paths and commands change.

  1. Discovery: run /context or /doctor, check if the target Skill is in the list, and whether the description got truncated. If the list only has the name, first add keywords to the description.
  2. Trigger: run /skill-name explicitly once, confirm the body marker appears; then run a normal prompt and see if the model calls Skill on its own. Record both results separately.
  3. Retrieval: put a unique marker in references and ask the model to return it after reading. If it can't return it, either the extension didn't happen or the reference path is wrong.
  4. Execution: manually run the script in the Skill directory, recording cwd, exit code, and stdout. If it doesn't run manually, don't expect it to run when the model invokes it.
  5. Verification: check artifacts, not claims. For file changes, look at diff; for reports, look at path and content; for checks, look at exit code.

After completing these steps, you'll have a pass/fail table for five stages. The first False position is where to fix.

The next time you call a Skill, first look at what extra text the request carried, then look at what changed in artifacts. If neither appears, don't believe "it's been used".