Context rot — the gradual degradation of an agent’s working memory as a session grows — is one of the most common sources of wasted tokens and failed tasks. ECC addresses this at the infrastructure level: a SQLite state store records each session’s lifecycle, skill runs, architectural decisions, and linked work items. When you start a new session, the context from your last session is available immediately rather than reconstructed from memory.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/affaan-m/ECC/llms.txt
Use this file to discover all available pages before exploring further.
Session Lifecycle
Every ECC-managed session moves through a defined lifecycle driven by hooks:-
SessionStart — The
session-start.jshook fires when Claude Code opens a new session. It loads context from the previous session snapshot, injects learned instincts (up toECC_MAX_INJECTED_INSTINCTS, default 6), and primes the agent with project context. Context loading is bounded:ECC_SESSION_START_MAX_CHARScaps the injected text at 8,000 characters by default. - Work phase — The agent works, producing tool calls, file edits, and decisions recorded in the session transcript.
-
PreCompact — Before Claude Code compacts the context window, the
pre-compact.jshook saves important state to a file so the compacted session retains situational awareness. -
Stop — When the session ends, the
session-end.jshook persists a session summary to~/.claude/session-data/. Theevaluate-session.jshook extracts patterns from the session and feeds them to the continuous learning system.
CLI Commands for Session Management
All session management commands are available through thenpx ecc CLI:
Session Resume Pattern
ECC provides/save-session and /resume-session commands for explicit, human-readable session handoffs. These work independently of the automatic hook-based persistence — they are for intentional, structured context capture.
Saving a Session
Run/save-session at the end of a work session or before hitting context limits. The command gathers context from the conversation, reads all modified files, and writes a structured snapshot to ~/.claude/session-data/YYYY-MM-DD-<short-id>-session.tmp:
- What We Are Building — project context and goal
- What WORKED (with evidence) — confirmed working items
- What Did NOT Work (and why) — failed approaches with exact reasons
- What Has NOT Been Tried Yet — queued approaches
- Current State of Files — per-file status table
- Decisions Made — architectural choices and rationale
- Blockers & Open Questions — unresolved items
- Exact Next Step — precise starting point for the next session
Resuming a Session
Start any new session with/resume-session to load the previous session’s context before doing any work:
Bounded Context Loading
Session context injection atSessionStart is bounded by two environment variables to prevent stale sessions from consuming the entire context window:
ECC_SESSION_RETENTION_DAYS (default: 30). Set to 0, off, false, disabled, never, or none to keep all session files:
Install-State Tracking
ECC records what was installed, when, and how in its SQLite state store. This powersnpx ecc doctor (which detects drift) and npx ecc repair (which restores missing files without a full reinstall):
- Modules installed and their resolved paths
- Target harness and profile used
- Operations applied (copy, write, merge)
- Timestamp of install
npx ecc list-installed, then npx ecc doctor and npx ecc repair before reinstalling anything. This usually restores ECC-managed files without rebuilding your entire setup.
Decision Log
ECC session snapshots include an explicit decisions section. When the agent makes an architectural choice — selecting a library, accepting a tradeoff, choosing one approach over another — that decision and its rationale should be recorded before moving on. This prevents the next session from relitigating settled choices. Session file format for decisions:Example: npx ecc sessions Output
Continuous Learning Integration
The session stop hook runsevaluate-session.js, which extracts reusable patterns from the session transcript and feeds them to the continuous learning v2 system. Extracted patterns become instincts — high-confidence, reusable knowledge pieces that are injected at the start of future sessions.
Manage instincts directly: