Claude Code hook generator

Make Claude Code check every form it writes. This generator gives you a small hook that runs FormDoc’s form checker each time Claude edits a file with a form in it. If the form has a problem, such as a missing access key, a GET method or a field without a name, Claude sees the problem straight away and fixes it before moving on.

  • Free
  • No account
  • Runs in your browser
  • Updated

Get your hook

Check forms in

You need Node.js 18 or newer. The check runs npx -y @formdocdev/cli check only when an edited file contains a form that posts to FormDoc.

Want the skill and MCP server too? Install the FormDoc plugin, which includes this hook.

1. Save the check script

File:

2. Add the hook

File: (if it already has "hooks", add the PostToolUse entry to them)

How to use the hook generator

  1. Choose whether to check forms in this project or in all your projects.
  2. Save the check script at the path shown.
  3. Add the hook to your Claude Code settings file, next to any hooks you already have.
  4. Start Claude Code (or run /hooks to see that the hook is loaded).
  5. Ask Claude to add a contact form. If anything is wrong, Claude fixes it on its own.

How the hook works

Claude Code runs the hook after every Edit or Write. The script reads which file changed and skips it unless it contains a form that posts to FormDoc, so ordinary edits cost nothing. For a form file it runs npx -y @formdocdev/cli check on that file. When the check finds problems, the script exits with code 2, which tells Claude Code to show the problems to Claude.

The check looks for Why it matters
method isn’t POST Forms default to GET, which FormDoc doesn’t accept
No hidden access_key, or still YOUR_ACCESS_KEY FormDoc can’t tell whose form it is
Fields without a name Only named fields are sent
No botcheck spam trap Bots fill the form and spam reaches you

The check runs on your computer and reads only the file that changed. Nothing is uploaded.

Hook, skill or plugin?

The hook catches mistakes after Claude writes a form. The Claude Code skill tells Claude the rules before it writes one. Use both for the best results, or install the FormDoc plugin for Claude Code, which includes the skill, this hook and FormDoc’s MCP server in one step.

Common questions

Is the hook free?

Yes. The hook and FormDoc’s form checker are free, and forms on the Free plan receive 250 submissions a month.

Does the hook slow Claude down?

Hardly. For files without a FormDoc form the script finishes in a few milliseconds. For form files, the first run downloads the checker with npx, and later runs use the copy npx keeps.

What if I don’t have Node.js?

The hook needs Node.js 18 or newer, which Claude Code users usually have already. Check with node --version. If the checker can’t run, the hook stays quiet rather than blocking Claude.

Can I run the same check in CI?

Yes. Run npx -y @formdocdev/cli check . in your build. It exits with code 1 when a form has problems, so the build fails before a broken form goes live. See the AI assistants guide for the other commands.