agynio

Claudemd Deep Dive — Development skill for Claude Code

Development community

Research into how Claude Code loads subdirectory CLAUDE.md files — what triggers injection, where content lands in the API payload, deduplication, session resume, and token cost, traced via intercepti.

How to install Claudemd Deep Dive

This entry records only its repository, not the path inside it, so there is no exact command to give. Open agynio/claudemd-deep-dive and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claudemd Deep Dive does

Research into how Claude Code loads subdirectory CLAUDE.md files — what triggers injection, where content lands in the API payload, deduplication, session resume, and token cost, traced via intercepting proxy.

Alternatives in Development

  • Management Deep Dive — 管理层纵深研究:买股票就是买人 15.9k ★
  • Review Claudemd — Review recent conversations to find improvements for CLAUDE.md files 6.5k ★
  • Oob — Out-of-band orchestrator — confirm BLIND SSRF/XXE/SQLi/RCE/Log4Shell by correlating interactsh callbacks to th 4.5k ★

README

How Claude Code Reads CLAUDE.md Files — Experiment

Claude Code supports `CLAUDE.md` files at multiple levels. Global and project-root files are simple — loaded once at session start, always in context. Subdirectory files are different: the docs say they load *"on demand as Claude navigates your codebase"* but explain nothing about the actual mechanism.

We had questions that mattered for building agents:

  • What exactly triggers the load — any tool, or a specific one?
  • Does it re-inject on every file read, or is there deduplication?
  • Where does the content go — system prompt or messages?
  • What survives a session resume?
  • Does repeated injection blow up token costs?

To answer these we put an intercepting HTTP proxy between Claude Code and the Anthropic API and traced every `/v1/messages` call. Full write-up: **[REPORT.md](./REPORT.md)**


Key Findings

Question Answer
What triggers subdir CLAUDE.md? Read tool only — not Bash, Glob, or Write
Where does it appear? Concatenated into the tool result text — not the system prompt, not a separate message
Does system prompt grow? Never — stays constant regardless of how many subdirs load
Re-injected on every Read? No — once per subprocess per directory (readFileState Map)
Visible after injection? Yes — sticky in message history for all subsequent turns
Parallel reads, same dir? One injection total for the whole batch
Persisted to disk? Stripped before writing — disk session is always clean
Session resume? readFileState resets → fresh injection on first Read
Token cost? Near-zero — prompt caching absorbs it

Repository Structure

Experiment scripts

File Description
src/experiment.ts Experiment 1 — 9 scenarios covering first Read, same-session re-read, new session, multiple subdirs, Write-only, Glob-only, Bash-only, and resumed session. Outputs results.json.
`src/exper