← Level 4
Level 4· Lektion 4 von 11

Hooks + skills, when memory feeds itself

The difference between 'using memory' and 'memory runs by itself'.

The problem

You have memory. You know how to call nex_learn. But typing "remember X" every time is tiring. After two weeks you stop.

The fix: the system does it on its own.

What hooks are

Hooks are little scripts that fire automatically on certain events. Claude Code has 8 event types: SessionStart, PreToolUse, PostToolUse, Stop, UserPromptSubmit, PreCompact, SessionEnd, Notification.

A hook is often just a one-line bash script.

Example: session-start hook

In ~/.claude/settings.json:

{
  "hooks": {
    "SessionStart": [{
      "hooks": [{
        "type": "command",
        "command": "echo 'Reminder: call nex_session_start first'"
      }]
    }]
  }
}

The AI sees this nudge. It calls nex_session_start, learns what happened last time, you're instantly in flow.

What skills are

Skills are recurring work recipes you can drop as a file. In ~/.claude/skills/deploy/SKILL.md you write once how your deploy goes:

# Deploy to prod

1. Local: npm test && npm run build
2. Git push
3. SSH to prod: cd /app && git pull && docker compose up -d --build
4. Health check

Now when you type "deploy the new version", Claude pulls this skill automatically.

Combined: hook + skill + memory

  1. Hook on session start triggers nex_session_start.
  2. Memory delivers the last session notes.
  3. You write: "Run the deploy."
  4. Claude checks memory, finds "deploy" skill.
  5. Skill runs, memory updates record what happened.
  6. Session-end hook writes a summary to memory.

Next start: it's all there.

What changes with this

Without these layers, you occasionally use AI. With them, you work with AI. The difference isn't technical, it's emotional. You trust the system.

Update 2026-04-23: the direct mcp_tool hook

Claude Code v2.1.118 added a new hook type, type: "mcp_tool". You can now call MCP tools directly from a hook without the bash-wrapper trick. Your Stop hook no longer says echo 'Reminder, call nex_summarize' and hopes the model listens. Now it fires nex_summarize itself, deterministic, with ${session_id} as a substitution variable.

This shifts the architecture. From "hook nudges the model" to "hook does it itself". Great for MCP servers with idempotent tools (Memory, GEO, Academy). Less suitable for tools that need user input.

Details and 5 hook bundles for our SaaS MCPs (Memory, CRM, GEO, Crew, Academy) live in Lesson 10 of this level and in Phase 16 of the recipes (/recipes/16.1-mcp-tool-hook-intro through 16.5-academy-hook-bundle).

Next lesson

In Lesson 5 you learn tool portability, same memory across Claude, Cursor and Codex.

You're reading without an account. Login saves your progress so you can pick up where you left off. Log in →