agentleFS
mrhinklemrhinkle/VibeCoding-a-Website/.claude/skills/form-wiring/SKILL.md

form-wiring

Skill17 starsChanged 7 months agoMITView on GitHub

Connect your generated website to Resend for email delivery and Beehiiv for newsletter signup. This skill transforms form placeholders in your site-generator output into fully functional forms that: - Send contact inquiries via Resend - Capture newsletter signups in Beehiiv - Validate input client-side - Handle errors gracefully - Show success confirmations - Protect against spam Fields: - Name (required, text) - Email (required, email) - Subject (required, text) - Message (required, textarea) - Honeypot field (hidden) Delivery: Via Resend…

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

41 rules. About 0 are common, 40 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈40

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Create api/contact.ts serverless function

    line 50
  2. Distinctive:

    Add form submission handler in main JS

    line 51
  3. Distinctive:

    Create Beehiiv embed code

    line 54
  4. Distinctive:

    No form wiring needed

    line 103
  5. Distinctive:

    Honeypot: Must be empty (hidden field)

    line 162
  6. Distinctive:

    Create Beehiiv publication (if not already created)

    line 180
  7. Distinctive:

    Add each variable from .env.example

    line 225
  8. Distinctive:

    If this field contains any value, the submission is rejected as spam.

    line 243
  9. Distinctive:

    After site-generator creates your website:

    line 279
  10. Distinctive:

    Check browser console for errors

    line 299
  11. Distinctive:

    Verify form validation works

    line 300
  12. Distinctive:

    Test honeypot field (leave empty)

    line 301
  13. Distinctive:

    Test error states (if rate limiting enabled)

    line 302
  14. Distinctive:

    Check for success toast notification

    line 306
  15. Distinctive:

    Verify email arrives in inbox

    line 307
  16. Distinctive:

    Test from different devices (mobile, desktop)

    line 308
  17. Distinctive:

    Test from different networks

    line 309
  18. Distinctive:

    Check spam folder for emails

    line 310
  19. Distinctive:

    Verify Resend API key is correct in Vercel env vars

    line 316
  20. Distinctive:

    Check that form names match function expectations

    line 317
  21. Distinctive:

    Ensure Resend domain is verified

    line 318
  22. Distinctive:

    Check email spam folder

    line 321
  23. Distinctive:

    Verify email address in Resend dashboard

    line 322
  24. Distinctive:

    Check Resend logs in dashboard

    line 323
  25. Distinctive:

    Verify sender domain is authenticated

    line 324
  26. Distinctive:

    Check that form handling JS is loaded

    line 327
  27. Distinctive:

    Verify toast CSS is present

    line 328
  28. Distinctive:

    Ensure form submit handler is wired correctly

    line 330
  29. Distinctive:

    Verify Beehiiv publication ID is correct

    line 333
  30. Distinctive:

    Check iframe sandbox permissions

    line 334
  31. Distinctive:

    Ensure Beehiiv publication is active

    line 335
  32. Distinctive:

    Never commit .env files with real API keys

    line 348
  33. Distinctive:

    Use Vercel's environment variable system

    line 349
  34. Distinctive:

    Add field to HTML form with name attribute

    line 358
  35. Distinctive:

    Add validation in client JS if needed

    line 359
  36. Distinctive:

    Add field to form data object

    line 360
  37. Distinctive:

    Update email template in function

    line 361
  38. Distinctive:

    Read the Resend Setup guide in references/

    line 385
  39. Distinctive:

    Create Resend account and API key

    line 386
  40. Distinctive:

    Run this skill on your generated website

    line 387
  41. Distinctive:

    Test contact form end-to-end

    line 389

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SKILL 4: Form Wiring

Connect your generated website to Resend for email delivery and Beehiiv for newsletter signup.

Overview

This skill transforms form placeholders in your site-generator output into fully functional forms that:

  • Send contact inquiries via Resend
  • Capture newsletter signups in Beehiiv
  • Validate input client-side
  • Handle errors gracefully
  • Show success confirmations
  • Protect against spam

What This Skill Does

1. Detects Forms

  • Scans generated website files
  • Identifies contact forms, newsletter fields, inquiry forms
  • Finds Beehiiv embed placeholders

2. Creates Serverless Functions

  • Generates api/contact.ts or api/contact.js
  • Implements Resend email delivery
  • Handles multiple form types (contact, inquiry, etc.)
  • Includes error handling and validation

3. Enhances Client-Side Forms

  • Adds form validation (required, email, phone)
  • Implements toast notifications (success/error)
  • Adds honeypot field for spam protection
  • Wires form submit to serverless function
  • Adds loading states to buttons

4. Configures Services

  • Resend API integration
  • Beehiiv embed setup (zero-code iframe)
  • Vercel environment variables
  • Domain verification for Resend

Skill Workflow

Input

  1. Website folder (generated by site-generator)
  2. User's Resend API key (provided by user)
  3. User's Beehiiv publication ID (if using newsletter)

Processing

  1. Scan for form markup in HTML/JSX files
  2. Create api/contact.ts serverless function
  3. Add form submission handler in main JS
  4. Inject toast notification UI
  5. Generate environment variable setup instructions
  6. Create Beehiiv embed code

Output

  1. Updated website with wired forms
  2. api/contact.ts serverless function
  3. Updated form HTML with event listeners
  4. .env.example file with required variables
  5. Setup instructions for Vercel
  6. Beehiiv embed code (copy-paste ready)

Form Types Supported

Contact Form

Purpose: General inquiries from visitors

Fields:

  • Name (required, text)
  • Email (required, email)
  • Subject (required, text)
  • Message (required, textarea)
  • Honeypot field (hidden)

Delivery: Via Resend to business owner email

Response: Welcome email + internal notification

Sponsor/Partnership Inquiry

Purpose: B2B partnership requests

Fields:

  • Company Name (required, text)
  • Contact Name (required, text)
  • Email (required, email)
  • Phone (optional, tel)
  • Inquiry Type (required, select)
  • Budget (optional, text)
  • Timeline (optional, select)
  • Message (required, textarea)

Delivery: Via Resend to partnerships email

Response: Thank you email + internal notification

Newsletter Signup

Purpose: Email list growth

Method: Beehiiv iframe embed (zero-code)

What Happens:

  • No form wiring needed
  • Pure HTML iframe embed
  • Beehiiv handles email capture
  • User can build campaigns in Beehiiv dashboard

Server-Side Function: api/contact.ts

Structure

import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

export default async function handler(req, res) {
  if (req.method !== 'POST') {
    return res.status(405).json({ error: 'Method not allowed' });
  }

  try {
    // Validate form data
    // Check honeypot field
    // Send via Resend
    // Return success
  } catch (error) {
    // Return error response
  }
}

Features

  • POST-only endpoint
  • Input validation (required fields, email format)
  • Honeypot spam detection
  • Rate limiting ready (configurable)
  • Error logging to console
  • Success response with message
  • Error response with user-friendly message

Environment Variables

Client-Side Form Handling

Form Submission

  1. User fills form and clicks submit
  2. JavaScript prevents default form behavior
  3. Form data is validated client-side
  4. Loading state appears on button
  5. Form data is sent to /api/contact via fetch
  6. Response is checked for success/error
  7. Toast notification appears
  8. Form is cleared (if successful)

Validation

  • Required fields: Empty check
  • Email: Regex pattern match
  • Phone: Optional, basic format check
  • Honeypot: Must be empty (hidden field)

Toast Notifications

Success Toast:

✓ Message sent! We'll get back to you soon.

Appears for 5 seconds, auto-dismisses.

Error Toast:

✗ Something went wrong. Please try again.

Shows specific error message, persistent.

Beehiiv Newsletter Integration

Zero-Configuration Setup

  1. Create Beehiiv publication (if not already created)
  2. Get publication ID from Beehiiv dashboard
  3. Skill generates embed code
  4. Copy embed code to footer or dedicated section
  5. Done! No serverless function needed

Embed Code Format

<!-- Beehiiv Newsletter Form -->
<iframe
  src="https://www.beehiiv.com/embedjs?publication_id=YOUR_PUB_ID"
  style="border: none; width: 100%; height: 220px; max-height: none;"
></iframe>

Features

  • Fully managed by Beehiiv
  • Custom styling via Beehiiv dashboard
  • Audience tracking and analytics
  • Double opt-in available
  • GDPR compliant

Location Options

  • Footer section (recommended)
  • Dedicated subscribe page
  • Homepage sidebar
  • Blog post sidebar
  • Modal popup (advanced)

Environment Variable Setup

.env.example File

# Resend Email Service
VITE_RESEND_FROM_EMAIL=noreply@yourdomain.com
VITE_RESEND_TO_EMAIL=contact@yourdomain.com
RESEND_API_KEY=re_xxxxxxxxxxxxx

# Beehiiv Newsletter
VITE_BEEHIIV_PUBLICATION_ID=xxxxxxxxxxxxx

Vercel Configuration

  1. Go to Vercel project settings
  2. Navigate to Environment Variables
  3. Add each variable from .env.example
  4. Restart deployment
  5. Forms are now live

Spam Protection

Honeypot Field

A hidden form field that only bots can see and fill:

<input 
  type="text" 
  name="_redirect" 
  style="display: none;"
  aria-hidden="true"
/>

If this field contains any value, the submission is rejected as spam.

Rate Limiting (Optional)

Skill includes commented code for rate limiting:

  • 5 submissions per IP per hour
  • Prevents abuse
  • Customizable thresholds

To enable, uncomment rate limiting code in api/contact.ts.

Email Templates

Confirmation Email to User

Hi [Name],

Thanks for reaching out! We've received your message and will get back to you as soon as possible.

Best regards,
[Business Name]

Notification Email to Business

New Contact Form Submission

Name: [Name]
Email: [Email]
Subject: [Subject]
Message: [Message]

Reply to: [Email]

Setup Checklist

After site-generator creates your website:

  • User creates Resend account (resend.com)
  • User creates API key in Resend
  • User verifies domain in Resend
  • User provides API key to this skill
  • Skill creates api/contact.ts function
  • Skill updates form HTML and JS
  • User adds .env variables to Vercel
  • User deploys updated site
  • User tests contact form
  • User receives test email
  • (Optional) User creates Beehiiv publication
  • (Optional) User provides Beehiiv pub ID to skill
  • (Optional) User adds newsletter embed to site

Testing Forms

Before Deployment

  1. Fill out contact form locally
  2. Check browser console for errors
  3. Verify form validation works
  4. Test honeypot field (leave empty)
  5. Test error states (if rate limiting enabled)

After Deployment

  1. Fill out contact form on live site
  2. Check for success toast notification
  3. Verify email arrives in inbox
  4. Test from different devices (mobile, desktop)
  5. Test from different networks
  6. Check spam folder for emails

Troubleshooting

Form Doesn't Submit

  • Check browser console for errors
  • Verify Resend API key is correct in Vercel env vars
  • Check that form names match function expectations
  • Ensure Resend domain is verified

Email Not Received

  • Check email spam folder
  • Verify email address in Resend dashboard
  • Check Resend logs in dashboard
  • Verify sender domain is authenticated

Toast Not Showing

  • Check that form handling JS is loaded
  • Verify toast CSS is present
  • Check browser console for errors
  • Ensure form submit handler is wired correctly

Newsletter Embed Not Showing

  • Verify Beehiiv publication ID is correct
  • Check iframe sandbox permissions
  • Ensure Beehiiv publication is active
  • Try different embed placement

Security Considerations

What's Protected

  • API key only stored on Vercel (never exposed to browser)
  • Form data validated on both client and server
  • Honeypot field prevents automated spam
  • Rate limiting prevents abuse (optional)
  • HTTPS ensures data encryption

What User Should Do

  • Never commit .env files with real API keys
  • Use Vercel's environment variable system
  • Enable domain verification in Resend
  • Monitor Resend logs for unusual activity
  • Regularly rotate API keys

Advanced Customization

Custom Form Fields

To add fields beyond the defaults:

  1. Add field to HTML form with name attribute
  2. Add validation in client JS if needed
  3. Add field to form data object
  4. Update email template in function
  5. Test submission

Custom Email Template

Modify email content in api/contact.ts:

await resend.emails.send({
  from: process.env.RESEND_FROM_EMAIL,
  to: process.env.RESEND_TO_EMAIL,
  subject: `New message from ${name}`,
  html: `<h2>New submission</h2>...` // Edit HTML here
});

Custom Toast Styling

Modify toast CSS in form handling JS:

toast.style.backgroundColor = '#your-color';
toast.style.padding = '20px';
// etc.

Next Steps

  1. Read the Resend Setup guide in references/
  2. Create Resend account and API key
  3. Run this skill on your generated website
  4. Deploy to Vercel with env variables
  5. Test contact form end-to-end
  6. (Optional) Add Beehiiv newsletter embed

See references/resend-setup.md for detailed Resend account creation and configuration steps.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.