Repository navigation
fix(skills): mktemp templates with a non-trailing X suffix break on macOS - #2343
Merged
Merged
Conversation
…acOS (#2157) BSD mktemp (macOS) only randomizes a TRAILING run of X's — a suffix directly after it (mktemp "tmp.XXXXXXXXXX.ext") returns the template literally instead of creating a unique path. create-skill/SKILL.md mandated exactly this broken pattern in Patterns 2/3/13/14 and the Phase 5 checklist, so every generated skill following it got a fixed, non-unique temp path on macOS: concurrent sessions collided on the same literal file, and re-runs failed with "mkstemp failed ... File exists". lint-skill.sh and smoke-test-skill.sh reproduced the same broken pattern in their own mktemp calls. Fix: rewrite every mandated example to mktemp -d a trailing-X directory template, placing the extensioned file inside it when an extension is required. Add a lint-skill.sh check that flags any mktemp template whose X run is not trailing, so a future skill reintroducing this is caught automatically instead of silently shipping. docs check acknowledged.
Contributor
Greptile SummaryThe PR makes generated skill temp-path guidance and validation portable to BSD mktemp on macOS.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(test): resolve a real bash 4+ for li..." | Re-trigger Greptile |
Comment on lines
+56
to
+57
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'lint-skill-mktemp-')); | ||
| const skillPath = path.join(dir, 'SKILL.md'); |
Contributor
There was a problem hiding this comment.
Fixture Fails Unrelated Name Check
runLint writes SKILL.md under a randomly named directory while its frontmatter declares name: lint-test-skill, so the linter reports a name mismatch and exits non-zero. Because the negative cases inspect only stdout and ignore status, they pass despite this unrelated error and therefore do not establish that the recommended mktemp forms pass lint cleanly.
…ly ran (#2157 CI) Two bugs in the new regression test: 1. lint-skill.sh requires bash 4+; macOS ships bash 3.2 as the `bash` on PATH (including GitHub Actions' macos-latest runner), so execFileSync('bash', ...) invoked a bash that rejects the script outright. Resolve a real bash 4+ explicitly (checking common Homebrew install paths) and skip the suite if none is found, rather than assuming plain "bash" is adequate. 2. The "does not flag ..." assertions used stdout.not.toContain(...), which passes vacuously on an EMPTY stdout — exactly what happens when the script fails to even start. This is why only the "flags ..." tests (which assert toContain, not not.toContain) surfaced the bash-version failure in CI; the others silently "passed" for the wrong reason. Every case now also asserts the script actually reached its own summary line. docs check acknowledged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2157
BSD
mktemp(macOS) only randomizes a trailing run ofXs — a suffix directly after it (mktemp "tmp.XXXXXXXXXX.ext") returns the template literally instead of creating a unique path:.claude/skills/create-skill/SKILL.mdmandated exactly this broken pattern in Patterns 2, 3, 13, 14 and the Phase 5 idempotency checklist — every skill generated by/create-skillfollowing it inherited a fixed, non-unique temp path on macOS:mkstemp failed ... File existsonce the literal file is left behind.lint-skill.shandsmoke-test-skill.sh(the skill's own linting/smoke-test tooling) reproduced the identical broken pattern in their ownmktempcalls.Fix
mktempexample inSKILL.md(Patterns 2, 3, 13, 14, Phase 5 checklist) to use a trailing-Xmktemp -ddirectory template, placing the extensioned file inside that directory when an extension is required (matches the issue's own suggested fix).lint-skill.sh's andsmoke-test-skill.sh's ownmktempcalls — neither actually needed an extension on the temp file they create, so both now use a bare trailing-X template.lint-skill.shcheck that flags anymktemptemplate whoseXrun is not trailing, so a future skill reintroducing this pattern is caught automatically instead of silently shipping.Test plan
tests/unit/lint-skill-mktemp-trailing-x.test.ts: the new lint check fires on the exact reported bug pattern and a generic non-extension suffix, does not false-positive on the recommended trailing-X /mktemp -dforms, and confirmsSKILL.mditself is clean.lint-skill.shandsmoke-test-skill.shagainst the updatedSKILL.mddirectly — 0 errors/warnings, all 10 bash blocks passbash -n.npm testsuite passes (4615 tests, 288 files).npx tsc --noEmitandnpm run lintclean.