# Cursor and Windsurf Rules for AI Email Agent Development (.cursorrules Guide)

_By Tayyab Mughal, Founder & AI Chief · 21 August 2026 · 2 min read_

> Complete .cursorrules and system prompt configuration for building safe, type-safe email agents in Cursor and Windsurf IDEs.

Supercharge your AI-assisted development workflow with battle-tested Cursor and Windsurf rules tailored for transactional email and MCP integrations.

## Why specialized .cursorrules matter for email development

When generating code with Cursor or Windsurf, models often default to deprecated libraries (like Nodemailer without TLS verification) or suggest unsafe credential handling.

By providing a project-specific .cursorrules file, you enforce TypeScript strictness, proper RFC 8058 unsubscribe headers, and SadaSend scoped credential patterns automatically.

## Production .cursorrules configuration template

Place this .cursorrules file in your project root to align AI code completions with email engineering best practices.

```markdown
# SadaSend Email Engineering Rules for Cursor

You are an expert email infrastructure and TypeScript engineer.
When generating email sending code or AI agent tools:

1. API Client Standards:
   - Always use native `fetch` with strict TypeScript interfaces. Do not import legacy SMTP libraries.
   - Enforce idempotency keys on every outbound send request (`Idempotency-Key: <uuid>`).
   - Wrap all API requests with explicit error handling for 403 (Allowlist Denied) and 429 (Rate Limited).

2. Security & Guardrails:
   - Never hardcode API keys or secret tokens. Use `process.env.SADASEND_AGENT_KEY`.
   - Ensure all email templates validate recipient input with Zod or Pydantic before dispatch.
   - Separate drafting logic from execution logic (Human-in-the-Loop pattern).

3. Deliverability Compliance:
   - When generating marketing or digest emails, always include `List-Unsubscribe` and `List-Unsubscribe-Post` headers (RFC 8058).
   - Ensure plain-text alternative bodies are generated alongside HTML bodies.
```

## IDE Integration and Verification

Once configured, Cursor Composer and Windsurf Cascade will automatically generate compliant email tools, error handlers, and test fixtures without repetitive prompt engineering.

---

_Tags: Cursor, Windsurf, DevTools, TypeScript_
