Describe the stack
I'd like to contribute a template showing a production-shaped pattern for AI on Workers: a deterministic rule engine grades HTTP security headers (HSTS, CSP, cookie attributes, disclosure headers) and Workers AI, optionally routed through AI Gateway, adds plain-language explanations under a constrained JSON schema.
Design points that might make it a useful reference template:
- The model never receives user input: its prompt is a closed set of finding IDs and fixed catalog text, and the grade never depends on the model. If AI is unavailable or over budget, the analysis still completes with deterministic explanations.
- Safe by default on the free tier: free-form input fails closed until a token is configured, and a Durable Object enforces a per-IP rate window plus an atomic daily AI budget consumed before inference.
- Bindings: Workers AI, AI Gateway (runtime option), D1, Durable Objects, static assets.
It passes pnpm run check, templates lint, syncpack, and the lockfile checks at current main, ships Vitest coverage plus a Playwright spec using the existing fixtures, and follows the e2e fake-AI pattern from text-to-image-template. A ready branch is at Leiruz/templates (add-ai-security-headers-template) if you'd like to preview; happy to open the PR, adjust scope, or drop pieces to fit what you want in the library.
AI assistance was used in building it; I specified, reviewed, ran, and take responsibility for the code.
Describe the stack
I'd like to contribute a template showing a production-shaped pattern for AI on Workers: a deterministic rule engine grades HTTP security headers (HSTS, CSP, cookie attributes, disclosure headers) and Workers AI, optionally routed through AI Gateway, adds plain-language explanations under a constrained JSON schema.
Design points that might make it a useful reference template:
It passes
pnpm run check,templates lint, syncpack, and the lockfile checks at current main, ships Vitest coverage plus a Playwright spec using the existing fixtures, and follows the e2e fake-AI pattern from text-to-image-template. A ready branch is atLeiruz/templates(add-ai-security-headers-template) if you'd like to preview; happy to open the PR, adjust scope, or drop pieces to fit what you want in the library.AI assistance was used in building it; I specified, reviewed, ran, and take responsibility for the code.