
Writing a Claude Code Book with Claude Code: When PostToolUse Hooks Loop 25 Times
Misconfigure a single Claude Code hook and you get an agent that loops 25 times. This is what happened while writing a book about Claude Code using Claude Code. Out of 26 sessions and 147 tool calls, exactly three sessions produced anything useful. TL;DR : PostToolUse hooks trigger on the agent's own tool usage, not just the user's. Without a loop guard, the same task repeats dozens of times. Automating book research with AI is possible, but hook design comes first. Automating Market Research with a PostToolUse Hook Before writing the book, I needed market research. How many Claude Code-related books existed domestically and internationally? Were there courses on platforms like Inflearn or Leanpub? Instead of doing this manually every time, I decided to automate it with Claude Code's PostToolUse hook. The idea was simple: after any work task completes, a market research agent automatically kicks in. I created a /agent-business slash command and configured it to trigger on the PostToolU
Continue reading on Dev.to
Opens in a new tab

