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.

Lab · Intermediate · 60 min

A Hook That Blocks Commits When Tests Were Skipped

Write a pre-tool hook that intercepts git commit, checks that the test command ran successfully after the last edit, and blocks with a clear message if not.

Claude Code · Cursor

Show all 4 steps

Step 1 of 4

Lab brief

Goal

A deterministic guardrail that the agent cannot talk its way around, working in Claude Code and Cursor.

Failure mode

Memory file says 'always run tests before committing'; the agent commits anyway after a long session because the instruction scrolled out of attention.

Staff move

Move must-always rules from prompts into hooks, keep the hook fast, and make the block message tell the agent exactly what to do next.