Skip to content

ctx init writes AGENTS.md; CLAUDE.md becomes an @AGENTS.md bridge - #198

Open
bilersan wants to merge 1 commit into
ActiveMemory:mainfrom
bilersan:feat/init-agents-md
Open

bilersan wants to merge 1 commit into
ActiveMemory:mainfrom
bilersan:feat/init-agents-md

Conversation

@bilersan

Copy link
Copy Markdown
Contributor

Summary

ctx init wrote the agent bootstrap instructions only to CLAUDE.md, while
ctx setup codex|opencode|pi deployed a second, older AGENTS.md template:
mixed-tool teams carried two diverging texts and non-Claude users got nothing
from ctx init. AGENTS.md is the vendor-neutral
instruction 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 init create or merge AGENTS.md from the one
template every agent shares, and turns the ctx block of CLAUDE.md into an
@AGENTS.md import. The bridge stays because 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.

Closes #197

Changes

  • internal/cli/initialize/core/agents: new HandleMd, wired into ctx init
    before the CLAUDE.md handler; failures stay non-fatal, as for CLAUDE.md
    — serves specs/init-agents-md.md
  • internal/assets/integrations/agents.md: tool-neutral version of the former
    CLAUDE.md content between <!-- ctx:agents --> and the new
    marker.AgentsEnd (<!-- ctx:agents:end -->); ctx setup agents|codex|opencode|pi
    ship the same file and already skip on the marker — serves specs/init-agents-md.md
  • internal/assets/claude/CLAUDE.md: reduced to the marker-bounded @AGENTS.md
    import — serves specs/init-agents-md.md
  • merge.OrCreate inserts only the marker-bounded block into an existing file
    (the template's own # Project Context title used to come along as a second
    H1); block extraction moves to merge/section.go, shared with
    UpdateMarkedSection — serves specs/init-agents-md.md
  • Docs (docs/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 init long help and --merge flag text, internal/assets/README.md
    and 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.md

Specs

  • specs/init-agents-md.md — ctx init output for AGENTS.md and the
    CLAUDE.md bridge: behavior table for fresh, hand-written and already
    marked files, --merge/--reset semantics, non-goals (setup deploy logic,
    repo-root flip, nested AGENTS.md, copilot-instructions)

Verification

  • gofmt, go vet ./... and golangci-lint v2.15.0 (the CI pin): clean, 0 issues
  • go test ./... on a Windows checkout: no new failures against a clean
    upstream/main worktree run the same way (the pre-existing environment
    failures are identical in both runs); internal/cli/initialize at 100%
    statement coverage; internal/audit and internal/compliance conventions
    pass for the new files
  • Hand-driven ctx init --merge against a project with its own AGENTS.md
    and CLAUDE.md: block inserted after each H1, backups written, the rest
    untouched; a fresh ctx init creates both files from the templates
  • Not run locally: make check-steering (the branch touches no steering
    sources or outputs); CI covers it

…@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>
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.

ctx init should generate AGENTS.md (the open standard) and keep CLAUDE.md as an @AGENTS.md bridge

2 participants