Two Knowledge Hierarchies: Structuring Context for AI Agents and LLMs TestSmith has implemented a two-tier knowledge hierarchy to provide AI agents and LLMs with structured, task-specific context. For AI agents working on the TestSmith codebase, the system uses a `CLAUDE.md` hierarchy with per-package files that agents load automatically when touching specific directories, ensuring they receive only relevant context. For runtime test generation, TestSmith merges a root `TESTSMITH.md` file with optional per-directory overrides into the system prompt, exempting this project knowledge from the configurable token budget that trims other content. TestSmith has two distinct audiences that need context about the project: AI agents that work on the TestSmith codebase helping develop and extend it , and the LLM that generates test code for your project at runtime. These are different problems with different solutions. When an AI agent opens TestSmith to fix a bug or add a feature, it needs to understand the codebase structure without reading every file. A single large context file doesn't work well — an agent fixing a retry bug doesn't need to know the Java driver's fixture generation logic. The solution is a CLAUDE.md hierarchy: CLAUDE.md ← package map, invariants, dependency direction internal/domain/CLAUDE.md ← interfaces, key types, "add a field" checklist internal/generation/CLAUDE.md ← pipeline data flow, verifier selection internal/llm/CLAUDE.md ← middleware stack, batch vs fan-out, cache key internal/projectknowledge/CLAUDE.md ← TESTSMITH.md hierarchy, budget tiers internal/drivers/CLAUDE.md ← how to add an adapter or language driver The root file is the map. The per-package files are the territory. An agent touching the LLM retry logic loads internal/llm/CLAUDE.md — it never sees the driver or generation docs. The root file contains three things that every agent needs regardless of task: domain never imports other internal packages; drivers never import generation GeneratedFile.Language must always be set; resolveAction has specific rules for fixture vs. non-fixture files Per-package files contain the "read this before touching this package" context: data flow diagrams for the pipeline, the middleware stack for the LLM layer, the adapter registration pattern for drivers. When Claude Code loads a file in a package, it automatically reads that package's CLAUDE.md . The agent gets exactly what it needs, nothing more. This is what TestSmith injects into prompts when generating tests for your project. It's a conventions file you maintain alongside your source code. Two levels are merged at generation time: