~/codigoagente
AI agents

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:

EventWhen it runsCan block
`SessionStart`When the session opensNo
`UserPromptSubmit`Before Claude reads your messageYes
`PreToolUse`Before a tool runs (Bash, Edit…)Yes (exit code 2)
`PostToolUse`After it runsNo, but it returns warnings
`PreCompact`Before context compactionNo
`Stop` / `SessionEnd`After each reply or at session endNo

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:

terminalsh
npx ecc-universal@2.2.3 install --profile core --target claude --enable-hooks
28 hooks across 8 events after installing the core profile · codigoagente

The most useful ones per its docs (hooks/README.md):

  • Before Bash: blocks npm run dev outside tmux so logs are not lost, reminds you to review before git push, and runs checks before git commit (lint of staged files, message format, leftover console.log).
  • After edits: formats with Prettier, runs tsc --noEmit on .ts files and warns about console.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):

snippettext
Change server.js so the port comes from process.env.PORT, defaulting to 3000. Then run npm test.
GateGuard denied the first edit; once justified, it passed and all 19 tests stayed green · codigoagente

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:

terminalsh
export ECC_GATEGUARD=off

Control hooks without editing JSON

ECC reads environment variables to tune its hooks:

terminalsh
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=off

minimal 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).

snippetyaml
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
scope: project

Since 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:

CommandWhat 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.json into settings.json. Remove them from settings.json.
  • npm run dev blocked: 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_CHARS or set ECC_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

Repository in this article
The code this article covers is public: browse it, star it or clone it from here.

Help us grow

codigoagente is free, with no paywalls. If this article helped you, any of these keeps the blog going.

// newsletter

One email a week with the repos worth your time

The week's new articles, tested against real code. No spam; unsubscribe in one click.

rea-video is an Apache-2.0 skill that breaks a video down shot by shot: filmed, AI or code, voice, music, captions and how to remake it. Real test and costs.
  • Skills for your agents
  • Claude Code
read article
AI agents

guide · Marketing psychology guide for AI agents · #3

Part 3 of the guide: anchoring, decoy, paradox of choice, Hick's Law and activation energy applied to the pricing page, with examples from the codigoagente kit.
  • Skills for your agents
  • Claude Code
read article
AI agents

guide · Marketing psychology guide for AI agents · #2

Part 2 of the guide: authority, commitment, real scarcity and framing with the marketing-psychology skill, with real before/after fragments from codigoagente.
  • Skills for your agents
  • Claude Code
read article