Skip to content

Own Each Agent's Whole Global Instruction File From One Source, and Report a Local Edit #2423

Closed

Description

@ptr727

What happens

The host-safety installer, host-setup/agent-safety/claude/install.py, manages only two marker blocks in ~/.claude/CLAUDE.md. Everything outside the markers is never written and never checked. The fleet writes nothing at all to the global instruction files of Codex (~/.codex/AGENTS.md) or opencode (~/.config/opencode/AGENTS.md).

So a host can run with global instructions that are out of date with the fleet, in four ways:

  • Stale blocks. A re-run of the installer refreshes the blocks, but nothing triggers one. merge-and-release step 7 refreshes Skills only. One host was found running blocks installed three weeks earlier, with its containment hook missing.
  • Hand-written content outside the markers. It is never updated and never reported. On that host it was three sections that predate the kit and restate fleet rules in older wording. One of them described pr_review.py reply behavior the same day a release changed it.
  • Codex and opencode outside a fleet repository. Neither gets the host-wide content: repository boundaries, representative data, authorization scope, or the fleet entry point.
  • Edits versus versions. --report compares the live blocks only against the current checkout. A block edited by hand and a block from an older install both read "differs", so the report cannot say which.

Proposed

  1. One source, three targets. Render the host-wide content from one source to each installed agent's global instruction file: ~/.claude/CLAUDE.md, ~/.codex/AGENTS.md, and ~/.config/opencode/AGENTS.md. Include a target only where that agent is installed, and verify each path empirically with the installed agent version.
  2. Whole-file ownership. The installer writes the whole file and always overwrites it. Host-specific content lives in a separate local file that the installer never edits. The rendered output appends it under a marker, because Codex has no @ import.
  3. Telling an edit from an old version. The stamp already records the digest of what was installed.
    • The live file matches the stamp: it is an untouched previous version. Overwrite it silently.
    • The live file differs from the stamp: it was edited locally. Back it up, overwrite it, and print the diff so the edit can be moved into the local file.
    • No stamp, from an install before this change: treat it as edited.
  4. First run on an existing file. The content outside the old markers is backed up. Nothing moves into the local file automatically, so whatever restates fleet content is dropped rather than carried forward. The report names the backup path.
  5. Staleness is reported at release time. merge-and-release step 7 also runs this kit's --report next to the Skills refresh, and a stale host is reported to the maintainer.

Out of scope

Write-guard hooks for Codex and opencode stay on #781. This issue covers instruction content only.

Activity

  1. added
    enhancement
    agents
    on Oct 5, 2026
  2. ptr727 commented on Oct 5, 2026

    @ptr727
    OwnerAuthor

    How each agent loads global instructions, verified against the installed binaries

    Each finding below was read from the installed binary's own instruction-loading code. They were not taken from the agents' docs.

    • Codex (codex-cli 0.149.1). It reads AGENTS.override.md or AGENTS.md in ~/.codex, preferring the override. The override replaces the global file rather than adding to it. The installer must therefore never write one, and --report should flag one as shadowing the fleet content.
    • opencode (1.18.18). Its global list is [~/.config/opencode/AGENTS.md, ~/.claude/CLAUDE.md], and it takes the first that exists. With no opencode AGENTS.md, it falls back to the Claude file, Claude Code-specific text included. OPENCODE_DISABLE_CLAUDE_CODE or OPENCODE_DISABLE_CLAUDE_CODE_PROMPT turns that fallback off. Its config has an additive instructions array, which accepts extra file paths and URLs.
    • Claude Code. CLAUDE.local.md is a project-level file only, with no user-level counterpart. ~/.claude/CLAUDE.md supports @path imports. Codex has no import syntax.

    So no native "local" mechanism adds content in all three agents. The portable design renders each target as the fleet content plus a host-local file, appended under a marker. Writing an opencode AGENTS.md also ends opencode's fallback to the Claude file, so each agent gets text written for it.

  3. added a commit that references this issue on Oct 6, 2026
    fbc6ae3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions