Expand description
What an agent works from: the instruction files it loads and in what order, its skills, subagents, commands, hooks and MCP servers, what a session of it read, and checks on all of that. Every file here is read as data; nothing in one is ever followed. Nothing here writes.
Each agent’s rules are its own, so each has its own discovery. With a transcript, what the
agent says it loaded wins over what the files suggest (transcript).
Structs§
- Breakdown
- What fills the context, in tokens. Everything but
totalis estimated from the text. - Check
- Context
- Everything an agent works from in one project, before any session.
- File
Read - A file the session read, searched in or changed.
- Homes
- Where each agent keeps the user’s own settings. Tests point these at fixtures.
- Instruction
- One instruction file, in the order the agent reads it.
- Item
- A skill, subagent, command, hook or MCP server, and the file that defines it.
- Loaded
- An instruction file as the agent got it.
- Search
- A search the session ran: Grep or Glob.
- Session
Enums§
Constants§
- CODEX_
BYTES - Codex stops reading project instructions after this many bytes (
project_doc_max_bytes). - IMPORT_
DEPTH - Imports are followed this many hops deep and no further, as Claude Code follows them.
- LARGE_
CHARS - Claude Code warns of an instruction file past this many characters.
- MEMORY_
BYTES - Nor more than this many bytes of it, whichever comes first.
- MEMORY_
LINES - Claude Code loads only this many lines of its auto memory’s
MEMORY.md.
Functions§
- checks
- claude_
project_ dir - The folder Claude Code keeps a project’s sessions in: its path with every character that isn’t a letter or digit made a dash.
- claude_
window - The context window of a Claude model, by the id its transcript logs (
claude-opus-5-5, or with a provider’s prefix asus.anthropic.claude-…), and how much of it isused. Every Claude model since Opus and Sonnet 4.6 has a million, and so does a model not known here, since a new one is likelier to have the long window than an old one. Those up to 4.5 have 200k, unless the name says otherwise ([1m],-1m) or the context has gone past it. - discover
- What
agentwould load working inproject, worked out from the files by its rules. - estimate_
tokens - Text is about four characters a token in English and code; good enough to compare parts.
- front_
matter - A Markdown file’s front matter, as plain
key: valuepairs, quotes taken off. - gemini_
names - The names Gemini CLI reads its instructions from:
context.fileNamein its settings, the project’s over the user’s, orGEMINI.md. - imports
- The imports in
text, in order. Ones that can’t be files, like@types/nodein prose, are left out: a path counts only with an extension or a leading./,../,~/or/. - read_
session - Reads a transcript. A line that isn’t JSON, or a kind it doesn’t know, is passed over, so a newer Claude Code’s transcript still reads as far as it can.
- transcript_
path - Where Claude Code keeps session
session’s transcript for a project.