pilot-shell icon indicating copy to clipboard operation
pilot-shell copied to clipboard

Stop hook's ai-rulez sync check can never pass when CLAUDE.md and AGENTS.md are both legitimately generated with different content

Open ianrios opened this issue 2 months ago • 2 comments

The Stop hook (repo_agent_sync.py) runs skills/setup-rules/scripts/sync-agent-assets.mjs --check, which blocks session completion with: refusing to overwrite nontrivial CLAUDE.md; AGENTS.md and CLAUDE.md both contain instructions.

This fires even when there is nothing to reconcile. In a repo using ai-rulez, both CLAUDE.md and AGENTS.md are ai-rulez-generated targets (each carries a 🤖 AI-RULEZ :: GENERATED FILE — DO NOT EDIT DIRECTLY banner on line 1), both are committed, and git status is clean. The only content difference is correct: CLAUDE.md uses ai-rulez's @.ai-rulez/context/... import syntax, while AGENTS.md inlines the same text, because AGENTS.md has no import syntax to use. sync-agent-assets.mjs's isTrivialClaude check only accepts CLAUDE.md being empty or exactly @AGENTS.md — so a legitimately-generated pair with different (but equivalent) content always trips it, and the hook blocks every session Stop in that repo.

Its own --write recovery flag would make this worse: it would overwrite a committed, generated, multi-hundred-line file, immediately reverted by the next ai-rulez run, and would show up as a spurious modification for every other user of the repo.

Requested fix: teach the check to recognize a target it can detect as tool-generated (the banner is on line 1) and skip the trivial-CLAUDE.md requirement for it, rather than assuming any CLAUDE.md/AGENTS.md content difference means an unreconciled manual edit.

Impact: any repo that lets ai-rulez (or a similar generator) emit both files with legitimately different content can never satisfy this Stop hook check — not degraded, just permanently blocked, across every session in that repo.

ianrios avatar Sep 08 '26 18:09 ianrios

Follow-up with the missing attribution: the generator this issue describes is Goldziher/ai-rulez, a separate open-source project (not part of pilot-shell, and not affiliated with it) that generates config files for 19+ AI tools from one source.

Verified against ai-rulez's own docs, since the original issue's claim was asserted rather than sourced: CLAUDE.md comes from ai-rulez's claude preset, AGENTS.md from its codex preset (targeting OpenAI Codex). The two presets legitimately produce different formats for the same underlying rules — Codex's AGENTS.md format has no equivalent to Claude Code's @file import directive, so a repo using both presets correctly ends up with CLAUDE.md importing shared content and AGENTS.md inlining the same content, not a manual edit drifting out of sync. Source: https://github.com/Goldziher/ai-rulez/blob/main/skills/ai-rulez/references/presets-and-outputs.md and https://github.com/Goldziher/ai-rulez/blob/main/docs/configuration.md.

ianrios avatar Sep 08 '26 19:09 ianrios

Thanks @ianrios for reporting this, and for the detailed ai-rulez follow-up. That made the external ownership distinction very clear.

Resolved in Pilot Shell v11.0.2.

Pilot now recognizes an AGENTS.md / CLAUDE.md pair as externally generated only when both headers identify generated, do-not-edit outputs, declare the expected target, and share matching source provenance. When that contract is present, Pilot preserves both generated files byte-for-byte instead of trying to force CLAUDE.md to @AGENTS.md, while continuing the independent skill and rule checks. Ambiguous ownership still fails safely and preserves both sides.

Regression coverage exercises the generated-pair behavior across the synchronization modes. Thanks again for the excellent reproduction.

maxritter avatar Sep 09 '26 13:09 maxritter