When Are Subdirectory CLAUDE.md and AGENTS.md Files Loaded? Making AI Follow the Rules in a Monorepo
If you put several sites in one repository and place a CLAUDE.md or AGENTS.md in each site's folder, those rules aren't guaranteed to be read before work begins. Claude Code loads a CLAUDE.md below the launch directory when Claude reads, writes or edits a file in that folder, while Codex reads only the AGENTS.md files from the project root down to the launch directory, once at the start of each run. This article compares, item by item, how both tools load these files and how to check whether they were loaded (/context shows only what was loaded at startup), then covers a check that stops the release if anything outside the assigned folder changes, and tool settings that block writes. It also shows how to tell similarly named repositories apart by remote URL and root commit, and commands that show only environment variable names (checked November 1, 2026).