Skip to main content

load_project_context

Function load_project_context 

Source
pub fn load_project_context(workspace: &Path) -> Option<String>
Expand description

Load project context from the workspace root, merging AGENTS.md and CLAUDE.md when present.

Each file is capped at [MAX_PROJECT_CONTEXT_SIZE] bytes with a truncation marker when larger. The returned string is empty of outer heading — callers wrap it (see prepend_project_context).

AGENTS.md is the authoritative project context (vendor-neutral). It is loaded when present. CLAUDE.md is read only as a fallback when AGENTS.md is absent — this preserves compatibility with Claude-only projects while avoiding double-loading both files (and double-charging the context budget) when a repo happens to ship both. The section is emitted under a ## AGENTS.md or ## CLAUDE.md sub-header matching whichever file was used. Returns None when neither file is present.