Skip to content

fix(scripts): refuse CLAUDE.md promotion when a repo guards it by literal path - #1346

Closed
wongsuwarn wants to merge 1 commit into
kunchenguid:mainfrom
wongsuwarn:fm/ensure-agents-md-claude-guard
Closed

wongsuwarn wants to merge 1 commit into
kunchenguid:mainfrom
wongsuwarn:fm/ensure-agents-md-claude-guard

Conversation

@wongsuwarn

Copy link
Copy Markdown

Summary

  • fm-ensure-agents-md.sh promotes a bare CLAUDE.md into AGENTS.md (with a symlink left behind) whenever a project has only CLAUDE.md and no AGENTS.md yet.
  • If that project's own tracked automation hardcodes a --disallowedTools entry naming CLAUDE.md by literal path (to stop unattended agent turns from editing their own "constitution"), promotion silently defeats that protection: the real content moves to AGENTS.md, but the guard keeps matching only the now-empty CLAUDE.md symlink.
  • Found the hard way: caught and reverted by hand in a project after this exact regression happened.
  • This adds a narrow, scoped detector (has_disallowed_tools_guard_referencing_claude) that refuses promotion when a git-tracked file mentions both disallowedTools and CLAUDE.md together, with an actionable error explaining the fix (point the guard at AGENTS.md instead, or promote manually).
  • Deliberately narrow: this is a textual heuristic for the one confirmed pattern, not general guard-mechanism detection - a guard built from a variable, a separate config file, or a non-CLI enforcement path isn't caught. The header comment says so explicitly.

Test plan

  • bin/fm-lint.sh bin/fm-ensure-agents-md.sh tests/fm-ensure-agents-md.test.sh (ShellCheck 0.11.0, pinned)
  • bash tests/fm-ensure-agents-md.test.sh - 11/11 passing, including two new tests: one confirming refusal when a --disallowedTools guard names CLAUDE.md, one confirming an ordinary README/CONTRIBUTING mention of CLAUDE.md alone does not false-trip the heuristic

…eral path

A repo whose own automation runs unattended agent turns against itself can
hardcode a --disallowedTools entry naming CLAUDE.md to stop stray edits to
its own constitution. Promoting CLAUDE.md to AGENTS.md in that repo would
move the real content out while the guard kept matching only the now-empty
symlink, silently defeating the protection - caught and reverted by hand in
the brain vault (2026-07-30) after exactly this happened.

Detection is narrow and scoped to the one confirmed pattern: a git-tracked
file mentioning both disallowedTools and CLAUDE.md together. It is not
general guard-mechanism detection.
@wongsuwarn

Copy link
Copy Markdown
Author

Opened in error against kunchenguid/firstmate. This was meant for our own firstmate (wongsuwarn/firstmate), where the change already landed. Not an upstream contribution. Closing; can be reopened if needed.

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.

1 participant