How CLAUDE.md Files Work — Discovery, Scoping, and Monorepo Behavior Context Explaining how the instruction file discovery algorithm works based on the actual Rust implementation at rust/crates/runtime/src/prompt.rs:192-213, with diagrams showing behavior in monorepos, sibling projects, and nested workspaces.
The Algorithm (from source code) // prompt.rs:192-213 fn discover_instruction_files(cwd: &Path) -> Vec { // 1. Collect every directory from cwd up to filesystem root // 2. Reverse so root comes first (ancestry order) // 3. For each directory, check 4 candidate filenames