Claude Code Complete Guide: Hooks, Agents, MCP Tools & Professional Development
A LinkedIn-hosted PDF guide to Claude Code hooks, subagents, MCP tools and custom slash commands. It covers the hook configuration in .claude/settings.json, the event payloads (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart), and exit code 2 as the way to block an action. It includes worked examples of safety hooks: a regex-based PreToolUse script that blocks rm -rf, curl piped to a shell, chmod 777 and privileged Docker containers. Other examples are audit logging, TDD enforcement and session context loading. Useful as a practical reference for putting deterministic guardrails around an AI coding agent, though the regex blocklists are easy to bypass.
What it is
A LinkedIn-hosted PDF, "Claude Code Complete Guide: Hooks, Agents, MCP Tools & Professional Development". The fetched text covers sections 1-8 and cuts off mid-table in the cheat sheet. The Security Considerations, MCP, sub-agent and slash-command chapters listed in the table of contents are not in the fetched text. Everything below comes from the visible part.
What to do
Configuration facts a reader would otherwise have to look up:
- Project hooks live in
.claude/settings.json. User-global hooks live in~/.claude/settings.json. - Settings load at startup, so restart Claude Code after editing.
- The guide recommends absolute script paths when a hook doesn't fire, and
chmod +x .claude/hooks/*.py. matchertakes regexes, for exampleEdit|MultiEdit|Write. An empty string matches all tools.- A hook command accepts
"timeout": 5. Appending&runs non-critical hooks in the background. - Hooks run synchronously.
- To see real payloads before writing logic, log them with this PreToolUse command:
jq '.' >> .claude/hooks/log.jsonlThe cheat sheet's blocking table:
| Event | Can block? |
|---|---|
| PreToolUse | Yes (exit 2) |
| SubagentStop | Yes (exit 2) |
| UserPromptSubmit, SessionStart, PostToolUse, Notification, Stop, PreCompact | No |
Caveats
The guide undercuts its own safety examples in ways the summary doesn't mention. The first three points below are my reading of the code shown, not claims the page makes.
curl | bashslips through. The advanced blocklist patterncurl.*\|\s*shneedsshright after the pipe.curl … | bashdoesn't match.curl … | sudo shalso doesn't match, becausesudosits between the pipe andsh.- The
rmpatterns are inconsistent. The standalone script only catches combined flags like-rfor-fr, sorm -r -fand--recursivepass. The "advanced" patternrm\s+-[^\s]*[rf]is too broad: it also blocks a plainrm -f file. - The error-handling advice fails open. The "Hook Blocking Unintentionally" section tells you to wrap hook logic in
try/exceptandsys.exit(0)on any error. For a guardrail, that means a parser crash or malformed payload silently allows the command. Fail-open suits notifications, not blockers. - The cheat sheet disagrees with itself on blocking. It marks
SubagentStopas blockable butStopas not, and the page doesn't explain why. Check the current Claude Code docs before relying on either. $CLAUDE_FILE_PATHSis unverified. The multi-tool formatter example reads this variable, but the page never shows it being set. The payload fields it documents aretool_nameandtool_input. Verify the variable exists before depending on it.
Technologies named here
- safety_check.py
- Command validation hook script
- jq
- uv
- Claude Code
- Model Context Protocol
- Python
- Claude
Techniques named here
- Protecting sensitive files via hooks
- Flagging risky commands
Related in AI Security
