Skip to main content
rule

cloudflare-workers-hono-angular-saas-cursorrules-prompt-file — Cursor

A Cursor rule that pins the stack and conventions for SaaS on Cloudflare Workers: Hono API, Angular, Drizzle, Clerk, Stripe.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/cloudflare-workers-hono-angular-saas-cursorrules-prompt-file.mdc
Open on GitHub

What cloudflare-workers-hono-angular-saas-cursorrules-prompt-file does

The file covers one stack end to end: Cloudflare Workers with Hono, an Angular frontend with Ionic and PrimeNG, D1 or Neon through Drizzle, Zod validation, Clerk auth, Stripe payments, Inngest background jobs, Resend email. Bun for builds, Vitest and Playwright for tests, ESLint with Prettier, PostHog and Sentry for observability. It applies to every file in the project, so the agent keeps these versions and libraries in mind on any edit.

Then come layer-by-layer requirements. In Hono: inline handlers so RPC types infer, method chaining, hc<AppType>(BASE_URL) for a typed client, @hono/zod-validator on every request body, one error envelope. In Angular: standalone components only, signals, HttpResource, @if/@for instead of *ngIf. In Drizzle: sqliteTable for D1 and the Batch API, because D1 does not support transactions. Separate sections cover OWASP security, headers, Turnstile and Stripe webhook signature checks.

There are numeric thresholds the agent will hold your code to: Lighthouse a11y at least 95, perf at least 75, LCP up to 2.5s, CLS up to 0.1, INP up to 200ms, JS up to 200KB gz, CSS up to 50KB gz, functions no longer than 50 lines. Worth checking whether you want those limits in your project. For deploys the rule gives npx wrangler deploy followed by a cache purge through the Cloudflare API, and a Hono worker starter with secureHeaders and CORS.

What it helps with

  • give the agent one stack for a Cloudflare Workers SaaS
  • get a typed RPC client between Hono and Angular
  • enforce Zod validation on every request body
  • run Inngest background jobs inside a worker
  • hold Lighthouse and bundle-size budgets while generating code

Example prompts for the agent

  • add a new Hono API endpoint with Zod body validation
  • build an Angular component on signals that lists users
  • set up an Inngest background job to send email via Resend

How to install cloudflare-workers-hono-angular-saas-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/cloudflare-workers-hono-angular-saas-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about cloudflare-workers-hono-angular-saas-cursorrules-prompt-file

How do I install cloudflare-workers-hono-angular-saas-cursorrules-prompt-file in Cursor?

Create .cursor/rules/cloudflare-workers-hono-angular-saas-cursorrules-prompt-file.mdc at the project root and paste the rule contents into it. Cursor picks it up automatically.

What does this rule do?

It describes a full SaaS stack on Cloudflare Workers: Hono for the API, Angular for the frontend, Drizzle with D1 or Neon, Clerk, Stripe, Inngest. The agent follows these conventions when writing or editing code.

What performance limits does the rule set?

Lighthouse a11y at least 95 and perf at least 75, LCP up to 2.5s, CLS up to 0.1, INP up to 200ms, JS up to 200KB gz, CSS up to 50KB gz. Functions stay under 50 lines, cyclomatic complexity under 10.

Source text

cloudflare-workers-hono-angular-saas-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for full-stack SaaS applications on Cloudflare Workers with Hono APIs, Angular frontends, typed RPC, D1/Neon, and production observability."
globs: **/*
alwaysApply: false
---
# Cloudflare Workers + Hono + Angular SaaS

Full-stack SaaS on Cloudflare Workers with Hono API, Angular frontend, and enterprise integrations.

## Stack
CF Workers+Hono v4.12+ | Angular 21+Ionic 8+PrimeNG 21 | D1/Neon | Drizzle v1 | Zod | Clerk Core 3 | Stripe | Inngest v4 | Resend | Bun 1.3 | Playwright v1.59+ | Vitest | ESLint+Prettier | PostHog | Sentry

## TypeScript
- Strict mode, never `any` (use `unknown`), prefer `interface` over `type`
- `readonly` when not reassigned, `undefined` over `null`
- Zod as source of truth for validation
- ESLint flat config (`eslint.config.ts`) + typescript-eslint + Prettier

## Hono API
- Inline handlers for RPC type inference (never separate controller files)
- Method chaining: `app.use().get().post()` preserves types
- `hc<AppType>(BASE_URL)` for typed client
- `@hono/zod-validator` on ALL request bodies
- `app.onError()` + `app.notFound()` centralized
- Split large apps: `app.route('/path', subApp)`
- Error envelope: `{ error: string, code?: string, details?: unknown }`
- `createFactory<{ Bindings: Env }>()` for reusable middleware chains
- `GET /health` returns `{ status, version, timestamp }`

## Angular
- Standalone only (no NgModules), Angular 21 zoneless by default
- Signals stable: `signal()`, `computed()`, `effect()`, `linkedSignal()`, `resource()`
- `HttpResource` for data fetching
- Control flow: `@if`/`@for`/`@switch`/`@defer` (not `*ngIf`/`*ngFor`)
- kebab-case files, one component per file, `providedIn: 'root'`
- PrimeNG for UI components

## Drizzle v1
- `sqliteTable` for D1, plural snake_case tables
- `$inferSelect`/`$inferInsert` for types
- `createInsertSchema`/`createSelectSchema` from `drizzle-orm/zod`
- Batch API (not `BEGIN` — D1 doesn't support transactions)
- Prepared statements for repeated queries

## CF Workers
- CPU limit: 10ms free / 30s paid
- `ctx.waitUntil()` for async post-response work
- `ctx.passThroughOnException()` for graceful degradation
- Bindings typed via `Env` interface
- D1 global read replication for latency reduction
- Workers Builds for native CI/CD (preview URLs per branch)

## Inngest v4 (Background Jobs)
- `eventType('name', { schema: z.object({...}) })` per-event (v4 breaking)
- `inngest/cloudflare` adapter + `inngest.setEnvVars(c.env)` for Workers
- Step functions: `step.run()`, `step.sleep()`, `step.waitForEvent()`, `step.sendEvent()`
- `step.ai.infer()` offloads inference (zero compute during wait)
- `step.realtime.publish()` for durable pub/sub
- Each step idempotent, retried independently

## Testing (TDD)
- Failing test FIRST, then implement
- Playwright for E2E: 6 breakpoints (375, 390, 768, 1024, 1280, 1920)
- Vitest for unit tests
- No sleeps — use `waitFor`/`toBeVisible()`
- Selectors: `data-testid` > role > text
- axe-core 0 violations
- `PROD_URL` env var for production testing

## Security (OWASP Top 10:2025)
- Must: HSTS, CSP (nonce-based strict), X-Content-Type-Options, X-Frame-Options
- Must: Referrer-Policy, Permissions-Policy, COOP, COEP, CORP
- Remove: X-XSS-Protection, Expect-CT, Server, X-Powered-By
- Turnstile on all forms, Zod validation on all inputs
- Stripe webhooks: verify signature, deduplicate via KV

## Auth (Clerk)
- JWT verified per-request (no session store)
- Webhook sync: Clerk → D1 for user data
- RBAC: Clerk org roles for org-scoped, D1 for app-level
- Route layers: public → auth-only → role-gated → owner-only

## Quality
- Lighthouse: a11y ≥95, perf ≥75
- WCAG 2.2 AA compliance
- LCP ≤2.5s, CLS ≤0.1, INP ≤200ms
- JS ≤200KB gz, CSS ≤50KB gz
- Functions ≤50 lines, cyclomatic complexity ≤10

## Deploy
```bash
npx wrangler deploy && curl -sX POST \
  "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/purge_cache" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"purge_everything":true}'
```

## Hono Worker Starter
```typescript
import { Hono } from 'hono';
import { secureHeaders } from 'hono/secure-headers';
import { cors } from 'hono/cors';

interface Env {
  DB: D1Database;
  KV: KVNamespace;
  AI: Ai;
  TURNSTILE_SECRET: string;
}

const app = new Hono<{ Bindings: Env }>();
app.use('*', secureHeaders());
app.use('/api/*', cors({ origin: ['https://yourdomain.com'] }));
app.get('/health', (c) => c.json({ status: 'ok', timestamp: new Date().toISOString() }));
export default app;
```

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Backend and APIs →

From the same set68

cypress-defect-tracking-cursorrules-prompt-file A Cursor rule that turns the agent into a QA engineer: writes Cypress tests tagged by team, category and case ID, and builds reports through qa-shadow-report. ★ 41,011repo stars cursorrules-cursor-ai-wordpress-draft-macos-prompt A Cursor rule that describes the PressThat project: a system tray app that connects to WordPress and creates draft posts. Useful if you work on that app in Cursor. ★ 41,011repo stars cursor-ai-react-typescript-shadcn-ui-cursorrules-p A Cursor rule that pushes the agent toward React and TypeScript code written the way shadcn/ui and Tailwind CSS projects expect. ★ 41,011repo stars code-style-consistency-cursorrules-prompt-file A Cursor rule that makes the agent study your codebase conventions first and write new code to match them. Useful in repos with an established style. ★ 41,011repo stars chrome-extension-dev-js-typescript-cursorrules-pro A Cursor rule that points the agent at one set of conventions for building Chrome extensions in JavaScript and TypeScript. ★ 41,011repo stars ascii-simulation-game-cursorrules-prompt-file A Cursor rule that frames an observer-only ASCII simulation: 10x10 grid, turn-based play, logs for nearly everything. Useful if you are building something in the spirit of Conway's Game of Life. ★ 41,011repo stars ankra-cli A Cursor rule that tells the agent how to drive the Ankra CLI: clusters, stacks, Helm releases and tokens. ★ 41,011repo stars android-jetpack-compose-cursorrules-prompt-file A Cursor rule that steers the agent through Android development with Jetpack Compose: architecture, state, tests. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor