I hid a secret in my Claude Code skill's script. Claude never read it

2026-12-05来源 dev.toEnglish

My release-notes skill had grown to 263 lines. After one experiment with a planted passphrase, the main file is 9.

Every time a skill misbehaved, I added a line. "Also check this." "Never do that." "Here is the format, in full." A few months later my release-notes skill was 263 lines long, with a chunk of Python pasted right in the middle.

It still worked. Mostly. But every time it ran, Claude had to read all 263 lines, including the parts that only matter once a month. And the longer it got, the more often it skipped a step I cared about.

Then I went back to the official docs and noticed something I had skimmed past: a skill is a folder. The main file is only the entry point. Everything else is supposed to live next to it and be loaded only when needed.

So I ran an experiment to see how literally Claude takes that. I hid a passphrase inside one of the skill's scripts and waited to see if Claude would ever repeat it. It never did, and that one result changed how I write every skill.

Short on time? The walkthrough below is free. If you'd rather skip the setup, I packaged it as a ready-to-use skill: skill-folderize on Gumroad.

Claude reads a skill in three stages, and stops early

Anthropic calls this progressive disclosure. There are three stages.

Stage 1: the description. At startup, Claude only sees each skill's name and description. That's how it decides whether to use the skill at all.

Stage 2: the main file. When the skill is triggered, Claude reads the body of the main file.

Stage 3: everything else. Reference files and scripts in the folder are touched only if the main file points to them, and only when the situation calls for it. Scripts are executed, not read. Only their output enters the context.

That last part is the interesting one. If a script is executed but never read, its code costs you nothing.

I planted a passphrase to check

I built a tiny test skill with three parts:

  • A short main file with the steps
  • A guide.md reference file, linked with a condition: "read this only when the input has headings"
  • A count.sh script that counts characters and headings in a file

Inside count.sh, I planted a comment: a random phrase about a purple penguin. If Claude ever read the script, that phrase would be in its context, and I could ask about it.

Then I ran the skill on a plain text file. Claude ran count.sh and got back two numbers: 94 characters, 2 headings. The penguin phrase never appeared anywhere in what Claude saw. And guide.md was opened only when I gave it input that matched the condition.

So the script's code never entered the context. Only its one-line output did. And the reference stayed closed until it was actually needed.

That changed how I think about skills. The main file is the part you pay for every time. Everything else can be as long as it needs to be, for free, as long as it's in the right place.

Sort every paragraph: processing, reference, or steps

Once you see it that way, rebuilding a skill becomes a sorting job. For every paragraph, ask these questions in order, and stop at the first yes.

1. Is it processing? Move it to scripts/. Input and output are fixed, and the result is the same every time. Counting, formatting JSON, converting to a fixed template, mechanically checking a list of rules.

A code block longer than 30 lines sitting in your main file is almost always this. Claude doesn't need to understand it. It only needs the result.

2. Is it reference? Move it to references/. Knowledge you don't need every time, but do need in specific situations. API details, a table of fixes per error, detailed style rules, templates, past examples.

One topic per file, and link it from the main file together with the condition: "When the release includes breaking changes, read references/breaking.md."

3. Everything else is steps. It stays. Things done every single time, or that require judgment. The order of work, when to check with the user, what not to do, what "done" looks like.

When I can't decide, I ask: "If I deleted this paragraph, would every run get worse?" If yes, it's a step. If no, it's reference.

Two things that bit me

The Claude Code docs line up with the sorting rule.

  • Keep the main file under 500 lines. Move detailed material to separate files
  • Keep references one level deep. Link them from the main file, not from each other
  • The description must say when to use the skill. In Claude Code's skill list, the description is cut off at 1,536 characters

The description rule was the first thing that bit me. My old description said what the skill did, but not when to use it, so Claude sometimes ignored it entirely.

The second one: when I asked Claude to do the split for me, it did a decent job, with one problem. It rewrote every script call with the absolute path on my machine.

It works on my Mac. It breaks on anyone else's, and it breaks on mine the moment I move the folder.

The fix is the variable Claude Code provides: ${CLAUDE_SKILL_DIR} always points to the skill's own folder. Script calls should look like this, in the body and in allowed-tools:

allowed-tools: Bash(${CLAUDE_SKILL_DIR}/scripts/count.sh *) Run ${CLAUDE_SKILL_DIR}/scripts/count.sh <file> (no need to read it) 

Now I tell Claude explicitly: copy this pattern, never expand the variable.

From 263 lines to 9

I applied the sorting rule to the 263-line release-notes skill. The main file is now 9 lines of steps. Next to it sit two reference files, each linked with when to read it, and one script for the formatting that used to be a pasted Python snippet.

Then I checked it against the rules above (length, description, links, paths, script permissions): 0 errors, 0 warnings. And Claude now reads 9 lines on every run instead of 263.

What I'd keep from all this:

  • A skill is a folder. Claude reads the description, then the main file, then only what it needs
  • Scripts are executed, not read, so their code is free. My planted passphrase never showed up
  • Sort every paragraph into steps (stay), reference (references/) or processing (scripts/)
  • Use ${CLAUDE_SKILL_DIR}, never absolute paths, and say when to use the skill in the description

If you have a skill that keeps growing, it probably doesn't need fewer words. It needs a folder.

Over to you: how long is your longest skill or instruction file right now? Drop the line count in the comments. I suspect mine wasn't the worst.

Want Claude to do the sorting for you?

Thanks for reading this far! If you're itching to shrink your own skills, I turned this whole process into a skill.

The rule above is simple, but doing it by hand means a lot of small checks: is the description saying when to use it, are any links broken, did a path get hardcoded, are the scripts executable, does any reference link to another reference. The skill handles all of it, and it checks its own work before it tells you it's done.

  • Measures your skill first: body length, description length, long code blocks, absolute paths, broken links, unlinked files
  • Sorts every paragraph into steps, reference or processing, and shows you the plan before changing anything
  • Backs up the original, then rebuilds the folder with ${CLAUDE_SKILL_DIR} paths and executable scripts
  • Re-checks until there are zero errors, then reports line counts before and after
  • Also works on a long prompt from your CLAUDE.md that you want to turn into a skill

If your skills are all under 50 lines and you never paste code into them, you don't need it.

👉 Get the skill: https://pastereadyengineer.gumroad.com/l/skill-folderize

📦 skill-folderize is also part of the Claude Code Workflow Kit: 5 Claude Code skills (claude-org, scout, local-worker, skill-folderize, split-commits) for $29 instead of $45.

🧰 Want all of them? The Claude Code Complete Kit has all 26 skills I tested for $59 instead of $234.

🎁 New here? Start with my free skill: mcp-key-check finds the API keys your MCP setup left in plain text and prints the commands to fix them. Pay what you want, $0 is fine.

If this was useful, a ❤️ and a follow would mean a lot. I write about practical ways to put AI to work in indie development.

原文:https://www.a8q9.cn/en/article/i-hid-a-secret-in-my-claude-code-skill-s-script-claude-never-read-it-7d2719.html

相关文章