cloudflare / cloudflare/templates

🚀 Template Request: AI-assisted security headers analyzer (Workers AI + AI Gateway + D1 + Durable Objects)

Open
#1,136 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.1k
Forks
1k
Avg merge
17h 44m
Merged PRs (30d)
10

Description

### 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`](https://github.com/Leiruz/templates/tree/add-ai-security-headers-template) (`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.

Contributor guide

Open the contributing guide

Research direction

Review the add-ai-security-headers-template branch first, then compare its approach with the text-to-image-template fake-AI pattern and the repository's existing fixtures. Run pnpm run check, templates lint, syncpack, and the lockfile checks; done means the template includes the described bindings, Vitest coverage, and a passing Playwright spec.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript
Domain
ai, backend, databases, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.