Development Guide
This file provides guidance for coding agents working in this repository.
Essential Commands
Development
pnpm run dev- Start local development (wrangler devon:8080+ local SES on:8005)pnpm run create-token- Generate JWT token for API testing
Quality Checks
pnpm run lint- Run Biome checkspnpm run fix- Apply Biome formatting/fixespnpm run typecheck- Run TypeScript type checkingpnpm run test- Run unit testspnpm run test:coverage- Run tests with coverage
Architecture Overview
- Runtime: Cloudflare Workers + Hono
- Deployment: GitHub Actions (
stagingbranch -> staging,mainbranch -> production) - Auth: JWT middleware on
/api/* - OpenAPI: served at
/schema/v1
Email Delivery Flow
POST /api/v1/send: send a single email via AWS SESPOST /api/v1/send-multiple: accept an async campaign and enqueue up to 100 recipients per queue message- Queue consumer: sends emails via AWS SES with controlled pace (
~8/sec) - Retry policy: queue-level retries with DLQ fallback
Storage and Logging
- R2 bucket binding:
MAIL_LOGS_BUCKET - Campaign acceptance logs and recipient failure logs are stored as JSON
Required Bindings and Vars
ENVIRONMENTTOKEN_SECRETERROR_NOTIFICATION_TOKENAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYMAIL_LOGS_BUCKETMAIL_SEND_QUEUE
Working Conventions
- Use TDD where practical.
- Keep API contracts stable unless explicitly requested.
- Prefer minimal, focused changes and keep tests updated.
- Communicate with the developer in Japanese.
- Write code comments and documentation in English.
Change Checklist
When implementing changes, make sure to:
- Update related tests.
- Run
pnpm run lint,pnpm run typecheck, andpnpm run test. - Regenerate Worker types after Wrangler binding changes:
pnpm run gen:cf-types