Skip to content

feat(agent/agentcontextconfig): fall back to AGENT.md and CLAUDE.md#26282

Draft
tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/codagt-338-support-claudemd-fallback-for-instruction-files
Draft

feat(agent/agentcontextconfig): fall back to AGENT.md and CLAUDE.md#26282
tracyjohnsonux wants to merge 1 commit into
mainfrom
tracy/codagt-338-support-claudemd-fallback-for-instruction-files

Conversation

@tracyjohnsonux

Copy link
Copy Markdown
Contributor

Adds an ordered fallback chain so Coder Agents picks up AGENTS.md, then AGENT.md, then CLAUDE.md per directory. The first existing file wins; a file that sanitizes to empty falls through to the next candidate, matching Coder's existing empty-file semantics.

The configuration env var is renamed to follow the rest of the package convention (*_DIRS, *_FILES for comma-separated lists):

  • CODER_AGENT_EXP_INSTRUCTIONS_FILECODER_AGENT_EXP_INSTRUCTIONS_FILES

The var is experimental, so the rename is a straight swap with no backcompat alias. Setting it to a single name still works and disables the default fallback, preserving the behavior of any user who pinned the old single-name override.

Refs https://linear.app/codercom/issue/CODAGT-338

Design plan and decision log

Behavior

  • Per directory, the package searches a comma-separated, priority-ordered list of filenames (AGENTS.md,AGENT.md,CLAUDE.md by default).
  • First existing, non-empty file wins per directory. No concatenation across candidate names in the same folder.
  • A file that exists but sanitizes to empty (HTML-comment-only, whitespace, etc.) is treated as "not found" and falls through to the next candidate, matching Coder's existing single-filename behavior.
  • Sanitization, the 64 KiB truncation cap, and the case-insensitive name match are unchanged.

Env var

One env var, pluralized to match CODER_AGENT_EXP_INSTRUCTIONS_DIRS, CODER_AGENT_EXP_SKILLS_DIRS, and CODER_AGENT_EXP_MCP_CONFIG_FILES. The closest precedent is CODER_AGENT_EXP_MCP_CONFIG_FILES, which already takes a comma-separated list in dogfood (~/.mcp.json,.mcp.json).

Divergences from Mux

Mux already has comparable fallback behavior. We adopt the same priority list but deliberately diverge on two points:

  • Mux uses pre-sanitization existence to pick the base file. Coder keeps its "empty-after-sanitization is not found" rule for consistency with prior single-filename behavior, which means an empty AGENTS.md falls through to CLAUDE.md.
  • Mux also overlays AGENTS.local.md from the same directory. Not in scope for this change.

Scope

  • agent/agentcontextconfig/api.go — env var rename, Config field rename, default fallback list, Resolve and ContextPartsFromDir parse the list and pass a []string of candidate filenames to readInstructionFileFromDir, which iterates in priority order.
  • agent/agentcontextconfig/api_test.go — six new subtests covering AGENTS.md > AGENT.md > CLAUDE.md precedence, fallback when only CLAUDE.md exists, AGENT.md > CLAUDE.md, empty AGENTS.md falls through, single-name env var disables the default fallback, and per-directory fallback is independent.
  • coderd/x/chatd/chatd_test.go — env var identifier rename only.

No downstream changes. agent/proto, coderd/x/chatd/chatd.go, and codersdk treat the instruction file as opaque path + content.


Authored by Coder Agents on behalf of @tracyjohnsonux.

Coder Agents previously read a single configurable instruction
filename (default AGENTS.md). Users coming from other agent
tooling expect CLAUDE.md (and to a lesser extent AGENT.md) to
work as well.

Per directory, the package now searches a comma-separated,
priority-ordered list of filenames. The first existing file
wins; files that are empty after sanitization fall through to
the next candidate, matching Coder's existing empty-file
semantics. Default list: AGENTS.md,AGENT.md,CLAUDE.md.

The configuration env var is renamed to match the rest of the
package (CODER_AGENT_EXP_*_DIRS / *_FILES use the plural form
for lists):

  CODER_AGENT_EXP_INSTRUCTIONS_FILE -> CODER_AGENT_EXP_INSTRUCTIONS_FILES

The var is experimental and the rename is a straight swap with
no backcompat alias. Setting it to a single name still works
and disables the default fallback, which preserves the
behavior of users who pinned the old single-name override.

Linear: CODAGT-338
@linear-code

linear-code Bot commented Jun 11, 2026

Copy link
Copy Markdown

CODAGT-338

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.

1 participant