---
title: "Discussion on \"CLAUDE.md vs AGENTS.md: one rules file for Claude Code and Codex\" | Hashnode"
description: "Discussion on \"CLAUDE.md vs AGENTS.md: one rules file for Claude Code and Codex\". Keep shared rules in AGENTS.md so Claude Code and Codex read one file. Setup steps, the traps that split them and a checklist."
url: "https://hashnode.com/posts/claude-md-vs-agents-md/6aeb4f0597a9b19d61946e9c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [CLAUDE.md vs AGENTS.md: one rules file for Claude Code and Codex](https://iliyaoblakov.hashnode.dev/claude-md-vs-agents-md?utm_source=hashnode&utm_medium=feed)

Keep shared rules in AGENTS.md so Claude Code and Codex read one file. Setup steps, the traps that split them and a checklist.

Nov 4 · 11 min read · iliyaoblakov.hashnode.dev  
Read the article

-   [#claude-code](https://hashnode.com/tag/claude-code)
-   [#ai](https://hashnode.com/tag/ai)
-   [#developer-tools](https://hashnode.com/tag/developer-tools)
-   [#productivity](https://hashnode.com/tag/productivity)
-   [#codex](https://hashnode.com/tag/codex)

## Written by

[Iliya Oblakov](https://hashnode.com/@iliyaoblakov)

@iliyaoblakov

  
[View profile](https://hashnode.com/@iliyaoblakov)

## Responses 2

Markdown supported · ⌘↵ to post

[Adam Lewis](https://hashnode.com/@nark3d)

[Nov 6](https://hashnode.com/posts/claude-md-vs-agents-md/6aeb4f0597a9b19d61946e9c/comment/6aee4a2d7a7608d83c750ff4)

Pin down precedence: when both files are in play under claude-md-and-agents-md, does a later AGENTS.md actually override an earlier CLAUDE.md line, or do the two just stack in context with no winner? Matters for anything you'd write as a rule. If Codex resolves conflicts and Claude Code only concatenates, then the shared file has to be written so the two never disagree in the first place. How are you handling a line you want in AGENTS.md that Claude Code would read as contradicting something in .claude/rules?

[Iliya Oblakov](https://hashnode.com/@iliyaoblakov)

[Nov 7](https://hashnode.com/posts/claude-md-vs-agents-md/6aeb4f0597a9b19d61946e9c/comment/6aee4a2d7a7608d83c750ff4#reply-6aeec07aad182b2ffc5342dc)

Thanks, Adam. By default, from v2.1.277, Claude Code reads AGENTS.md only when no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md sits in the working directory or above it, so with one of them present there's nothing to rank. With @AGENTS.md at the top of CLAUDE.md, the shared lines load first, but the docs say Claude Code can follow either line when two contradict. Codex has a fixed order: at most one file per directory, AGENTS.md ahead of any name in project\_doc\_fallback\_filenames, and the file closest to the working directory overrides the ones above it. So keep every shared rule in AGENTS.md and give CLAUDE.md only lines that don't contradict them.
