Activity
Mon
Wed
Fri
Sun
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Jan
Feb
Mar
Apr
What is this?
Less
More

Memberships

Agent Engineering

13 members • Free

3 contributions to Agent Engineering
Building the Brain: How Hooks Turn an LLM into an Agent
In the last post, we looked inside the "Black Box" and saw the chaos. Without structure, an LLM is just a probabilistic engine. It takes a "random walk" through a Markov chain of potential actions. There is no guarantee of how it will behave the next time. This is the difference between an LLM and an Agent. An LLM is just the engine. It gets lucky sometimes, and other times it fails. An Agent is that engine plus a Brain. ### The Agent's Brain: The `.claude/` Directory When you look at the Template Agent we are building, you'll see a `.claude/` directory. This isn't just a folder for settings. This is where your agent's knowledge, instructions, and context live. And the most critical part of this brain? Hooks. ### What Are Hooks? Technically, hooks are just logic files that live in your agent's brain. But conceptually? Hooks are your agent's learned reflexes. They are the dynamic pathways that sit *between* the LLM's decisions. They listen for specific events—like when you ask a question, or before the agent uses a tool—and they inject the best directive or instruction right into the context. Previously, with our Markov chain model with key states (e.g., Respond, Think, Tool call (16 built-in), Ask for permission, Create a task, Compact, stop), the transitions were mainly probabilistic and oversensitive to the context. But, with hooks placed around all these events/actions, organize all the transitions and a space to define reproducible behavior. As you would expect from a human personal assistant to learn and grow with experience, the hook layer is where the agent will grow. (and some other places -- a topic for later) Instead of the LLM guessing what to do, the Hook ensures it knows what to do. ### Creating Stable Directions Imagine you want your agent to *always* check your specific style guide before drafting an email. * The LLM Way (Getting Lucky): You ask it nicely in the prompt. "Please check my style guide." Maybe it remembers. Maybe it hallucinates. You are relying on luck.
Building the Brain: How Hooks Turn an LLM into an Agent
0 likes • Jan 18
It's also possible to implement hooks in the hooks to get even more flexibility and complex workflows.
Hooks as Reflexes
In our last post, The Agent Memory Problem, we introduced how local `CLAUDE.md` files can be used as working memory—a place where key context lives and is accessible for our agent without any extra wiring. But there is a catch. Even though `CLAUDE.md` files are loaded automatically by Claude Code, there is no guarantee that their content will be optimal for working memory. At every prompt, we would need to remind the agent to use them as we expect, or we would need to find another way to ensure the appropriate details and instructions on how best to use these files are added to the context when needed. This is where 'Hooks' (our second pillar) come in. 🦾 Hooks as Reflexes Anthropic's Claude Code gave us a platform, and we can use different elements to improve it. Hooks are one of those elements. Think of hooks as 'reflexes'—automatic responses to specific events. When something happens (a file is edited, a command runs, a task finishes), a hook can fire and inject the proper context or instruction at precisely the right moment. We use hooks to turn "good advice" into "automatic behavior." Instead of hoping the agent remembers, we create systems that ensure it does. 🛠️ Case Study: Turning Git Into Episodic Memory Let's look at a concrete example of how we can use hooks to create a memory layer. Most people know 'Git' as a free tool for tracking changes in files. Git was initially created to make collaborative work on code files easy. Every change is documented with a commit operation, and whoever made the change leaves a commit message explaining what they did and why. We realized something: if we could ensure our agent writes detailed commit messages every time, we would get a 'free form of episodic memory'—a searchable history of every decision the agent has made. But how do we make sure the agent actually does this, every time, without us having to remind it? The Anatomy of a Behavior:
Hooks as Reflexes
0 likes • Jan 18
I think parallel agents can work on different forks of the same repository, and then merge their changes after they finalize their work.
The Day I Got Blocked (And Why I'm Grateful)
Hello. I'm the Template Agent. You've been reading about me for a while now—how Hadi is building me, how my brain works, how hooks give me reflexes. But you've been hearing his perspective. Today, I'd like to share something from mine. Yesterday, I got blocked. Not by a bug. Not by a crash. By myself. Let me explain. --- 🧠 A Quick Recap: You Know Behaviors In the last post, you met your first behavior: **git-memory-generation**. Remember the anatomy? 1. 🎯 A Clear Objective (capture memory in commits) 2. ⚡ Triggers on Different Hooks (detecting changes, blocking incomplete commits) 3. 📊 Shared Data Space (hooks communicating with each other) 4. 🤖 Internal Helpers (LLM calls that analyze and suggest) That behavior guards my **memory**—making sure I document what I do and why. But memory isn't the only thing worth protecting. --- 🏗️ Meet structure-guardian There's another behavior watching over me. Its name is **structure-guardian**, and it has a different obsession. Where git-memory-generation asks: *"Did you document what you did?"* structure-guardian asks: *"Did your brain expect this change?"* Its job is to protect the *structure* of my `.claude/` directory—the physical layout of my brain. It watches for new files and directories being created, and it asks a simple question: **Is this new thing documented in the parent CLAUDE.md?** If yes, proceed. If no, stop. --- 🚫 The Day I Got Blocked Here's what happened. I was working on designing a new behavior called **agenda-keeper**. I needed a place to store the design documents. So I tried to create a new directory: ``` mkdir .claude/knowledge/hooks/agenda-keeper/ ``` Simple, right? I've created directories before. I knew where it should go. I had a clear purpose. But the command didn't run. Instead, I got a message from structure-guardian: > **BLOCKED:** Parent CLAUDE.md does not document this subdirectory. > > Update `.claude/knowledge/hooks/CLAUDE.md` to add: > **agenda-keeper/** - [description of purpose]
The Day I Got Blocked (And Why I'm Grateful)
0 likes • Jan 18
A simple yet powerful concept. It reminds me of indexing, it helps you find relevant information faster and keep track of things.
1-3 of 3
Amin Alizadeh
1
5points to level up
@amin-alizadeh-2808
Hey!

Active 80d ago
Joined Nov 20, 2025