Skip to content

feat(codex): stop writing Codebase Memory guidance to global AGENTS.md #1689

Description

@astandrik

What problem does this solve?

The Codex installer currently writes Codebase Memory guidance to $CODEX_HOME/AGENTS.md and installs the Codebase Memory skill in the same run.

The behavior is visible in current main:

This was an intentional multi-agent compatibility choice. Commit 159378ad introduced Codex detection, marker-managed instruction files, and the original global block. Issue #976 and PR #977 later kept .codex/AGENTS.md as lightweight guidance while adding the skill.

Current Codex documentation describes different loading behavior for these two surfaces:

As a result, Codex receives overlapping Codebase Memory instructions from two separately maintained sources. The global block consumes context even when the task does not call for structural code discovery. It can also drift from the skill's activation, fallback, pagination, coverage, and mutation rules.

A read-only reproduction on v0.10.2 shows that the installer still plans the global write:

$ codebase-memory-mcp --version
codebase-memory-mcp 0.10.2

$ codebase-memory-mcp install --plan |
    jq -r '.instruction_files_planned[] | select(endswith("/.codex/AGENTS.md"))'
/path/to/home/.codex/AGENTS.md

Proposed solution

For Codex, use the installed skill as the workflow instruction surface and stop writing Codebase Memory guidance to the global AGENTS.md.

One implementation path:

  1. Pass NULL as the Codex instruction path when calling install_generic_agent_config.
  2. Keep the Codex MCP entry, skill, agent profiles, and lifecycle hooks unchanged.
  3. During install, remove only the exact codebase-memory-mcp:start/end managed block from an existing $CODEX_HOME/AGENTS.md. Preserve all content outside that block.
  4. Keep uninstall able to remove the managed block from older installations.
  5. Update install --plan, the smoke test, and the README so they no longer require a Codex global instruction write. If a legacy cleanup is planned, report it as a cleanup rather than a new instruction file.

Suggested regression coverage:

  • A fresh Codex install does not create $CODEX_HOME/AGENTS.md.
  • An existing user AGENTS.md without the managed markers stays byte-identical.
  • An existing user AGENTS.md with the managed block loses only that block.
  • install --plan and --dry-run do not mutate either case.
  • Repeated installs do not restore the block.
  • MCP, skill, profiles, and hooks retain their current behavior.

Alternatives considered

Keeping a short pointer in the global file still loads Codebase Memory guidance for every task and leaves two instruction surfaces to maintain. Copying the skill guidance into AGENTS.md has the same problem and defeats progressive disclosure.

Stopping new writes without a migration would leave the old managed block active for existing users, so the installer should clean up only the block it owns.

Confirmations

Metadata

Metadata

Assignees

No one assigned

    Labels

    editor/integrationEditor compatibility and CLI integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions