Writing a Claude Code Book with Claude Code: When PostToolUse Hooks Loop 25 Times
Dev.to AI
•
Generative AI
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.