Skip to content

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 into
mainfrom
feature/1289-investigation-skills-claude-code-may-substitute-po
Oct 4, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/1289-investigation-skills-claude-code-may-substitute-po

Conversation

@admarble

@admarble admarble commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Claude Code replaces positional $N in 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 1249 turned substr($0, 2) into substr(1249, 2). With two arguments, $1 and $2 are 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.

  • §6c added-line extraction moved into qa/scripts/added-lines.sh.
  • Every other awk field (qa, loop, release, setup; all three mirrors) is written $(N).
  • New lint: 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-gates now 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/skills symlink, untemplated. On macOS, awk '{print \$2}' exits 2 with a syntax error, and behind || true that error is silent. That was QA's pause_for_human risk. $(N) avoids it:

  • Claude Code leaves $(0), $n and $NF untouched (verified with a scratch skill invoked as /zzsubst1289 1249 --phase qa).
  • awk evaluates $(N) identically to $N.
  • Run on the same input as the main form, the manual-AC attribution program gives the same output (AC-2 AC-3).

references/*.md and scripts/ 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

AC Status Evidence
AC-1 MET Reproduction recorded on #1289 with the Claude Code version (2.1.289)
AC-2 MET No positional $N remains in any SKILL.md mirror. lint:skill-argument-substitution passes, and fails on a reintroduced \$0 (/verify record on #1289). Gate test mutation-verified below
AC-3 N/A AC-1 reproduced, so the "refutes" branch does not apply

Mutation-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 passed
  • npm run lint:skill-argument-substitution: exit 0; exit 1 on a reintroduced \$0
  • npx tsx scripts/lint-skill-gates.ts: exit 0
  • npx tsx scripts/check-skill-sync.ts: 48 synced, 0 diverged
  • Rewritten awk programs run in macOS awk against sample input (attribution, numstat sum, verdict field, CLI command count)

Fixes #1289

🤖 Generated with Claude Code

…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
@admarble
admarble merged commit b42f378 into main Oct 4, 2026
11 checks passed
@admarble
admarble deleted the feature/1289-investigation-skills-claude-code-may-substitute-po branch October 4, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

investigation(skills): Claude Code may substitute positional $0 inside qa SKILL.md awk programs when /qa gets an argument

1 participant