Repository navigation
fix(bin): keep a project's existing agent guide in place instead of relocating it - #3
Merged
Merged
Conversation
…ating it The ship brief told workers to run fm-ensure-agents-md.sh whenever AGENTS.md or CLAUDE.md existed, and the helper itself moved a real CLAUDE.md into a new AGENTS.md and left a two-line import behind. Following the brief exactly therefore bundled a guide relocation into unrelated feature branches. The helper now creates AGENTS.md and the CLAUDE.md pointer only when a project has no working guide, keeps an existing guide at its path (adding only the self-governance section), and names the file to record knowledge in on a final guide: line. Relocation, adding a pointer beside an existing AGENTS.md, and replacing a CLAUDE.md symlink move behind an explicit --migrate-layout flag for a change whose purpose is that relocation. The brief now runs the helper only when the task produced durable knowledge, records it in the guide the helper names, and forbids relocating or restructuring an existing guide inside the task.
karimghabra
force-pushed
the
fm/fm-agents-md-scaffold-scope
branch
from
September 11, 2026 09:51
176df07 to
7059cb4
Compare
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.
Intent
Twice in one day a ship worker relocated a project's CLAUDE.md into a new AGENTS.md and left a two-line import behind, on branches that had nothing to do with documentation layout. Both times the review correctly flagged it as unrequested by the stated intent. On the first branch firstmate accepted it because that branch was already large and the marginal cost was near zero; on the second it was the majority of the diff, in a production repository the captain reviews personally, and firstmate had it reverted.
Neither worker overreached. The prompt comes from firstmate's own generated ship brief, which instructs a worker to run bin/fm-ensure-agents-md.sh whenever AGENTS.md or CLAUDE.md exists. The worker reads that as licence to restructure a working file.
The instruction is trying to do something good: make sure a project has a guide, and give durable knowledge a home. It is the relocation that is unwanted.
What Changed
bin/fm-ensure-agents-md.shno longer moves an existing guide. A realCLAUDE.mdwith its own content stays the project's guide at its current path and only gets the## Maintaining this filesection added. A correctCLAUDE.md -> AGENTS.mdsymlink stays a symlink. The helper still createsAGENTS.mdand the@AGENTS.mdpointer when a project has no working guide, and still adds a missing pointer next to an existingAGENTS.md. Every successful run now ends with aguide: <absolute path>line naming the file to write knowledge into. The conflict messages (case-variantagents.md, two real guide files) now say to record the knowledge by hand where it already lives, and to rename or merge files only in a separate change.bin/fm-brief.shnow tells the worker to run the helper only when the task produced durable project knowledge, not wheneverAGENTS.mdorCLAUDE.mdexists. The worker records that knowledge in the file theguide:line names. The brief also forbids relocating, renaming, merging, or restructuring an existingAGENTS.md/CLAUDE.mdas part of the task.AGENTS.md, thestowskill,docs/architecture.md, anddocs/scripts.mdnow say "agent guide" instead of a project'sAGENTS.md, and state that moving a working guide is a change of its own. Intests/, the old promotion and symlink-migration cases are replaced with cases where an existingCLAUDE.mdstays at its path and knowledge reaches the existing guide. There is also a new brief test that the ship prompt keeps an existingCLAUDE.mdin place.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is limited to a crewmate worktree helper, the ship-brief wording, and prose; the helper no longer has any path that moves a real CLAUDE.md or replaces a working symlink; the recorded round-1 decisions are fully applied (the --migrate-layout flag is gone and default mode adds the missing pointer); and every success path ends with the guide line and is covered by behavior tests.
Testing
I drove the real helper CLI and the real brief generator in isolated temporary git projects and FM_HOME directories, comparing the base commit with the target commit. Base: a CLAUDE.md-only project was promoted to AGENTS.md with a pointer left behind, and a correct symlink was replaced by a pointer file. Target: CLAUDE.md stays in place with only the self-governance section appended, and the symlink stays a symlink. AGENTS.md-only still gains the pointer, as the user decided. No-guide and pointer-only projects still get the full scaffold. The conflict cases still refuse and touch nothing, and their messages now say to leave the guide where it is. Reruns change nothing, CRLF line endings are preserved, the project mark is respected, and
--migrate-layoutis rejected. The generated target ship brief ties the helper to durable knowledge only and forbids relocation. A worker who follows the brief's own command in a CLAUDE.md-only repo produces a diff that touches only CLAUDE.md plus their unrelated work, with no AGENTS.md. Both targeted test files pass on the target. Run against the base tree, they fail. This is a CLI and generated-text change, so text transcripts are the right evidence; there is no UI to screenshot. The overall result is go.bash tests/fm-brief.test.shbash tests/fm-brief.test.sh(test_ship_project_memory_command_keeps_existing_claude_md)Evidence: Helper layout transcript: base vs target across 10 guide layouts
Source: Helper layout transcript: base vs target across 10 guide layouts
Evidence: Helper edge cases: append-only diff, CRLF, rerun, removed --migrate-layout, --help
Source: Helper edge cases: append-only diff, CRLF, rerun, removed --migrate-layout, --help
Evidence: Generated ship brief '# Project memory' section, base vs target
Source: Generated ship brief '# Project memory' section, base vs target
Evidence: Worker follows the brief's command in a CLAUDE.md-only repo: resulting diff
Source: Worker follows the brief's command in a CLAUDE.md-only repo: resulting diff
Evidence: New tests fail against the base helper and brief (regression reproduced)
Source: New tests fail against the base helper and brief (regression reproduced)
Evidence: Live driver script used for the layout transcript
Source: Live driver script used for the layout transcript
Evidence: Key before/after: CLAUDE.md-only project
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-brief.test.shbash tests/fm-brief.test.sh(test_ship_project_memory_command_keeps_existing_claude_md)bash drive-helper.sh(evidence dir): ran the base (6705ed2) and target helpers on fresh git projects covering 10 layouts: claude-only, claude-only CRLF, claude-only with the project mark, correct CLAUDE.md symlink, agents-only, no guide, pointer-only, both real, lowercase agents.md, wrong symlinkChecked the kept CLAUDE.md withgit diff(only appended), checked CRLF preservation, ran the helper twice on the kept CLAUDE.md and on the symlink layout, ran--migrate-layout(with and without a directory), passed a directory path from another cwd, and ran--helpFM_HOME=<isolated> bin/fm-brief.sh live-brief-<label> some-proj --mode no-mistakeswith both the base and target trees, then compared the '# Project memory' sectionsWorker end-to-end: ran the command taken from the generated target brief in a CLAUDE.md-only repo during unrelated work, recorded knowledge at the namedguide:path, then checkedgit statusandgit diff --statbash tests/fm-ensure-agents-md.test.shbash tests/fm-brief.test.shRan the target branch'stests/fm-ensure-agents-md.test.shandtests/fm-brief.test.shagainst the base tree to confirm they fail theregrep -rn fm-ensure-agents-mdacross bin/docs/skills to confirm no other caller still runs the helper whenever a guide exists✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.