Repository navigation
Conversation
…@AGENTS.md bridge AGENTS.md is the vendor-neutral instruction file (agents.md, stewarded by the Agentic AI Foundation under the Linux Foundation) read by Codex, Copilot, Cursor, Gemini CLI, OpenCode, Pi and, since 2.1.277, by Claude Code. ctx init wrote the bootstrap instructions only to CLAUDE.md while ctx setup codex|opencode|pi deployed a second, older AGENTS.md template, so mixed-tool teams carried two diverging texts and non-Claude users got nothing from ctx init. ctx init now creates or merges AGENTS.md between the ctx:agents markers the setup deployers already recognise, from the one template every agent shares. CLAUDE.md is still created or merged, but its ctx block is only an @AGENTS.md import: Claude Code's own AGENTS.md fallback needs 2.1.277, is unavailable in some sessions, and switches off as soon as any CLAUDE.md exists in the tree, which is exactly the --merge case. Existing projects migrate with ctx init --reset --merge. Changes: - internal/cli/initialize/core/agents: new HandleMd, wired into init before the CLAUDE.md handler; failures stay non-fatal - internal/assets/integrations/agents.md: tool-neutral version of the former CLAUDE.md content, closed by the new marker.AgentsEnd - internal/assets/claude/CLAUDE.md: reduced to the marker-bounded @AGENTS.md import - merge.OrCreate inserts only the marker-bounded block into an existing file; the template's own title no longer leaks in as a second H1 - docs, command help, flag text and package doc comments follow the new output; DECISIONS.md records the choice and supersedes the 2026-01-25 "Removed AGENTS.md from project root" entry Verification: gofmt, go vet and golangci-lint v2.15.0 (CI pin) are clean; the full go test run shows no new failures against a clean upstream/main worktree on the same Windows checkout (the pre-existing environment failures are identical in both runs). Hand-driven ctx init --merge against a project with its own AGENTS.md and CLAUDE.md inserts the block after each H1 and leaves the rest untouched. Closes ActiveMemory#197 Spec: specs/init-agents-md.md Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
bilersan
requested review from
CoderMungan,
hamzaerbay,
josealekhine and
parlakisik
as code owners
October 22, 2026 18:18
hamzaerbay
approved these changes
Oct 22, 2026
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.
Summary
ctx initwrote the agent bootstrap instructions only toCLAUDE.md, whilectx setup codex|opencode|pideployed a second, olderAGENTS.mdtemplate:mixed-tool teams carried two diverging texts and non-Claude users got nothing
from
ctx init. AGENTS.md is the vendor-neutralinstruction file (stewarded by the Agentic AI Foundation under the Linux
Foundation, announced 2025-12-09)
read natively by Codex, Copilot, Cursor, Gemini CLI, OpenCode, Pi and, since
Claude Code 2.1.277, by
Claude Code. This PR makes
ctx initcreate or mergeAGENTS.mdfrom the onetemplate every agent shares, and turns the ctx block of
CLAUDE.mdinto an@AGENTS.mdimport. The bridge stays because Claude Code's ownAGENTS.mdfallback needs 2.1.277, is unavailable in some sessions, and switches off as
soon as any
CLAUDE.mdexists in the tree, which is exactly the--mergecase. Existing projects migrate with
ctx init --reset --merge.Closes #197
Changes
internal/cli/initialize/core/agents: newHandleMd, wired intoctx initbefore the
CLAUDE.mdhandler; failures stay non-fatal, as forCLAUDE.md— serves
specs/init-agents-md.mdinternal/assets/integrations/agents.md: tool-neutral version of the formerCLAUDE.mdcontent between<!-- ctx:agents -->and the newmarker.AgentsEnd(<!-- ctx:agents:end -->);ctx setup agents|codex|opencode|piship the same file and already skip on the marker — serves
specs/init-agents-md.mdinternal/assets/claude/CLAUDE.md: reduced to the marker-bounded@AGENTS.mdimport — serves
specs/init-agents-md.mdmerge.OrCreateinserts only the marker-bounded block into an existing file(the template's own
# Project Contexttitle used to come along as a secondH1); block extraction moves to
merge/section.go, shared withUpdateMarkedSection— servesspecs/init-agents-md.mddocs/cli/init-status.md,docs/cli/setup.md,docs/operations/{migration,integrations,upgrading}.md,docs/operations/runbooks/breaking-migration.md,docs/home/{common-workflows,configuration}.md),ctx initlong help and--mergeflag text,internal/assets/README.mdand package doc comments follow the new output — serves
specs/init-agents-md.md.context/DECISIONS.md: records the choice and supersedes the 2026-01-25"Removed AGENTS.md from project root" entry — serves
specs/init-agents-md.mdSpecs
specs/init-agents-md.md—ctx initoutput forAGENTS.mdand theCLAUDE.mdbridge: behavior table for fresh, hand-written and alreadymarked files,
--merge/--resetsemantics, non-goals (setup deploy logic,repo-root flip, nested
AGENTS.md, copilot-instructions)Verification
gofmt,go vet ./...andgolangci-lintv2.15.0 (the CI pin): clean, 0 issuesgo test ./...on a Windows checkout: no new failures against a cleanupstream/mainworktree run the same way (the pre-existing environmentfailures are identical in both runs);
internal/cli/initializeat 100%statement coverage;
internal/auditandinternal/complianceconventionspass for the new files
ctx init --mergeagainst a project with its ownAGENTS.mdand
CLAUDE.md: block inserted after each H1, backups written, the restuntouched; a fresh
ctx initcreates both files from the templatesmake check-steering(the branch touches no steeringsources or outputs); CI covers it