Claude Tips mascot
Claude Tips & Tricks
Claude Code intermediate Featured

Give Claude a Way to Verify Its Own Work

Provide Claude with feedback loops like tests, screenshots, or simulators so it can self-correct and deliver 2-3x better results.

The best thing you can do is give Claude a way to check its own work. A verification loop gets you 2-3x better results.

Types of Feedback Loops

Tests (the most common and reliable):

Write the implementation for the new rate limiter.
After each change, run `npm test -- --grep "rate-limit"`
and fix any failures before moving on.

Visual verification (for UI work):

After each change, take a screenshot with the Playwright MCP
and compare it to the design mock at ./designs/modal.png

Type checking / linting:

After each edit, run `tsc --noEmit` and fix any type errors
before proceeding.

CLI output:

Run the CLI command after your changes and verify the
output matches the expected format.

Why This Matters

Without verification, Claude writes code based on its best guess and moves on. With a feedback loop, it:

  1. Discovers its own mistakes immediately
  2. Iterates toward a working solution
  3. Handles edge cases it wouldn’t otherwise catch
  4. Delivers tested, working code, not just plausible code

Combine with Hooks

Use a PostToolUse hook to auto-run linters or formatters after every edit, so Claude doesn’t waste context fixing style issues:

{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Edit|Write",
      "command": "npx prettier --write $TOOL_INPUT_FILE_PATH"
    }]
  }
}
Paste into Claude Code
Set up a feedback loop where Claude can verify its own work by running tests after each change, checking the output, and iterating until everything passes.