Repository navigation
fix(#1289): investigation(skills): Claude Code may substitute positional $0 inside qa SKILL.md awk programs when /qa gets an argument - #1303
Merged
admarble merged 3 commits intoOct 4, 2026
Conversation
…stitutes Escape \$N in qa/loop/setup/release, move qa added-line extraction to a script, add lint:skill-argument-substitution. Entire-Checkpoint: d4e5884f2e3b
… still parse them Claude Code strips the backslash from \$N, but the codex and opencode drivers read the same skill files through .agents/skills untemplated, and awk rejects \$0 with a syntax error. $(N) survives Claude Code substitution (verified on 2.1.289 with two arguments) and runs unchanged in awk. The lint now rejects the escaped form too; CHANGELOG entry added. Claude-Session: https://claude.ai/code/session_01WsNvBL3sW5Uhvw1TSg62FX
This was referenced Oct 4, 2026
…ation-skills-claude-code-may-substitute-po
admarble
deleted the
feature/1289-investigation-skills-claude-code-may-substitute-po
branch
October 4, 2026 22:10
This was referenced Oct 4, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Claude Code replaces positional
$Nin a skill's text when the skill is invoked with arguments, and fenced code blocks are not exempt. This was reproduced on 2.1.289 (see #1289):/qa 1249turnedsubstr($0, 2)intosubstr(1249, 2). With two arguments,$1and$2are replaced too. This PR rewrites every positional awk field in the shipped skills so none reach the model as$N, and adds a CI lint that rejects them.qa/scripts/added-lines.sh.qa,loop,release,setup; all three mirrors) is written$(N).npm run lint:skill-argument-substitution, wired into CI. It scans SKILL.md in every mirror root and rejects$N, bare or escaped.lint-skill-gatesnow parses the manual-AC awk program in its$(0)form.Why
$(N)and not\$N(runner fix after QA)Exec's first pass escaped the fields as
\$N. Claude Code strips the backslash, but the codex and opencode drivers read the same files through the.agents/skills -> ../.claude/skillssymlink, untemplated. On macOS,awk '{print \$2}'exits 2 with a syntax error, and behind|| truethat error is silent. That was QA'spause_for_humanrisk.$(N)avoids it:$(0),$nand$NFuntouched (verified with a scratch skill invoked as/zzsubst1289 1249 --phase qa).$(N)identically to$N.mainform, the manual-AC attribution program gives the same output (AC-2 AC-3).references/*.mdandscripts/are not scanned. Claude Code templates only the skill body it injects; references and scripts reach the model through Read or Bash, as file contents.AC verification
$Nremains in any SKILL.md mirror.lint:skill-argument-substitutionpasses, and fails on a reintroduced\$0(/verifyrecord on #1289). Gate test mutation-verified belowMutation-verified: AC-2 — POSITIONAL_RE changed to require nine digits after the dollar sign (never matches); scripts/lint-skill-argument-substitution.test.ts > lint-skill-argument-substitution > flags a bare $0 inside a fenced awk program failed (with the escape and every-root cases); restored.
Test plan
npx vitest run scripts/lint-skill-argument-substitution.test.ts scripts/lint-skill-gates.test.ts: 46 passednpm run lint:skill-argument-substitution: exit 0; exit 1 on a reintroduced\$0npx tsx scripts/lint-skill-gates.ts: exit 0npx tsx scripts/check-skill-sync.ts: 48 synced, 0 divergedFixes #1289
🤖 Generated with Claude Code