Make CLAUDE.md point to AGENTS.md instead of duplicating content#40
Make CLAUDE.md point to AGENTS.md instead of duplicating content#40lmajano merged 2 commits intodevelopmentfrom
Conversation
Agent-Logs-Url: https://github.com/ColdBox/coldbox-cli/sessions/785ea4ed-69ec-4c40-9eb3-3ed6e0ae4012 Co-authored-by: lmajano <137111+lmajano@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces duplicated AI agent configuration by generating a single shared AGENTS.md file and making Claude’s CLAUDE.md delegate to it via Claude Code’s @AGENTS.md import directive.
Changes:
- Update
AgentRegistry.configureAgent()soclaudewrites full config toAGENTS.mdand writesCLAUDE.mdas@AGENTS.md. - Update documentation to reflect
CLAUDE.md → AGENTS.mdbehavior. - Add an Unreleased changelog entry describing the change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| models/AgentRegistry.cfc | Generates shared AGENTS.md for Claude and writes a delegating CLAUDE.md. |
| AI_INTEGRATION.md | Updates agent file descriptions and the supported agents table to reflect delegation. |
| README.md | Updates supported agents description to note CLAUDE.md → AGENTS.md. |
| changelog.md | Adds an Unreleased note about the new delegation behavior. |
| // For Claude, write the full content to AGENTS.md and make CLAUDE.md point to it | ||
| if ( arguments.agent == "claude" ) { | ||
| var agentsFilePath = getDirectoryFromPath( configPath ) & "AGENTS.md" | ||
| fileWrite( agentsFilePath, content ) | ||
| fileWrite( configPath, "@AGENTS.md" ) | ||
| return |
There was a problem hiding this comment.
configureAgent() now makes Claude depend on a shared AGENTS.md, but the rest of the system still treats Claude as having only CLAUDE.md. This can leave the install in a broken state without detection (e.g., ai doctor/AgentRegistry.diagnose() won’t warn if AGENTS.md is missing, and removing codex/opencode will delete AGENTS.md even if claude is still configured, leaving CLAUDE.md pointing at a non-existent file). Update the agent health/removal logic to model AGENTS.md as a shared dependency and only delete it when no configured agents require it, and ensure diagnostics validate both files for Claude.
| // For Claude, write the full content to AGENTS.md and make CLAUDE.md point to it | ||
| if ( arguments.agent == "claude" ) { | ||
| var agentsFilePath = getDirectoryFromPath( configPath ) & "AGENTS.md" | ||
| fileWrite( agentsFilePath, content ) | ||
| fileWrite( configPath, "@AGENTS.md" ) |
There was a problem hiding this comment.
This block hardcodes both the shared filename (AGENTS.md) and recomputes the directory via getDirectoryFromPath( configPath ) even though configDir is already available. Consider deriving the shared path from the existing agent-path mapping (e.g., via getAgentConfigPath(directory, "codex") or static.AGENT_FILES) and using configDir to avoid future divergence if agent filenames/locations change.
| // For Claude, write the full content to AGENTS.md and make CLAUDE.md point to it | |
| if ( arguments.agent == "claude" ) { | |
| var agentsFilePath = getDirectoryFromPath( configPath ) & "AGENTS.md" | |
| fileWrite( agentsFilePath, content ) | |
| fileWrite( configPath, "@AGENTS.md" ) | |
| // For Claude, write the full content to the shared agent file (e.g. AGENTS.md) | |
| if ( arguments.agent == "claude" ) { | |
| var sharedAgentFileName = static.AGENT_FILES[ "codex" ] | |
| var agentsFilePath = configDir & sharedAgentFileName | |
| fileWrite( agentsFilePath, content ) | |
| fileWrite( configPath, "@" & sharedAgentFileName ) |
When
coldbox ai installconfigured the Claude agent,CLAUDE.mdandAGENTS.mdwere generated with identical content. Claude Code supports the@AGENTS.mdimport directive, soCLAUDE.mdcan simply delegate to the shared file.Changes
models/AgentRegistry.cfc— InconfigureAgent(), when agent isclaude:AGENTS.md(shared with Codex/OpenCode)CLAUDE.mdis written with just@AGENTS.mdconfigPathviagetDirectoryFromPath()to avoid trailing-slash edge casesAI_INTEGRATION.md/README.md— Updated supported agents table and descriptions to reflectCLAUDE.md → AGENTS.mdchangelog.md— Added unreleased entryResult
All configuration content lives in
AGENTS.md; users switching between Claude and Codex/OpenCode share a single source of truth.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.