/croftweaver:website-contact-formfrom Croftweaver
Adds a serverless contact form that opens the visitor's email program with a pre-written message. Includes form component, English/German texts, CSP-safe script, and tests.
Ships in Croftweaver. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Our suggestion for contact on a small site: a short form whose button opens the visitor's own email program with a message to the owner already written. The visitor reads it, presses Send, and it arrives like any other email. There is no server work, no account and no setting behind it.
And the honest weak spots, so the owner hears them from you first:
If the owner needs either of those solved (messages from every visitor whatever their setup, or a count of them), this is the wrong tool: see §0.
<EmailLink>) does the job. Say so.new-website/references/WEBSITE_ARCHITECTURE.md Tier 2: a form that sends
through a server, which needs a mail service, settings only the owner can create,
and a paragraph on the privacy page. Not built by this skill.| File | From this skill's templates/ | What it is |
|---|---|---|
src/components/MailForm.astro | MailForm.astro | the form, and the address line under it |
src/components/mail-form-text.ts | mail-form-text.ts | everything the form says, in English and German, and the longest message it takes |
public/js/mail-form.js | mail-form.js | the script: shows the form, builds the mailto: link, opens it |
tests/mail-form.spec.ts | mail-form.spec.ts | the form as a visitor meets it: the link the button opens (address, subject, every field, encoding), an empty field, labels and keyboard order through any added fields, a hint as the message box's description, the page without JavaScript, a strict Content-Security-Policy, and every text against the site's tone rules |
The templates are in this skill's templates/ folder, beside this SKILL.md; the bundled
copy of the skill on a handed-off repo has them too. Install all four.
How it works, in one paragraph. The owner's address goes into the HTML encoded the
way EmailLink encodes it (src/lib/obfuscate.ts), never as plain text. The script, a
file of the site's own under public/js/ rather than an inline script, so a strict
script-src 'self' policy lets it run, shows the form, and when the button is pressed
decodes the address and opens mailto:<address>?subject=…&body=…. The body starts
with the greeting the owner chose (greeting), then the visitor's message as typed,
less any empty space (spaces, tabs, blank lines) at its very start and end. Every other
field the visitor filled in follows as "Label: value", so a field the owner adds later
goes into the mail by its label with no change to the script. The language's sign-off
("Kind regards", "Freundliche Grüße") ends it; the visitor's mail program says who they
are. Without JavaScript the form stays hidden, since it could do nothing, and
the address line under it is what the visitor sees.
The spec needs toneViolations from the site's tests/_helpers.ts, the tone rules
its pages are held to. A site made from an older starter lacks it, and npm run check
says has no exported member 'toneViolations'. Then first bring that file up to date
from the starter's (new-website/templates/astro/tests/_helpers.ts): take
toneViolations and the rules above it, keep the site's own PAGES. Take the
starter's tests/tone.spec.ts with it, so the pages and the form read one list. Before
replacing the site's tone.spec.ts, compare its rules and its ALLOWLIST with the
starter's: a word the site added goes into the same place in _helpers.ts, or the site
loses it.
AGENTS.md §2)Copy the four files to the places in §1 (mkdir -p public/js first).
Put the form on a page, inside that page's <Base>:
---
import MailForm from '../components/MailForm.astro';
---
<MailForm to="<the address messages go to>" subject="<what the visitor comes for>" greeting="<the mail's first line>" />
Ask the owner for the address. The starter's encoding takes only plain addresses:
letters, digits and . _ % + - before the @, and the build stops with a clear
message on anything else. A new /contact page is a new page: work through
AGENTS.md §6 (PAGES, llms.txt, share card, a link to it). One form per page:
its ids are fixed.
The subject line (subject, required: the build stops without it). It is the
first thing the visitor reads in their mail program, and what stays in their Sent
folder. So let it name what they came for, in their words, rather than the website:
an architects' office "Anfrage Bauvorhaben", a holiday flat "Booking request", a
consultant "Project enquiry". The mail then starts as their own request, not as a
message to a website. Take it from the site's offer and the primary action in
CONTENT_GUIDE.md, in the page's language, and keep it short, about 40 characters,
so a mail program's list shows all of it. A page for one offer can pass its own.
Propose one or two and let the owner choose: these are their customers' first words
to them. The plain address under the form carries the same subject.
The greeting (greeting, required: the build stops without it). The first line
of every mail, as the visitor would write it to the owner, punctuation included. Ask
the owner whom visitors address, and propose one in the site's form of address:
"Sehr geehrte Frau Muster," where one named person answers on a "Sie" site, "Sehr
geehrte Damen und Herren," for a firm with no one person, "Hallo Anna," on a "du"
site, "Dear Ms Smith," in English. The mail ends with the language's sign-off
(signoff in mail-form-text.ts: "Kind regards", "Freundliche Grüße", no comma). A
site that wants another, such as "Viele Grüße", changes it there. The plain address
under the form opens a blank mail, with no greeting.
Language. The form speaks the language of the page it is on, by itself: a page
built with <Base lang="de"> on an English site gets a German form. Base.astro
hands the page's language down (Astro.locals.lang); on a site with several
languages it is the page's locale.
lang="…" overrides; then set LANG in the spec too (step 4). English and German
are built in, with no form of address in German, so the form fits a "du" site and a
"Sie" site. Any other language: "Add a language" below, first. A form in a language
with no texts stops the build.
A site made from an older starter lacks the line in Base.astro. On a site
without Astro's language routing, a form without lang then stops the build with a
message naming the line (with routing, the page's locale stands in). Add
Astro.locals.lang = lang; after the props in Base.astro, and the declaration
declare namespace App { interface Locals { lang?: string } } to src/env.d.ts:
create the file from the starter's if the site has none, and keep what a site's own
file already declares. Without the declaration, npm run check fails on the line.
In tests/mail-form.spec.ts set PAGE (the page with the form), TO, SUBJECT
and GREETING (the address, the subject and the greeting from step 2). The spec
fails while one is empty, and holds the subject and the greeting to the site's tone
rules. LANG only if the page passes
lang. One copy guards one form:
with the form on pages in two languages, copy it once per language
(tests/mail-form.de.spec.ts), each with its own PAGE, SUBJECT and GREETING.
Fields. The form asks for the message, nothing else: the visitor's name and email address come with their mail, and the form adds the greeting and the sign-off. A field the owner wants, or a hint above the message box: "Adding fields" below.
npm run check && npm test.
Ask only what the visitor's mail cannot carry and the owner needs to answer: a kind of request, a place, a phone number for a call back. Never a name or an email field: the mail brings both. Each field is one more reason to leave; two or three is plenty.
Fields go between <MailForm> and </MailForm>, and come before the message. A hint goes
in the slot hint: the form shows it between the message's label and its box, and ties it
to the box (aria-describedby), so it becomes the box's accessible description. An
example,
for a building firm:
<MailForm to="…" subject="Project enquiry" greeting="Dear Ms Smith,">
<fieldset>
<legend>What is it about? <span class="mail-form-optional">(optional)</span></legend>
<label><input type="radio" name="kind" id="kind-new" value="new" /> A new project</label>
<label><input type="radio" name="kind" id="kind-running" value="running" /> A project under way</label>
</fieldset>
<p>
<label for="town">Town</label> <span class="mail-form-optional" id="town-optional">(optional)</span>
<input id="town" name="town" type="text" maxlength="80" aria-describedby="town-optional" />
</p>
<Fragment slot="hint">For example: what is planned, how far the planning is, when work should start.</Fragment>
</MailForm>
The mail then reads, between the message and the sign-off: "A new project" and "Town: Bath". The rules behind it, each from a source read on 2026-10-27:
fieldset, named by its legend. "Radio button
groups should always be grouped using <fieldset>" (W3C WAI,
https://www.w3.org/WAI/tutorials/forms/grouping/). The mail carries the ticked option's
label alone, not the legend, so write each option to read on its own ("A new project",
not "New").select): a drop-down list always has an entry
chosen, so an untouched list sends an answer the visitor never gave, a "Please choose"
entry included. No box ticked and no text filled in advance. The script sends whatever a
field holds, and the spec expects no field line when the visitor adds nothing.span with class mail-form-optional tied to the
field with aria-describedby, because the mail uses the label's text: "Town: Bath", not
"Town (optional): Bath". In a radio group it goes in the legend, which the mail never
shows.span per case in the slot
(<span class="hint-any">…</span><span class="hint-new">…</span><span class="hint-running">…</span>) and show the one that fits, in the page's <style>.
.mail-form is the form's own element, outside the page's style scope, hence
:global:
.hint-new, .hint-running { display: none; }
:global(.mail-form):has(#kind-new:checked, #kind-running:checked) .hint-any { display: none; }
:global(.mail-form):has(#kind-new:checked) .hint-new { display: inline; }
:global(.mail-form):has(#kind-running:checked) .hint-running { display: inline; }
A hidden span is left out of the box's description, so the description is the hint
on screen (the page test below checks it).Looks. The form styles what goes in the slot: a text field, a radio group and
the mail-form-optional note look like the message field, with no CSS of the page's own.
Astro gives fields in a slot the page's style scope, not the form's, so the form's rules
reach them through :global, inside the form only. A page adds style only for what is its
own, such as a hint that changes.
The spec. Set ADDED in tests/mail-form.spec.ts to the fields' labels, one per Tab
stop in order: a radio group by its first option (['A new project', 'Town']). The spec
then checks that every control has a label, that Tab goes through them to the message and
the button, and, when there is a hint, that it is the box's accessible description.
The page's own test. Only the page knows its fields, so add a short spec next to it
(tests/contact.spec.ts) that enters as a visitor does, through the button, and checks the
mail word for word:
import { test, expect, type Page } from '@playwright/test';
import { TEXT } from '../src/components/mail-form-text';
const t = TEXT.en; // the page's language
const greeting = 'Dear Ms Smith,'; // the form's greeting
const form = (page: Page) => page.locator('form[data-mail-form]');
// The mail body the button hands to the mail program, decoded.
async function send(page: Page) {
const asked = page.waitForRequest((r) => r.url().startsWith('mailto:'), { timeout: 5000 });
await form(page).getByRole('button', { name: t.send, exact: true }).click();
const body = (await asked).url().split('?')[1].split('&').find((p) => p.startsWith('body='))!;
return decodeURIComponent(body.slice('body='.length));
}
test('contact — the choice and the town arrive under the message', async ({ page }) => {
await page.goto('/contact');
await form(page).getByLabel('A new project', { exact: true }).check();
await form(page).getByLabel('Town', { exact: true }).fill('Bath');
await form(page).getByLabel(t.message, { exact: true }).fill('A kitchen extension.');
expect(await send(page)).toBe(`${greeting}\r\n\r\nA kitchen extension.\r\n\r\nA new project\r\nTown: Bath\r\n\r\n${t.signoff}`);
});
test('contact — with nothing chosen or added, the mail has no field line', async ({ page }) => {
await page.goto('/contact');
await expect(form(page).locator('input[type=radio]:checked')).toHaveCount(0);
await form(page).getByLabel(t.message, { exact: true }).fill('A short question.');
expect(await send(page)).toBe(`${greeting}\r\n\r\nA short question.\r\n\r\n${t.signoff}`);
});
A hint that follows the choice
gets one more test: toHaveAccessibleDescription on the message box, before and after each
choice. A field that asks for more personal data than the message also goes into the privacy
page (§4).
On a new site in that language, or when a site gains it later. Translate from the English, all of it in one go.
CONTENT_GUIDE.md (in German the register, "du"
or "Sie") and the tone rules in tests/_helpers.ts. Where the language allows, do as
the German texts do and address nobody.src/components/mail-form-text.ts, copy the en entry of TEXT under the
language's two-letter code (fr, not fr-CA) and translate every value; the
comment above TEXT says where each one shows. npm run check fails while one is
missing, and the spec holds every text to the tone rules. For a language without
rules of its own in tests/_helpers.ts that is the ban on the long dash alone: read
the texts against step 1 yourself, and if the owner speaks the language, ask them to
read the form once.DOT_WORD in src/lib/obfuscate.ts (English and
German there); add the language's word. The spec fails while the hint says "dot".It works the same on a laptop as on the live site, since there is nothing on a server
to wait for. After npm run build && npm run preview, or on the preview address of the
pull request:
mailto: links. That
is exactly what some visitors meet, and why the address shows under the form. On a
Mac it is set in Mail's settings, on Windows under default apps; in Chrome a webmail
such as Gmail can ask to open these links. Not a fault of the form.The starter's privacy page already has a section on contact by email ("4. Contact by email", German "4. Kontakt per E-Mail"), naming the name, the address and the message. That is what this form produces: an email, sent by the visitor. Nothing to add, and no processor paragraph, since no service handles the message on the way.
Check two things only: the section is still there (a rewritten privacy page may have lost it; then write it, covering what is processed, why, the legal basis and how long it is kept), and any field added in §2 step 5 that asks for more than the message is named in it. Like the kit's other legal drafts, a baseline, not legal advice.
With Plausible on, a press of the button sends one "Email Tap" event, the same one
the starter's email link sends (nothing typed goes with it). Section 3 of the starter's
privacy page (EN privacy.astro; German _datenschutz.astro, served as
datenschutz.astro once a German site renames it) already says so ("a button that opens your
email program"). An older site's privacy page may lack that sentence, and its own
src/components/EmailLink.astro, which shows the address under the form, may not count
clicks yet (no addEventListener in it). Take whatever is missing from the starter: the
sentence, the click listener, or both. The form sends its event
either way, so the sentence is not optional on a site that runs Plausible. In Plausible's
installer leave "Form submissions" unticked: whether Plausible would count this form a
second time was not checked.
A site made before 0.35 in analytics server mode (ANALYTICS.mode: 'server') does not
count the button: no Plausible script runs, so the form's call does nothing, and counting
it from the server would mean passing what the visitor typed through it. The mail program
opens as before. A site made with 0.35 or later has no server mode.
LIMITS in
mail-form-text.ts). In the link they become more: about 2,800 for English prose,
more with umlauts and line breaks. Some mail programs cut a very long link, and at
what length was not measured, so a long message may arrive cut in some of them, and
then the sign-off at its end is the first thing lost. The visitor sees the mail
before pressing Send, and can write on in their mail program. Whether a mail program
adds the visitor's own signature under it was not checked.script-src 'self' (the spec proves it). The address under it, the starter's
EmailLink, decodes through an inline script, so under such a policy it stays as the
readable "name [at] example [dot] com" hint and cannot be clicked. The starter's own
policy (public/_headers) allows inline scripts, so a site that kept it is not
affected.mailto:
links (RFC 6068), and the spec checks it to the character. How each mail program
shows it was not tried beyond the owner's own (§3).new-website §1 Q2 and
references/WEBSITE_ARCHITECTURE.md.website-qa §1b.privacy.astro and _datenschutz.astro.EmailLink.The owner chose the form knowing its weak spots; it is on its page in the site's
language with the right address and the owner's greeting; npm test is green with
PAGE, TO, SUBJECT and GREETING set; the
privacy page's section on contact by email is in place; and the owner has opened one
message from it in their own mail program and seen it arrive.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
40 skills in this plugin
/ai-seoWhen the user wants to optimize content for AI search engines, get cited by LLMs, or appear in AI-generated answers. Also use when the user mentions 'AI SEO,' 'AEO,' 'GEO,' 'LLMO,' 'answer engine optimization,' 'generative engine optimization,' 'LLM optimization,' 'AI Overviews,' 'optimize for ChatGPT,' 'optimize for Perplexity,' 'AI citations,' 'AI visibility,' 'zero-click search,' 'how do I show up in AI answers,' 'LLM mentions,' or 'optimize for Claude/Gemini.' Use this whenever someone wants their content to be cited or surfaced by AI assistants and AI search engines. For traditional technical and on-page SEO audits, see seo-audit. For structured data implementation, see schema-markup./astro-i18n-setupTurn a new-website scaffold into a turnkey multi-language site: Astro i18n routing (clean default locale + prefixed others), self-referencing hreflang + x-default in the Base layout, i18n sitemap alternates, a language switcher, and the test-harness changes that keep the green-from-commit-1 gate honest across locales. Run at scaffold time when new-website Q4 = "two+ languages at launch", OR later to add a second language to a single-locale site whose default stays unprefixed (phased rollout). Trigger phrases: "multi-language site", "add i18n", "DE+EN site", "internationalization", "hreflang setup", "two languages at launch".
npx claudepluginhub karero/croftweaver --plugin croftweaverOther plugins' skills for the same job