Skip to main content

Module context

Module context 

Source
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 total is estimated from the text.
Check
Context
Everything an agent works from in one project, before any session.
FileRead
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§

Agent
CheckKind
ItemKind
Scope
Where a file or setting comes from, as the agent ranks them.

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 as us.anthropic.claude-…), and how much of it is used. 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 agent would load working in project, 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: value pairs, quotes taken off.
gemini_names
The names Gemini CLI reads its instructions from: context.fileName in its settings, the project’s over the user’s, or GEMINI.md.
imports
The imports in text, in order. Ones that can’t be files, like @types/node in 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.