Build a complete UCP integration for Wix e-commerce with:
Traditional approach: Jump into code, figure it out as we go
Our approach: Write specifications first, then generate code
Cursor Rules (.mdc files) are markdown specification documents that:
Think of them as executable blueprints that Cursor AI can follow.
.cursor/rules/
βββ 00-project-overview.mdc # Master blueprint
βββ modules/
β βββ core-ucp.mdc # Types, schemas, utilities
β βββ payment-handler.mdc # Payment tokenization
β βββ checkout.mdc # Checkout capability
β βββ discovery.mdc # Business profile
β βββ identity.mdc # OAuth linking
β βββ orders.mdc # Order management
β βββ mcp-bridge.mdc # AI agent interface
βββ infrastructure/
β βββ deployment.mdc # Render hosting
β βββ render-deployment.mdc # Live deployment details
βββ practices/
βββ tdd.mdc # Test-driven development
βββ testing.mdc # Testing strategy
βββ security.mdc # Security practices
File: 00-project-overview.mdc
File: 00-project-overview.mdc
## Module Responsibilities
| Module | Responsibility |
|--------|----------------|
| `core-ucp` | UCP protocol types, schemas, utilities |
| `payment-handler` | Wix Payments tokenization as UCP handler |
| `checkout-capability` | UCP Checkout using Wix eCommerce |
| `discovery-profile` | Business profile advertisement |
| `mcp-bridge` | Bridge Wix MCP to UCP protocol |
| `identity-linking` | OAuth 2.0 account linking |
| `order-management` | Post-purchase order tracking |
File: modules/core-ucp.mdc
File: modules/core-ucp.mdc
// Types defined BEFORE implementation
interface CheckoutSession {
ucp: UCPVersion;
id: string;
status: CheckoutStatus;
currency: string;
buyer?: Buyer;
lineItems: LineItem[];
totals: Total[];
payment?: PaymentInfo;
// ...
}
type CheckoutStatus =
| 'incomplete'
| 'ready_for_payment'
| 'ready_for_complete'
| 'completed'
| 'expired'
| 'cancelled';
Files: modules/*.mdc
Files: modules/*.mdc
## File Structure
src/modules/checkout/
βββ index.ts # Module exports
βββ service.ts # Main checkout service
βββ session-manager.ts # Session lifecycle
βββ cart-mapper.ts # Wix β UCP mapping
βββ pricing-engine.ts # Calculations
βββ state-machine.ts # Status transitions
βββ types.ts # Module types
βββ routes.ts # API endpoints
File: practices/tdd.mdc
- β NEVER write implementation without a failing test first
- β NEVER skip the red phase
- β
ALWAYS write test before implementation
- β
ALWAYS confirm test fails before implementing
| Phase | Action |
|---|---|
| π΄ RED | Write failing test |
| β GREEN | Write minimal code to pass |
| π REFACTOR | Clean up while tests pass |
File: infrastructure/deployment.mdc
# Render services defined before writing code
services:
- name: wix-ucp-api
type: web_service
runtime: node
plan: starter
- name: wix-ucp-db
type: postgres
plan: free
- name: wix-ucp-redis
type: redis
plan: free
File: infrastructure/deployment.mdc
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β RENDER PLATFORM β
β β
β ββββββββββββββ βββββββββββ βββββββββββ β
β β Web Serviceβ β Postgresβ β Redis β β
β β (API) ββββΆβ(Storage)β β (Cache) β β
β ββββββββββββββ βββββββββββ βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
File: practices/security.mdc
| Area | Requirement |
|---|---|
| Auth | JWT with jose library |
| Validation | Zod schemas on all inputs |
| Rate Limiting | @fastify/rate-limit |
| Headers | @fastify/helmet |
| Tokens | 15-minute TTL, checkout-bound |
| Secrets | Environment variables only |
π Define types β π Define APIs β π Define tests
π€ "Implement the checkout module following checkout.mdc"
β
Run tests β π§ Fix issues β π Update rules
| Metric | Value |
|---|---|
| Modules | 8 |
| MCP Tools | 16 |
| Test Cases | 493+ |
| Code Coverage | 70%+ |
| API Endpoints | 25+ |
| Time to Deploy | Hours, not weeks |
# Module: [Name]
## Purpose
[One-line description]
## File Structure
[Directory tree]
## API Endpoints
[Request/Response specs]
## Service Interface
[Method signatures]
## Testing Requirements
[What to test]
| Rule File | Purpose |
|---|---|
00-project-overview.mdc |
Master blueprint, architecture |
modules/core-ucp.mdc |
Types, schemas, utilities |
modules/payment-handler.mdc |
Tokenization spec |
modules/checkout.mdc |
Checkout capability |
modules/discovery.mdc |
Profile advertisement |
modules/identity.mdc |
OAuth linking |
modules/orders.mdc |
Order management |
modules/mcp-bridge.mdc |
AI agent interface |
infrastructure/deployment.mdc |
Render hosting |
practices/tdd.mdc |
Test-first rules |
practices/testing.mdc |
Testing strategy |
practices/security.mdc |
Security practices |
"The best code is the code you don't have to debug because it was specified correctly from the start."
By writing detailed specifications in Cursor Rules before coding:
.cursor/rules/
Questions about specification-first development?
Browse the rules: https://github.com/itayshmool/wix-ucp/tree/main/.cursor/rules