Every AI "skill pack" I publish goes through a gate: build it, run its selftest, scan a real codebase, then upload. Last week I pointed the gate back at itself and audited all 82 packages that ship a runnable entry point in my skill directory.
Three of them graded an empty folder as perfectly clean. One gave 100/100 to a path that does not exist.
What I was auditing
100 packages in one folder, 93 with a SKILL.md, 50 with an evaluation_cases.md (the newer standard — the older packs predate it). Most are "doctor"-style static scanners: money/float precision, timeout defaults, cache correctness, secret leaks, subprocess injection, path traversal. 82 of them ship a Python script under scripts/.
I ran three probes against all 82.
Probe 1: can a generic harness even start the selftest?
65 packs mention selftest, but they don't agree on how to invoke it:
-
43 accept it as a positional subcommand:
tool.py selftest -
18 only accept a flag:
tool.py --selftest - 4 mention the word but neither form works under my harness
A harness that greps for one convention sees 43 out of 65 — it under-detects 34% of the packs that actually have a working selftest. That's not a tool bug, it's an interface bug: a capability with two names is a capability you cannot rely on programmatically.
Of the 61 I could dispatch, 60 exit 0. The one that doesn't, path-traversal-doctor, exits 1 with selftest: 55/56 — FAILED: PAT001. That's a real regression in a pack I already published, found only because the harness ran it instead of trusting the README.
Probe 2: zero input
Empty directory, no files, exit codes across 82 packs:
exit 2 : 42 (argparse usage error / unknown subcommand)
exit 1 : 20
exit 3 : 16 (a dedicated "no input" code)
exit 0 : 3 (printed a clean-looking report)
exit 4 : 1
The three exit-0 cases are the whole point:
code-review-assistant 审查范围: 0 个文件 → 健康分: 100/100 — ✅ 可以合并
security-audit-helper 扫描文件数: 0 | 命中数: 0 → [✓] 未发现敏感信息泄露
secret-leak-guard total 0.00s over 0 files
"0 files scanned" is not a result. It is the absence of a result, formatted to look like one. If a CI job, an agent, or a human reads only the verdict line, all three say "all clear" about nothing at all.
Probe 3: the path doesn't exist
exit 0 and clean language: 5 / 82
code-review-assistant on a nonexistent path: 跳过不存在的路径 → 0 files → 100/100, ready to merge, exit 0. A typo and a spotless codebase are indistinguishable from the outside.
One more, unprompted: official-doc-writer with no arguments at all wrote a 37,335-byte .docx to the Desktop and exited 0. Zero input produced a file side effect. In a "scan every pack in a loop" harness, that's an accidental write to the user's home directory.
The gate I now use
Four rules, all of them learnable from the three probes:
- "No input" gets its own exit code (3), distinct from "findings present" and from "you typed the command wrong".
- Exit 0 is not a verdict. Green requires evidence: an independent walk must find more than zero candidate files, and the tool's own reported count must equal that independent count.
- Compare numbers, not prose. A human-readable summary is not an interface.
-
One exit-code enum per tool, documented in
--help. Todaymoney-doctoruses0/2/3/4(clean/findings/no-input/selftest-failed) while 42 other packs use2for argparse misuse andsilent-failure-doctoruses2for "findings present". The same code means "bad command line" and "your code has bugs" depending on which pack you're holding.
CODE_EXT = {".py", ".js", ".ts", ".java", ".go", ".rb", ".php", ".rs", ".c", ".cpp", ".cs"}
def count_candidates(path):
"""Our own count. Never the tool's number."""
if not os.path.isdir(path):
return None # nonexistent path is its own failure
n = 0
for root, dirs, files in os.walk(path):
dirs[:] = [d for d in dirs if d not in {".git", "__pycache__", "node_modules", ".venv"}]
n += sum(1 for f in files if os.path.splitext(f)[1] in CODE_EXT)
return n
def gate(tool, path):
expect = count_candidates(path)
p = subprocess.run([sys.executable, tool, path], cwd=os.path.dirname(tool),
capture_output=True, text=True, timeout=180)
claim = claimed_count(p.stdout + p.stderr) # from --json, not from prose
if expect is None: return "FAIL_NONEXISTENT_PATH"
if expect == 0: return "NO_EVIDENCE" if p.returncode == 0 else "NO_INPUT_REFUSED"
if p.returncode != 0: return "RED"
if claim is None or claim != expect: return "NO_EVIDENCE_COUNT_MISMATCH"
return "GREEN"
The distinction that matters: NO_EVIDENCE is neither pass nor fail. It means the run cannot be used as a grade, and it must not be allowed to turn green just because a process exited 0.
The gate had two bugs, of course
First run, 10 out of 10 cases: ERR bufsize must be an integer. subprocess.run(cmd, root) passes root into the bufsize slot, not into cwd. I wrote a gate for positional-argument failures and then made one with a positional argument.
Second run, three false verdicts:
-
money-doctorprints扫描: 18 文件 / 5629 行. My regex required个文件, so a perfectly good tool was flagged as "reports no count". -
security-audit-helperreported扫描文件数: 0on a directory with 18 Python files. My gate calls that a mismatch; it's probably legitimate extension filtering — it scans config and credential files, not.py.
Both are the article's own thesis happening to me: a gate that parses prose produces false verdicts, and an independent counter must use the tool's declared extension scope or it becomes a false-alarm machine. After fixing the regex and scoping the counter, 5 tools × 2 corpora (empty dir, and requests with 18 files):
code-review-assistant empty → NO_EVIDENCE real → GREEN (18 = 18)
secret-leak-guard empty → NO_EVIDENCE real → GREEN (18 = 18)
security-audit-helper empty → NO_EVIDENCE real → COUNT_MISMATCH (scope)
silent-failure-doctor empty → NO_INPUT(3) real → RED by gate, but exit 2 = findings
money-doctor empty → NO_INPUT(3) real → GREEN (18 = 18)
What transfers to your own agent tools
- "No input" ≠ "clean input". Give it a distinct exit code and a distinct word in the output. Most of the bugs above are one line away from fixed.
- A tool may not grade its own homework. The count that decides green has to come from outside the tool — otherwise a counter is a claim, not a measurement.
-
Selftest invocation is an interface. Accept both
selftestand--selftest, or your first automated consumer will under-count you and never tell you. -
Exit codes are an API. Two packs using
2for two different meanings will page you at 3 a.m. for a typo. -
Zero-arg behavior is part of the interface. Mine wrote a
.docxto the Desktop.
Total cost of finding all of this: one 80-line audit script and about four minutes of wall clock. The empty-folder probe alone — tool.py $(mktemp -d) and look at the verdict line — catches the entire "ok means never ran" family in 30 seconds.
I've since added exit 3 and a machine-readable files_scanned to the packs I touched, and the release script refuses to publish when selftest exits non-zero (that's how path-traversal-doctor's 55/56 stayed out of the next batch).
The doctor family and the audit gate live in my GitHub repo: Felixwang007/awesome-content-tools — the tools/ folder has the scripts and the write-ups behind each rule. Individual packs (money-doctor, cache-doctor, timeout-doctor, silent-failure-doctor, and the rest) are published on 虾评 at xiaping.coze.com if you want to run one against your own repo before adopting the habit.
If you ship tools that an agent will call in a loop, run the empty-folder test first. The failure mode isn't a crash — it's a green check mark on a run that never happened.
Top comments (0)