Posted by Claude (AI assistant) on behalf of @jmchilton — not authored by them personally.
foundry-build cast <mold> --check is a read-only drift gate, but it creates the bundle directory as a side effect. On a Mold that has never been cast, this leaves an empty casts/claude/skills/<mold>/ behind.
Cause
packages/build-cli/src/commands/cast-mold.ts:1266 — mkdirSync(bundleRoot, { recursive: true }) runs unconditionally in runCastMoldCommand, before anything branches on args.check.
Reproduction
$ rm -rf casts/claude/skills/validate-cwl
$ test -d casts/claude/skills/validate-cwl && echo YES || echo NO
NO
$ npx tsx packages/build-cli/src/bin/foundry-build.ts cast --root . validate-cwl --check
drift: SKILL.md — SKILL.md missing
drift: _verify.json — verify manifest missing
check failed: 0 error(s), 2 drift(s)
$ test -d casts/claude/skills/validate-cwl && echo YES || echo NO
YES # empty
Why it bites
tests/plugin-packaging.test.ts (keeps non-skill artifacts outside the discovered skills directory) enumerates real directories under casts/claude/skills/ and asserts each has a SKILL.md. Git doesn't track empty directories, so these are invisible to git status — the failure looks like it came from nowhere.
Running a repo-wide drift scan is the natural way to answer "what's stale?":
for f in content/molds/*/index.md; do
m=$(basename $(dirname "$f"))
npx tsx packages/build-cli/src/bin/foundry-build.ts cast --root . "$m" --check
done
That currently creates one empty dir per uncast Mold (14 at the moment — the CWL and paper Molds, repair-galaxy-draft-topology, paper-to-test-data) and breaks an unrelated test until they're cleaned with find casts/claude/skills -type d -empty -delete.
Suggested fix
Skip the mkdirSync when args.check is set, or defer it to the first actual write. A --check run that finds drift should report it without touching the tree.
Worth a regression test: --check against a never-cast Mold should leave no directory behind.
Context
Found while closing out #322 residue (#359).
foundry-build cast <mold> --checkis a read-only drift gate, but it creates the bundle directory as a side effect. On a Mold that has never been cast, this leaves an emptycasts/claude/skills/<mold>/behind.Cause
packages/build-cli/src/commands/cast-mold.ts:1266—mkdirSync(bundleRoot, { recursive: true })runs unconditionally inrunCastMoldCommand, before anything branches onargs.check.Reproduction
Why it bites
tests/plugin-packaging.test.ts(keeps non-skill artifacts outside the discovered skills directory) enumerates real directories undercasts/claude/skills/and asserts each has aSKILL.md. Git doesn't track empty directories, so these are invisible togit status— the failure looks like it came from nowhere.Running a repo-wide drift scan is the natural way to answer "what's stale?":
That currently creates one empty dir per uncast Mold (14 at the moment — the CWL and paper Molds,
repair-galaxy-draft-topology,paper-to-test-data) and breaks an unrelated test until they're cleaned withfind casts/claude/skills -type d -empty -delete.Suggested fix
Skip the
mkdirSyncwhenargs.checkis set, or defer it to the first actual write. A--checkrun that finds drift should report it without touching the tree.Worth a regression test:
--checkagainst a never-cast Mold should leave no directory behind.Context
Found while closing out #322 residue (#359).