Skip to main content
HS
HiSETSuccess
LeetCode Prep

Agent Engineering

From autocomplete user to superstar developer — coding agents, context, skills, MCP, hooks, spec-driven and parallel workflows, and building your own agents.

Chapter 10 · 6 lessons

Hooks, Security, Evals & Shipping

Deterministic guardrails with hooks, permission and sandbox design, reviewing agent output, evals for agent setups, CI and cloud agents, and rolling this out to a team.

Cursor · Claude Code · OpenAI Codex · GitHub Copilot

Show all 6 lessons

Lesson 1 of 6

Hooks: Prompts Suggest, Hooks Decide

Hooks are scripts the harness runs on lifecycle events — before a tool call, after a file edit, before a shell command, when the agent tries to stop. They are deterministic: a hook that blocks rm -rf blocks it every time, regardless of what the model 'intended'.

ToolConfigExample events
Claude Code.claude/settings.json or plugin hooks/hooks.jsonPreToolUse, PostToolUse, UserPromptSubmit, Stop, SubagentStop, SessionStart
Cursor.cursor/hooks.jsonpreToolUse, beforeShellExecution, beforeMCPExecution, afterFileEdit, stop, subagentStop
CopilotHooks in CLI and cloud agentPre/post tool and session events
  • Block: dangerous commands, edits to protected paths, secrets in diffs
  • Enforce: run formatter after edits; refuse to stop until tests pass
  • Observe: log every tool call for audit
  • Keep hooks fast and fail-safe; in Cursor, failClosed makes a crashing hook block instead of allow