Claude Code talks too much. A 150-word hook fixed it
But read its replies for a day and you notice something. After every single answer comes a wall of text: a long recap, a summary block, a list of what’s untested, a question with three options.
And here is what that actually looks like:
One line asked. A wall of text back.
So you say “be concise”. And it overcorrects to the other extreme:
From a wall of text to nothing at all. Neither tells me where I stand.
To be fair, part of that wall of text was my own doing. My global CLAUDE.md asked for an executive summary on every answer. After a few weeks it had turned into boilerplate: the same six headings under every reply, half of them saying “nothing”.
Rules in CLAUDE.md are fine. They just fade
Rules in CLAUDE.md or AGENTS.md are good. Claude reads them at the start of every session and agrees with every word.
But the longer the conversation runs, the less they count. The rule sits at the very top, and there are hours of chat between it and the reply Claude is writing now. I wrote about this in a previous post: long sessions forget.
And even a fresh rule doesn’t always hold. Here’s a real one from this week, deep into a long session. I set a rule in plain words, Claude confirmed it, and a few minutes later:
It agreed. Then it did it anyway.
A rule written once, hours ago, is advice. What works is a rule that’s there again at the moment Claude writes the reply.
What a hook is
A hook is a small script that Claude Code runs on its own at fixed moments. It doesn’t matter what the model remembers. The harness runs it every time.
You set hooks up in ~/.claude/settings.json. Each one belongs to an event, for example:
UserPromptSubmitruns when you send a message, before Claude reads itPreToolUseruns before Claude uses a tool, and can block itStopruns after Claude has finished its reply, and can send it back
So the question is: which moment do you pick to enforce how Claude answers?
Why the Stop hook was the wrong choice
In a previous post I picked Stop for my job report check. Later I added a second Stop hook for length: it read every finished reply, and if it was over 2,000 characters it blocked it with “Rewrite the same answer in at most 2,000 characters.”
It sounds strict. It’s actually expensive.
The reply is already written when the hook sees it. Rejecting it means Claude writes the whole answer a second time.
I went through my own Claude Code history and counted. Between 9 and 16 October, that hook blocked a reply 42 times:
- about 99,000 characters of finished replies were thrown away and written again
- the rejected replies averaged 2,364 characters, the rewrites 1,677
- 34 of the 42 rewrites were still over 1,500 characters. Shorter, but still a wall.
- 2 rewrites still broke the limit and got through anyway, because the hook only allows one retry
So I paid for every long answer twice and still read long answers.
And there’s a deeper problem. A Stop hook only says what’s wrong (“too long”). It never says what a good reply looks like. So Claude guesses, and the guess is usually “the same thing, a bit shorter”.
A Stop hook punishes after the fact. What I needed was a reminder before.
Remind it in the request instead
The fix is the other end of the turn. A UserPromptSubmit hook runs every time I send a message. It can add text to my message before Claude sees it.
So the reply rule now rides along with every single message. It can’t fade, because it’s never more than one message old.
The prompt hook can’t force anything. It’s free when the rule is followed, and it tells Claude what good looks like every time.
The rule itself is short. It picks one of two shapes:
- you only asked a question: the answer first in one plain line, then a few short bullets only if they help, no table, no summary
- Claude did work: one short table and nothing else, with the rows Worked, Did not work, Blockers and Next, each cell at most 20 words
Why a table for work? It puts the bad news in fixed rows. “Did not work” and “Blockers” are always there, so they can’t be skipped or buried at the end of a paragraph.
What it looks like now
A question, answered with the hook on:
The answer comes first. The detail comes after, and it stops.
A small task, with the hook on:
The part I care about most is the second row. Claude fixed the bug but couldn’t run the check, and it said so right away, in a row that’s always there.
Both replies are real output from claude -p runs with the hook below, on a tiny demo file. The amber hook line is drawn in for clarity: Claude Code doesn’t print it.
The Limitations
Before you install it, a few honest caveats:
- It reminds, it doesn’t enforce. Nothing blocks a reply that ignores the rule. In my tests Claude followed it, but a long, messy session can still drift.
- Claude decides which case applies. A question that needs a quick file read may come back as a table.
- It costs a little on every message. The rule is about 150 words, so roughly 200 tokens added to each message you send. That’s still far less than rewriting a 2,000-character reply.
- The question answers can still run long. My test answer had four bullets, one of them about something I hadn’t asked.
- I only tested it with
claude -pin a terminal, a handful of times. Not yet over a full day of real work.
The Bottom Line
I used to think enforcement had to come after the reply. Check it, block it, make the agent fix it.
For reply format, that’s backwards. The cheapest moment to shape a reply is before it’s written. A reminder costs a few tokens. A rewrite costs the whole reply.
Remind before. Don’t punish after.
The exchanges in the screenshots are reconstructed from my real sessions and anonymized; the wording is shortened, the situations are real. The numbers come from my own Claude Code history, counted once per blocked reply.
Reference — everything to copy
1. What you need
- Claude Code (CLI or desktop app)
jq(brew install jqon macOS,sudo apt install jqon Debian/Ubuntu)- macOS or Linux with bash
2. Install with one paste
Paste this whole block into a terminal. It writes the hook script, backs up your ~/.claude/settings.json, makes this the only hook in it, keeps every other setting, and prints OK if the script works.
/dev/null || { echo "jq is missing: install it first (brew install jq)"; exit 1; }
mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/table-report.sh </dev/null
jq -n –arg c 'REPLY FORMAT (mandatory, every reply). Pick one of two cases.
CASE 1 – the user only asked something and you did no work (no edits, no runs, no results produced): answer short and structured: the answer first in one plain line, then a few short bullets only if they help. Plain words, no table, no headings, no executive summary.
CASE 2 – you did work and produced results (edited, ran, tested, built, committed): answer ONLY with one short table, nothing before or after it. Rows, in this order: Answer (only if the user asked a question; one plain sentence) | Worked | Did not work | Blockers | Next. Each cell at most 20 words, plain words, no code, no file paths unless asked, no jargon. Blockers = only things that stop THIS task. Write "none" if a row is empty. This table is the whole reply and replaces the executive summary.'
'{hookSpecificOutput:{hookEventName:"UserPromptSubmit",additionalContext:$c}}'
EOF
chmod +x ~/.claude/hooks/table-report.sh
S=~/.claude/settings.json
[ -f "$S" ] || echo '{}' > "$S"
cp "$S" "$S.bak-$(date +%Y%m%d-%H%M%S)"
jq '.hooks = {"UserPromptSubmit":[{"hooks":[{"type":"command","command":"$HOME/.claude/hooks/table-report.sh"}]}]}' "$S" > "$S.tmp" && mv "$S.tmp" "$S"
echo '{}' | ~/.claude/hooks/table-report.sh | jq -e '.hookSpecificOutput.hookEventName == "UserPromptSubmit"' >/dev/null && echo OK” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>
set -e
command -v jq >/dev/null || { echo "jq is missing: install it first (brew install jq)"; exit 1; }
mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/table-report.sh <<'EOF'
#!/bin/bash
# UserPromptSubmit: appends the reply-format rule to every message the user sends.
cat >/dev/null
jq -n --arg c 'REPLY FORMAT (mandatory, every reply). Pick one of two cases.
CASE 1 - the user only asked something and you did no work (no edits, no runs, no results produced): answer short and structured: the answer first in one plain line, then a few short bullets only if they help. Plain words, no table, no headings, no executive summary.
CASE 2 - you did work and produced results (edited, ran, tested, built, committed): answer ONLY with one short table, nothing before or after it. Rows, in this order: Answer (only if the user asked a question; one plain sentence) | Worked | Did not work | Blockers | Next. Each cell at most 20 words, plain words, no code, no file paths unless asked, no jargon. Blockers = only things that stop THIS task. Write "none" if a row is empty. This table is the whole reply and replaces the executive summary.'
'{hookSpecificOutput:{hookEventName:"UserPromptSubmit",additionalContext:$c}}'
EOF
chmod +x ~/.claude/hooks/table-report.sh
S=~/.claude/settings.json
[ -f "$S" ] || echo '{}' > "$S"
cp "$S" "$S.bak-$(date +%Y%m%d-%H%M%S)"
jq '.hooks = {"UserPromptSubmit":[{"hooks":[{"type":"command","command":"$HOME/.claude/hooks/table-report.sh"}]}]}' "$S" > "$S.tmp" && mv "$S.tmp" "$S"
echo '{}' | ~/.claude/hooks/table-report.sh | jq -e '.hookSpecificOutput.hookEventName == "UserPromptSubmit"' >/dev/null && echo OK
set -e
command -v jq >/dev/null || { echo "jq is missing: install it first (brew install jq)"; exit 1; }
mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/table-report.sh <<'EOF'
#!/bin/bash
# UserPromptSubmit: appends the reply-format rule to every message the user sends.
cat >/dev/null
jq -n --arg c 'REPLY FORMAT (mandatory, every reply). Pick one of two cases.
CASE 1 - the user only asked something and you did no work (no edits, no runs, no results produced): answer short and structured: the answer first in one plain line, then a few short bullets only if they help. Plain words, no table, no headings, no executive summary.
CASE 2 - you did work and produced results (edited, ran, tested, built, committed): answer ONLY with one short table, nothing before or after it. Rows, in this order: Answer (only if the user asked a question; one plain sentence) | Worked | Did not work | Blockers | Next. Each cell at most 20 words, plain words, no code, no file paths unless asked, no jargon. Blockers = only things that stop THIS task. Write "none" if a row is empty. This table is the whole reply and replaces the executive summary.'
'{hookSpecificOutput:{hookEventName:"UserPromptSubmit",additionalContext:$c}}'
EOF
chmod +x ~/.claude/hooks/table-report.sh
S=~/.claude/settings.json
[ -f "$S" ] || echo '{}' > "$S"
cp "$S" "$S.bak-$(date +%Y%m%d-%H%M%S)"
jq '.hooks = {"UserPromptSubmit":[{"hooks":[{"type":"command","command":"$HOME/.claude/hooks/table-report.sh"}]}]}' "$S" > "$S.tmp" && mv "$S.tmp" "$S"
echo '{}' | ~/.claude/hooks/table-report.sh | jq -e '.hookSpecificOutput.hookEventName == "UserPromptSubmit"' >/dev/null && echo OK
Then start a new Claude Code session. A session that’s already running doesn’t pick up the hook.
3. Keep your safety hooks
The install replaces all your hooks, so nothing else can clash with the reply rule. If you have safety hooks (for example, blocking dangerous commands), keep them: skip the jq '.hooks = …' line and add this entry next to your existing hooks by hand.
"UserPromptSubmit": [
{
"hooks": [
{ "type": "command", "command": "$HOME/.claude/hooks/table-report.sh" }
]
}
]
"UserPromptSubmit": [
{
"hooks": [
{ "type": "command", "command": "$HOME/.claude/hooks/table-report.sh" }
]
}
]
Do remove any other hook that checks reply length or format, like the old Stop hook. Two reply rules pull against each other.
4. Test it
claude -p "what is the difference between a hook and a skill in claude code?"
claude -p "count the files in this folder and tell me"
claude -p "what is the difference between a hook and a skill in claude code?"
claude -p "count the files in this folder and tell me"
The first should come back as a short answer with a few bullets. The second should be one table.
5. Change the rule
Edit the text between the single quotes in ~/.claude/hooks/table-report.sh, without using a single quote inside it. Check it still works:
echo '{}' | ~/.claude/hooks/table-report.sh | jq .
echo '{}' | ~/.claude/hooks/table-report.sh | jq .
The change applies to the next message you send.
6. Remove it
rm ~/.claude/hooks/table-report.sh
rm ~/.claude/hooks/table-report.sh
Then delete the UserPromptSubmit entry from ~/.claude/settings.json, or restore the backup the install made (~/.claude/settings.json.bak-<date-time>).

