Hooks, memory and continuous learning in ECC: Claude Code sessions that remember
ECC's hooks are commands Claude Code runs on its own at fixed moments (session start, before editing a file, before compaction, at the end) to check quality, save state and learn from what you do. The core profile registers 28 of them; /save-session and /resume-session let you pick up the next day, and continuous learning turns your corrections into "instincts".
This is part 6 of the complete ECC guide. Below: which hooks it installs, a real test of GateGuard (the hook that forces the agent to think before editing), how memory across sessions works and when continuous learning is worth turning on.
What a hook is (and why it beats a prompt)
A prompt asks the model for something; a hook enforces it. It is a command that runs outside the model on a Claude Code event:
| Event | When it runs | Can block |
|---|---|---|
| `SessionStart` | When the session opens | No |
| `UserPromptSubmit` | Before Claude reads your message | Yes |
| `PreToolUse` | Before a tool runs (Bash, Edit…) | Yes (exit code 2) |
| `PostToolUse` | After it runs | No, but it returns warnings |
| `PreCompact` | Before context compaction | No |
| `Stop` / `SessionEnd` | After each reply or at session end | No |
Because hooks run commands on your machine, ECC will not enable them silently: if a profile includes them and you pass neither --enable-hooks nor --no-hooks, the installer stops.
The 28 hooks in the core profile
We installed the core profile with hooks into an empty HOME and counted what was registered in ~/.claude/settings.json:
npx ecc-universal@2.2.3 install --profile core --target claude --enable-hooksThe most useful ones per its docs (hooks/README.md):
- Before Bash: blocks
npm run devoutside tmux so logs are not lost, reminds you to review beforegit push, and runs checks beforegit commit(lint of staged files, message format, leftoverconsole.log). - After edits: formats with Prettier, runs
tsc --noEmiton.tsfiles and warns aboutconsole.log. - Lifecycle: loads previous context at start, saves state before compaction and summarizes the session at the end.
Real test: GateGuard stops the first edit
The most striking hook is GateGuard ("Fact-Forcing Gate"). The first time the agent edits a file in a session, it denies the edit and asks the agent to state which code depends on the change and what your verbatim instruction was. Only then does it let the edit through.
We asked for a trivial change on the API from part 3 with ECC's hooks active (prompt in Spanish):
Change server.js so the port comes from process.env.PORT, defaulting to 3000. Then run npm test.Result: the first Edit was denied, the agent justified the change, retried and passed; the 19 tests stayed green. It took 17.5 seconds and the CLI reported 0.08 USD. The agent said so itself at the end: the first edit was blocked by a hook that asked to justify the change.
Is it worth it? ECC's CHANGELOG is candid: in its 72-session pilot the gate cost about 45% more turns and could not measure whether it improves results, because every variant solved every task. Our take: keep it for sensitive files (auth, payments, migrations, CI workflows), where ECC already applies it more strictly, and turn it off if it gets in your way:
export ECC_GATEGUARD=offControl hooks without editing JSON
ECC reads environment variables to tune its hooks:
export ECC_HOOK_PROFILE=standard # minimal | standard | strict
export ECC_DISABLED_HOOKS="pre:bash:tmux-reminder,post:edit:typecheck"
export ECC_SESSION_START_MAX_CHARS=4000 # less context at start
export ECC_CONTEXT_MONITOR_COST_WARNINGS=offminimal keeps only essential lifecycle and safety hooks; strict adds more reminders. With the plugin, change the profile via npx ecc-universal@2.2.3 setup --mode claude-plugin.
Memory across sessions: /save-session and /resume-session
/save-session writes a dated file to ~/.claude/session-data/ (for example 2026-11-22-a1b2c3d4-session.tmp) with what was built, what worked, what failed and what is left. The command requires every section to be filled, even with "Nothing yet", because "an incomplete file is worse than an honest empty section".
The next day, /resume-session loads the most recent one and you continue where you left off. Use it:
- When you close Claude Code at the end of the day.
- Before hitting the context limit: save, open a new session and resume.
- After solving something hard you want to remember.
Continuous learning: from corrections to instincts
The continuous-learning-v2 skill watches your sessions through hooks and extracts instincts: small behaviors with a trigger, an action and a confidence between 0.3 (tentative) and 0.9 (near certain).
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
scope: projectSince v2.1 they are per project (your React app's patterns do not leak into your Python one) and get promoted to global once they show up in 2 or more projects. The commands:
| Command | What it does |
|---|---|
| `/instinct-status` | Lists project and global instincts with their confidence |
| `/evolve` | Clusters instincts and proposes new skills, commands or agents |
| `/promote` | Moves project instincts to global |
| `/prune` | Deletes pending instincts older than 30 days that were never promoted |
| `/learn-eval` | Extracts a pattern from the session, evaluates it and decides global vs project |
Two caveats: the background observer ships disabled (observer.enabled: false) and does not work on native Windows (it needs WSL2, Linux or macOS). Start with a manual /learn-eval at the end of a productive session; turn on the observer only once you see it pays off.
Common mistakes
- Duplicated hooks: you have the plugin and also copied
hooks.jsonintosettings.json. Remove them fromsettings.json. npm run devblocked: that is the hook that prevents dev servers outside tmux, so the agent can read the logs. Start it inside tmux, as the warning asks.- Slow or heavy session starts: lower
ECC_SESSION_START_MAX_CHARSor setECC_SESSION_START_CONTEXT=off.
Conclusion
Hooks are what turn ECC's rules into habits that enforce themselves, and /save-session is the cheapest way to avoid starting from zero every morning. Enable the standard profile, try GateGuard for a week and decide. Part 7 covers measuring and trimming the context all of this takes up.
// source code
Help us grow
codigoagente is free, with no paywalls. If this article helped you, any of these keeps the blog going.
- Share it with someone who'll find it usefulWhatsAppLinkedInXFacebook
- Meet our sponsorSafe Build Labs
More on AI agents

- Skills for your agents
- Claude Code

guide · Marketing psychology guide for AI agents · #3
- Skills for your agents
- Claude Code

guide · Marketing psychology guide for AI agents · #2
- Skills for your agents
- Claude Code