Hard-coded constants, data flow, feature gates — verified against the Claude Code source.
| Constant | Value | Purpose |
|---|---|---|
| MEMORY.md line cap | 200 lines | Index truncation |
| MEMORY.md byte cap | 25,000 bytes | Index truncation (for long-line indexes) |
| Per-file recall lines | 200 lines | Topic file truncation when surfaced |
| Per-file recall bytes | 4,096 bytes | ~4KB per surfaced memory file |
| Session memory budget | 61,440 bytes | 60KB total for all surfaced memories |
| Max files scanned | 200 files | Memory directory scan limit |
| Max selected files | 5 files | Hard-coded in Sonnet selector prompt |
| @import depth | 5 levels | Prevents circular reference loops |
| Frontmatter scan depth | 30 lines | How deep to look for YAML frontmatter |
| CLAUDE.md "large" flag | 40,000 chars | /doctor warning only — not enforced |
| Auto-compact buffer | 13,000 tokens | Triggers when window - usage < this |
| MCP description cap | 2,048 chars | Tool descriptions truncated beyond this |
| Dream time gate | 24 hours | Minimum time between consolidations |
| Dream session gate | 5 sessions | Minimum transcript files since last run |
| Dream lock stale | 1 hour | Lock PID considered stale after this |
buildMemoryPrompt() reads MEMORY.md → dual truncation (200 lines / 25KB) → warning appended if truncated → injected into system prompt via getUserContext().
User input → findRelevantMemories() (Sonnet scores filename+description, picks up to 5) → readMemoriesForSurfacing() (truncate 200 lines / 4KB each, 60KB budget) → injected as <system-reminder> attachments.
End of turn → forked agent with restricted tools (Read/Grep/Glob + write only in memory dir) → pre-injected manifest → updates topic files + MEMORY.md. Throttled to every N turns. Skipped if main agent already wrote.
Time gate (24h) + session gate (5) + PID lock → forked dream agent → reviews logs → merges into topic files → prunes MEMORY.md.
Periodic background sub-agent → extracts key session info into .session/memory.md → triggered at ~30K token init, ~20K between updates. Within-session only.
SYSTEM_PROMPT_DYNAMIC_BOUNDARY — cache scope splitContent before the boundary is globally cacheable (shared across users). Content after (your CLAUDE.md, memory) is re-processed every API call.
Can block (exit code 2): PreToolUse, PermissionRequest, UserPromptSubmit, Stop, SubagentStop, TaskCreated, TaskCompleted, ConfigChange, Elicitation, WorktreeCreate, TeammateIdle
Informational: PostToolUse, PostToolUseFailure, SessionStart, SessionEnd, Notification, SubagentStart, CwdChanged, FileChanged, PreCompact, PostCompact, InstructionsLoaded, WorktreeRemove, Setup, PermissionDenied, ElicitationResult, StopFailure
Lowest to highest priority:
userSettings: ~/.claude/settings.jsonprojectSettings: .claude/settings.json (shared, committed)localSettings: .claude/settings.local.json (gitignored)flagSettings: --settings CLI flagpolicySettings: managed (remote API → MDM → managed-settings.json → drop-ins)Arrays are concatenated and deduplicated. Objects are deep-merged. Scalars: higher priority overwrites.
| Gate | Purpose |
|---|---|
KAIROS | Daily log mode (perpetual sessions) |
TEAMMEM | Team memory (shared via VCS) |
tengu_passport_quail | Enable memory extraction |
tengu_bramble_lintel | Throttle extraction frequency |
tengu_onyx_plover | Dream scheduling thresholds |
tengu_moth_copse | Skip MEMORY.md index in extraction prompt |
| Key | Type | Purpose |
|---|---|---|
autoMemoryEnabled | boolean | Toggle auto memory (default: true) |
autoMemoryDirectory | string | Custom path (supports ~/). Ignored in projectSettings for security. |
autoDreamEnabled | boolean | User override for dream consolidation |
claudeMdExcludes | string[] | Glob patterns to skip CLAUDE.md files |
disableAllHooks | boolean | Kill switch for all hooks |