Claude Code Hook Blocks Edit Unexpectedly
A PreToolUse hook keeps rejecting Edit calls with no clear reason, including safe edits. Usually exit-code logic, stdin parsing, or matcher scope at fault.
Agent loops, wrong-file edits, lost context, multi-agent conflicts, rollbacks, Plan mode issues.
Claude Code / Codex agent workflow failures are rarely "the model is weak" — usually "wrong context" or "too-broad permission." Articles here group by real failure mode: agent loops, wrong-file edits, lost context, broken Plan mode, multi-agent conflicts, messy rollbacks, scattered changes. One symptom, shortest fix path.
A PreToolUse hook keeps rejecting Edit calls with no clear reason, including safe edits. Usually exit-code logic, stdin parsing, or matcher scope at fault.
MCP tool calls (filesystem, GitHub, custom) time out in Claude Code, but a direct curl to the server works. Usually transport, stdio framing, or response shape.
A long agent reply gets cut off mid-sentence under context pressure. Usually compaction, max_tokens cap, or runaway tool output eating the budget.
You edited ~/.claude/settings.json but Claude Code ignores hooks, permissions, or env on restart. Usually JSON syntax, wrong scope, or shadowed precedence.
You dropped a skill under ~/.claude/skills/ but /<name> says not found, or it never auto-fires. Usually a SKILL.md frontmatter, path, or trigger-description issue.
Your Task/Agent subagent completed cleanly, but the main session shows nothing or a wrong summary. Usually a final-message format, context-window, or thread-routing issue.
Claude Code refuses to run a command you whitelisted — the Bash sandbox rejects it as unsafe or unapproved. Diagnose permission scope, pattern match, and settings.json wiring.
Claude Code starts a session but ignores your project CLAUDE.md — conventions, commands, and instructions never reach the model. Diagnose path, scope, and merge precedence.
You resume a Claude Code session and it acts like a fresh start — forgetting the plan, the decisions, the half-finished refactor. Diagnose snapshot scope, compaction, and memory layers.
Your Claude Code statusline shows an error, stays blank, or freezes the prompt — the custom script is failing silently. Diagnose exit codes, output format, and timeout limits.
Every Bash, Edit, Read asks for permission again even after you allowed the same tool — settings.json scope wrong, allowlist pattern too narrow, or hook is re-asking.
Single task burns 200K+ tokens, hits the context ceiling mid-execution, and forces a summarize. Decompose the task, use sub-agents, or scope reads tighter.
Bash command runs forever, the agent waits forever — no timeout set means a hung process locks the whole session. Set timeouts, detect hangs, kill cleanly.