bot-proof-forms
Skill0 starsChanged 48 days agoMITView on GitHub
Stop spam and bot submissions on Laravel contact, newsletter, sign-up, donation and checkout forms without a CAPTCHA, using an encrypted time token plus a honeypot field in a reusable middleware and Blade component. Use when forms receive spam, fake sign-ups, card-testing or injection attempts, or when adding a public form, a honeypot, or anti-bot protection.
In this repository11 other files it gives its agents.
- image-uploadsSkill
- inertia-admin-tablesSkill
- json-ld-structured-dataSkill
- mpesa-stk-pushSkill
- paypal-checkoutSkill
- pre-push-checksSkill
- secrets-scannerSkill
- seo-crawlabilitySkill
- shared-network-rate-limitsSkill
- social-share-previewsSkill
- wordpress-migrationSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Put <x-spam-guard /> inside every public form, next to @csrf.
- Very specific: line 31
JavaScript-submitted forms: must send form_token and website too.
- Distinctive: line 50
Add a CAPTCHA (Turnstile, hCaptcha) only if these checks plus rate limits aren't enough.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bot-proof forms without a CAPTCHA
Two invisible checks stop most form spam, with no friction for real people and no third-party script:
- Time token. An encrypted "form shown at" timestamp. People take at least a few seconds; bots post instantly or replay a form scraped days ago. Tokens younger than 3 seconds or older than 24 hours fail, and so do forged ones (they're encrypted with
APP_KEY). - Honeypot. A
websitefield hidden from people and screen readers. Only bots fill it in.
Install
- Copy from
stubs/, dropping.stub:app/Support/FormTimeToken.phpapp/Http/Middleware/SpamGuard.phpresources/views/components/spam-guard.blade.phptests/Feature/SpamGuardTest.php
- Put
<x-spam-guard />inside every public form, next to@csrf. - Protect the routes:
use App\Http\Middleware\SpamGuard; Route::post('contact', ContactController::class)->middleware([SpamGuard::class, 'throttle:forms']); Route::post('checkout', CheckoutController::class)->middleware(SpamGuard::class.':reject'); - JavaScript-submitted forms must send
form_tokenandwebsitetoo. Read them from the rendered inputs; don't build a new token in JS. - In your existing form tests, send a token issued at least 3 seconds earlier:
'form_token' => Crypt::encryptString((string) now()->subSeconds(10)->getTimestamp()),
Silent vs reject
- Silent (default): the bot gets the same success reply a person would, but the controller never runs. Bots can't tell they were caught, so they don't adapt. Use it for contact and newsletter forms.
- Reject (
:reject): answers with a 422 and "please try again". Use it where a real person caught by mistake (a password manager filled the form in 2 seconds) must be told to retry: payments, sign-ups, bookings.
Rules
- Don't reveal who's subscribed. The newsletter endpoint must give the same answer for new and existing emails.
- Block header injection in fields that end up in email headers (name, subject):
'not_regex:/[\r\n]/'. - Validate after the guard. Bots never reach validation, so they can't probe your rules.
- Pair with per-person rate limits (the
shared-network-rate-limitsskill). The guard stops dumb bots; limits stop persistent ones. - Card-testing bots hammer donation and checkout forms with tiny amounts. Use
:rejectthere, set a sensible minimum amount, and keep the provider's own fraud tools on. - Page caching breaks the token. If a form page is fully cached (a CDN caching HTML), the token becomes old for everyone. Render the token through a small uncached request, or exclude form pages from the cache.
- Add a CAPTCHA (Turnstile, hCaptcha) only if these checks plus rate limits aren't enough. Most sites never need one.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

