Cursor Rules Template: Python FastAPI for Delivery Issues Summaries
Copyable Cursor rules template for building AI agents to summarize delivery issues from emails and support tickets using Python FastAPI and PostgreSQL.
Target User
Developers building Cursor AI agents to summarize delivery issues from emails and support tickets
Use Cases
- Summarize delivery issues by order, driver/location, and customer
- Identify root causes from ticket threads
- Produce structured summaries with fields: issue, urgency, due date, and recommended actions
Markdown Template
Cursor Rules Template: Python FastAPI for Delivery Issues Summaries
Overview
This Cursor rules configuration provides a complete, copyable template for building Cursor AI agents that summarize delivery issues from emails and support tickets. It targets a Python FastAPI + PostgreSQL stack, guiding you through architecture, security, and testing considerations to produce structured summaries and actionable items from customer communications.
When to Use These Cursor Rules
- When you need consistent, reproducible summaries of delivery issues from email threads and ticket conversations.
- When integrating an AI agent into a FastAPI service that ingests email bodies and ticket text.
- When you want structured outputs (summary, issues, urgency, actions) that feed dashboards, escalations, and SLAs.
- When data privacy and auditability are required for customer communications.
Copyable .cursorrules Configuration
# Cursor rules block for Python FastAPI + PostgreSQL delivery-issues summarization
Framework: Python FastAPI + PostgreSQL (SQLAlchemy)
Context: You are a Cursor AI agent attached to a delivery-issues workspace. Your job: parse emails and support tickets, extract delivery problems, summarize them succinctly, classify by issue type, and propose concrete actions. Redact PII and adhere to privacy constraints; outputs must be safe for internal sharing.
Code Style and Style Guides:
- Language: Python 3.11+
- Type hints, docstrings, and PEP8-compliant formatting
- Outputs: structured dicts with keys: summary, issues, actions, urgency, customers, orders
- Do not return raw email bodies unless redacted; prefer per-item summaries
Architecture & Directory Rules:
- Project layout:
app/
main.py
api/
models/
services/
summarizers/
tests/
- Use SQLAlchemy models in app/models with async sessions
- Keep business logic in app/services and summarizers
Authentication & Security Rules:
- Use OAuth2 with short-lived tokens for API calls; never log full emails
- Store only redacted payloads in DB; encrypt sensitive fields at rest
- Validate inputs and escape outputs safely
Database and ORM patterns:
- PostgreSQL with SQLAlchemy 2.0, async support
- Migrations via Alembic; models are declarative
Testing & Linting Workflows:
- pytest + pytest-asyncio; mypy for type-checking; ruff for linting
- CI should run unit, integration, and end-to-end tests
Prohibited Actions and Anti-patterns for the AI:
- Do not emit raw customer emails or PII
- Do not access external inboxes from the AI runtime
- Do not bypass validation or produce non-deterministic outputs
Recommended Project Structure
project-root/
app/
main.py
api/
v1/
routes.py
models/
delivery_issue.py
services/
extractor.py
summarizer.py
summarizers/
issue_summary.py
config/
tests/
migrations/
Core Engineering Principles
- Privacy by design: redact PII and limit data exposure
- Deterministic, testable summarization outputs
- Idempotent rule execution with predictable side effects
- Observability: structured logs, metrics, and tracing
- Data minimization and secure handling of customer content
- Clear separation of concerns between parsing, summarization, and persistence
Code Construction Rules
- Inputs are normalized to a fixed schema; outputs include: summary, issues, actions, urgency
- All DB interactions use parameterized queries via SQLAlchemy
- Model names follow CamelCase; services use dependency injection
- Tests cover unit, integration, and a minimal end-to-end flow
- Redact sensitive fields in summaries and logs
- Do not build hard-coded queries; rely on ORM query builders
Security and Production Rules
- Secret management via environment and secret stores; rotate credentials
- Encrypt sensitive data at rest and in transit
- Implement rate limiting and robust input validation
- Use CI/CD with tests, linting, and dependency vulnerability checks
- Maintain audit trails for summaries and actions generated
Testing Checklist
- Unit tests for extractor and summarizer functions
- Integration tests with a test PostgreSQL database
- End-to-end tests simulating email and ticket inputs
- Static type checks and linting in CI
- Security tests for redaction and data handling
Common Mistakes to Avoid
- Assuming all emails are safe; always redact and validate
- Overly verbose summaries; prefer structured fields
- Ignoring data localization and jurisdictional rules
- Directly exposing internal IDs or raw content in outputs
Related implementation resources: AI Agent Use Case for Facility Management Firms Using Maintenance Tickets to Identify Recurring Building Issues and Production-Grade LLM Summaries for Test Execution Reports.
FAQ
What is this Cursor Rules Template about?
This Cursor Rules Template provides a ready-to-use configuration for building Cursor AI agents that summarize delivery issues from emails and support tickets on a Python FastAPI + PostgreSQL stack. It includes a copyable .cursorrules block and structured guidance for safe AI-assisted development.
Which stack does this template target?
The template targets Python FastAPI for the API layer and PostgreSQL via SQLAlchemy for persistence. It includes NLP steps to extract issues from email and ticket text while enforcing privacy, security, and testable code structure.
How do I run the .cursorrules file?
Save the block exactly as a .cursorrules file in your project root. The Cursor AI editor uses it to configure behavior. Ensure your app dependencies are installed and that the environment provides required credentials for services accessed by the agent.
How is data privacy handled?
PII is redacted before processing. Only structured summaries are produced. Raw emails are not logged or stored unless necessary for auditing, and access is restricted via tokens and role-based controls with encryption at rest.
Can I customize the summarization outputs?
Yes. The template defines fields like summary, issues, actions, and urgency. You can extend or tailor outputs, but maintain backward compatibility and ensure redaction rules apply consistently.Overview
This Cursor rules configuration provides a complete, copyable template for building Cursor AI agents that summarize delivery issues from emails and support tickets. It targets a Python FastAPI + PostgreSQL stack, guiding you through architecture, security, and testing considerations to produce structured summaries and actionable items from customer communications.
When to Use These Cursor Rules
- When you need consistent, reproducible summaries of delivery issues from email threads and ticket conversations.
- When integrating an AI agent into a FastAPI service that ingests email bodies and ticket text.
- When you want structured outputs (summary, issues, urgency, actions) that feed dashboards, escalations, and SLAs.
- When data privacy and auditability are required for customer communications.
Copyable .cursorrules Configuration
# Cursor rules block for Python FastAPI + PostgreSQL delivery-issues summarization
Framework: Python FastAPI + PostgreSQL (SQLAlchemy)
Context: You are a Cursor AI agent attached to a delivery-issues workspace. Your job: parse emails and support tickets, extract delivery problems, summarize them succinctly, classify by issue type, and propose concrete actions. Redact PII and adhere to privacy constraints; outputs must be safe for internal sharing.
Code Style and Style Guides:
- Language: Python 3.11+
- Type hints, docstrings, and PEP8-compliant formatting
- Outputs: structured dicts with keys: summary, issues, actions, urgency, customers, orders
- Do not return raw email bodies unless redacted; prefer per-item summaries
Architecture & Directory Rules:
- Project layout:
app/
main.py
api/
models/
services/
summarizers/
tests/
- Use SQLAlchemy models in app/models with async sessions
- Keep business logic in app/services and summarizers
Authentication & Security Rules:
- Use OAuth2 with short-lived tokens for API calls; never log full emails
- Store only redacted payloads in DB; encrypt sensitive fields at rest
- Validate inputs and escape outputs safely
Database and ORM patterns:
- PostgreSQL with SQLAlchemy 2.0, async support
- Migrations via Alembic; models are declarative
Testing & Linting Workflows:
- pytest + pytest-asyncio; mypy for type-checking; ruff for linting
- CI should run unit, integration, and end-to-end tests
Prohibited Actions and Anti-patterns for the AI:
- Do not emit raw customer emails or PII
- Do not access external inboxes from the AI runtime
- Do not bypass validation or produce non-deterministic outputs
Recommended Project Structure
project-root/
app/
main.py
api/
v1/
routes.py
models/
delivery_issue.py
services/
extractor.py
summarizer.py
summarizers/
issue_summary.py
config/
tests/
migrations/
Core Engineering Principles
- Privacy by design: redact PII and limit data exposure
- Deterministic, testable summarization outputs
- Idempotent rule execution with predictable side effects
- Observability: structured logs, metrics, and tracing
- Data minimization and secure handling of customer content
- Clear separation of concerns between parsing, summarization, and persistence
Code Construction Rules
- Inputs are normalized to a fixed schema; outputs include: summary, issues, actions, urgency
- All DB interactions use parameterized queries via SQLAlchemy
- Model names follow CamelCase; services use dependency injection
- Tests cover unit, integration, and a minimal end-to-end flow
- Redact sensitive fields in summaries and logs
- Do not build hard-coded queries; rely on ORM query builders
Security and Production Rules
- Secret management via environment and secret stores; rotate credentials
- Encrypt sensitive data at rest and in transit
- Implement rate limiting and robust input validation
- Use CI/CD with tests, linting, and dependency vulnerability checks
- Maintain audit trails for summaries and actions generated
Testing Checklist
- Unit tests for extractor and summarizer functions
- Integration tests with a test PostgreSQL database
- End-to-end tests simulating email and ticket inputs
- Static type checks and linting in CI
- Security tests for redaction and data handling
Common Mistakes to Avoid
- Assuming all emails are safe; always redact and validate
- Overly verbose summaries; prefer structured fields
- Ignoring data localization and jurisdictional rules
- Directly exposing internal IDs or raw content in outputs
Related implementation resources: AI Agent Use Case for Facility Management Firms Using Maintenance Tickets to Identify Recurring Building Issues and Production-Grade LLM Summaries for Test Execution Reports.
FAQ
What is this Cursor Rules Template about?
This Cursor Rules Template provides a ready-to-use configuration for building Cursor AI agents that summarize delivery issues from emails and support tickets on a Python FastAPI + PostgreSQL stack. It includes a copyable .cursorrules block and structured guidance for safe AI-assisted development.
Which stack does this template target?
The template targets Python FastAPI for the API layer and PostgreSQL via SQLAlchemy for persistence. It includes NLP steps to extract issues from email and ticket text while enforcing privacy, security, and testable code structure.
How do I run the .cursorrules file?
Save the block exactly as a .cursorrules file in your project root. The Cursor AI editor uses it to configure behavior. Ensure your app dependencies are installed and that the environment provides required credentials for services accessed by the agent.
How is data privacy handled?
PII is redacted before processing. Only structured summaries are produced. Raw emails are not logged or stored unless necessary for auditing, and access is restricted via tokens and role-based controls with encryption at rest.
Can I customize the summarization outputs?
Yes. The template defines fields like summary, issues, actions, and urgency. You can extend or tailor outputs, but maintain backward compatibility and ensure redaction rules apply consistently.