Polarity "NEVER use: uv run python test.py" vs. the same command marked correct with "NO EXCEPTIONS"Validation "Docs-only … none by default" vs. "Run tests after changes: Always run the project's test suite"Toolchain "Run with yarn test-e2e" vs. "make test-e2e" for the same browser suiteToolchain Backend testing uses xUnit vs. "Write backend tests using TUnit with [Test] attributes"
#!/usr/bin/env python3"""List what instruction files say about commands, versions and modal rules, side by side.Prints candidates for a human to read. It does not decide what is a conflict."""import re, sysfrom pathlib import PathTOOLS = r"(?:npm|npx|pnpm|yarn|bun|node|make|bash|python3?|uv|pip|poetry|pytest|tox|cargo|go|dotnet|mvn|gradle|\./gradlew|docker|ruff|eslint|prettier|tsc)" # extend for your stackCMD = re.compile(rf"^\s*(?:\$\s*)?({TOOLS}\b[^\n`]*)")INLINE = re.compile(r"`([^`\n]+)`")RUNTIME = re.compile(r"(?<![\w.])(node(?:\.js)?|python|go|java|ruby|rust|\.net)[ v]*(\d+(?:\.\d+)*)", re.I)FRAMEWORK = re.compile(r"\b(xunit|tunit|nunit|jest|vitest|mocha|pytest|unittest|playwright|cypress)\b", re.I)NEGATIVE = re.compile(r"\b(never|do not|don['’]t|avoid)\b", re.I)MODAL = re.compile(r"\b(never|always|must|do not|don['’]t)\b", re.I)TOPICS = ["e2e", "test", "lint", "format", "build", "dev", "install", "deploy", "migrat"]def facts(text): cmds, versions, modals = set(), set(), [] in_fence = False for n, line in enumerate(text.splitlines(), 1): if line.strip().startswith("```"): in_fence = not in_fence continue spans = [line] if in_fence else INLINE.findall(line) for s in spans: m = CMD.match(s) if m: clause = re.split(r"[;.]", line.split(s)[0])[-1] # text before the command, same clause neg = not in_fence and NEGATIVE.search(clause) cmds.add(m.group(1).strip() + (" (on a never/do-not line)" if neg else "")) for name, ver in RUNTIME.findall(line): versions.add(f"{name.lower()} {ver}") for name in FRAMEWORK.findall(line): versions.add(name.lower()) if not in_fence and MODAL.search(line): modals.append(f"{n}: {line.strip()}") return cmds, versions, modalsdef topic(cmd): return next((t for t in TOPICS if t in cmd.lower()), "other")files = [Path(p) for p in sys.argv[1:]]missing = [str(f) for f in files if not f.is_file()]if missing: print(f"not a file, skipped: {missing}")files = [f for f in files if f.is_file()]if len(files) < 2: print(f"only {len(files)} instruction file(s), nothing to compare") sys.exit(0)data = {f: facts(f.read_text(encoding="utf-8", errors="replace")) for f in files}print("== commands by topic (a topic with different commands is worth reading) ==")for t in TOPICS + ["other"]: per = {f: sorted(c for c in data[f][0] if topic(c) == t) for f in files} if sum(bool(v) for v in per.values()) < 2: continue flag = "DIFFERS" if len({tuple(v) for v in per.values() if v}) > 1 else "same" print(f"[{t}] {flag}") for f, v in per.items(): print(f" {f}: {v or '-'}")print("== tool and version mentions ==")for f in files: print(f" {f}: {sorted(data[f][1]) or '-'}")print("== modal lines (never/always/must/do not) ==")for f in files: for line in data[f][2]: print(f" {f}:{line}")
$ python3 scripts/instr_diff.py AGENTS.md CLAUDE.md== commands by topic (a topic with different commands is worth reading) ==[e2e] DIFFERS AGENTS.md: ['yarn test-e2e'] CLAUDE.md: ['make test-e2e'][test] DIFFERS AGENTS.md: ['uv run pytest -q'] CLAUDE.md: ['pytest -q', 'uv run pytest (on a never/do-not line)']== tool and version mentions == AGENTS.md: ['pytest', 'xunit'] CLAUDE.md: ['pytest', 'python 3.12', 'tunit']== modal lines (never/always/must/do not) == AGENTS.md:9: - Docs-only changes: do not run the test suite. CLAUDE.md:4: - NEVER use `uv run pytest`; activate the venv and call `pytest -q`. CLAUDE.md:7: - Run tests after changes: always run the project's test suite.
e2e のコマンド、禁止された uv run、xUnit 対 TUnit は差分として出ます。検証の矛盾は出ません。2 つの行はどちらも modal lines の下に出ますが、ドキュメントだけの変更での「do not run the test suite」と、あらゆる変更後の「always run」を突き合わせる処理はありません。2 行を一緒に読んで初めて気づきます。スクリプトが何も出さなかったからといって安心する前に、ほかの死角も知っておいてください。コマンドはバッククォートとコードブロックからしか読まないので、地の文で書かれたコマンドは見えません。1 つのファイルにしか出てこないテーマは表示されないため、CLAUDE.md の ruff format は一度も出てきません。入れ子のファイルは適用範囲に関係なくルートのファイルとまとめて扱われます。極性の印は、同じ節でコマンドの前にある語からの推測にすぎません。実際の長いファイルでは、modal lines のセクションが何十行にもなると考えてください。出力は「見るべき場所の一覧」として読み、そのうえで両方のファイルを全文読んでください。
AGENTS.md の yarn test-e2e と CLAUDE.md の make test-e2e が矛盾するのは、同じスイートを指していて、一方が他方を排除する場合だけです。Makefile のターゲットが yarn のスクリプトを呼んでいるなら、それは同じ操作の 2 通りの書き方で、どちらかに揃えるのは整理であって修正ではありません。適用範囲が違って見えても、重なっていることはあります。リポジトリ全体の「always run the tests」と、ドキュメントだけの変更での「do not run the tests」は、どちらもドキュメントの変更を対象にしていて、その作業では両立しません。論文にある元のペアの文言「none by default」はもっと緩く、エージェントはとにかくテストを走らせれば両方を満たせます。論文が 2 人の読み手と裁定を必要としたのは、まさにこうした行でした。このテストは、8 月に私が書いた 断片化と階層化 の区別を実務に落としたものです。2 つのファイルが同じ問いにそれぞれ答えていれば矛盾の候補で、範囲の異なる別々の問いに答えているならそうではありません。
keep shared policy in one canonical source, generate thin tool-specificadapters where formats permit, assign ownership for the remaining copies,and review all affected views in the same pull request.
#!/usr/bin/env bash# Advisory: lists what the instruction files say when a PR changes one. Never fails the build.# Needs bash 4.4+, GNU grep, full history (e.g. fetch-depth: 0) and BASE set to the target branch ref.PATTERN='(^|/)(AGENTS(\.override)?|CLAUDE|GEMINI)\.md$|(^|/)\.claude/rules/|(^|/)\.github/copilot-instructions\.md$|(^|/)\.github/instructions/.*\.instructions\.md$|(^|/)\.cursorrules$|(^|/)\.cursor/rules/'if [ -z "${BASE:-}" ] || ! git merge-base "$BASE" HEAD >/dev/null 2>&1; then echo "instruction-file check: no usable BASE ('${BASE:-}'), nothing inspected"; exit 0fiif ! diff=$(git -c core.quotePath=false diff --no-renames --name-only "$BASE"...HEAD); then echo "instruction-file check: git diff failed, nothing inspected"; exit 0fichanged=$(printf '%s\n' "$diff" | grep -iE "$PATTERN" || true)[ -z "$changed" ] && exit 0echo "Instruction files changed in this PR:"; echo "$changed"echo "Command candidates in the current instruction files:"mapfile -d '' files < <(git ls-files -z | grep -zE -i "$PATTERN" || true)python3 scripts/instr_diff.py "${files[@]}" || echo "instr_diff failed; read the files by hand"exit 0