Convert Figma designs to production-ready Salesforce Visualforce email templates using AI
This project enables designers to create Salesforce email templates directly from Figma designs. Using Figma Code Connect and Claude AI in Cursor, we automatically generate email-compatible Visualforce markup that follows Salesforce best practices.
- ✅ AI-Powered Conversion: Claude analyzes Figma components and generates proper Visualforce code
- ✅ Email-Compatible: Table-based layouts, 600px width, inline styles for Outlook compatibility
- ✅ Salesforce Best Practices: Uses
<apex:>components, proper escaping, merge fields - ✅ Designer-Friendly: No coding knowledge required
- ✅ Version Controlled: All templates stored in Git
- Figma account with Code Connect access
- Cursor IDE with Claude AI
- Node.js installed
Create Token:
- Go to Figma Settings → Personal Access Tokens
- Click "Generate new token"
- Name it:
BMS Code Connect
Required Permissions:
- ✅ File content: Read
- ✅ Code Connect: Write
Set Token:
# Add to your shell profile for persistence
echo 'export FIGMA_ACCESS_TOKEN="figd_your_token_here"' >> ~/.zshrc
source ~/.zshrccd vf-templates
npm installThis is our recommended workflow using Claude in Cursor:
-
In Figma:
- Create a component (or select existing component)
- Right-click → "Copy link to selection"
-
In Cursor:
- Open chat (Cmd+L)
- Paste the Figma URL with
@prefix:
@https://www.figma.com/design/YOUR_FILE?node-id=XXX-XXX Create a Visualforce email template for this component -
Claude will:
- Fetch the component structure from Figma API
- Analyze layers, text, colors, and layout
- Generate proper Visualforce email markup
- Create the
.figma.tsfile incomponents/ - Publish it to Figma Code Connect
-
View in Figma:
- Open your Figma file
- Switch to Dev Mode (bottom right)
- Select the component
- See the generated Visualforce code!
# Validate templates locally
npm run figma:parse
# Publish to Figma
npm run figma:publish
# Create new template stub
npm run figma:create "figma_url"vf-templates/
├── components/ # Published Code Connect templates (active)
│ ├── footer.figma.ts
│ └── warning.figma.ts
├── examples/ # Example templates (reference only)
│ ├── bms-component.figma.template.js
│ ├── button.figma.template.js
│ ├── contact-list.figma.template.js
│ └── form-card.figma.template.js
├── figma.config.json # Code Connect configuration
├── package.json
└── README.md
All generated templates follow these constraints:
- Width: 600px maximum (email client compatibility)
- Layout: Table-based (Outlook support)
- Styling: Inline CSS only
- Components:
<apex:outputText>,<apex:outputLink>, etc. - Security:
escape="true"by default - Merge Fields:
{!Contact.Name},{!Account.Field__c}
For best results, structure your Figma components with:
- Clear hierarchy: Group related elements
- Text layers: Use actual text (not images) for dynamic content
- Consistent spacing: Use Auto Layout
- Color variables: For easy theme changes
- Semantic naming: Descriptive layer names help Claude understand intent
📖 For detailed naming conventions, see: NAMING_CONVENTIONS.md
- Footer: Contact info, legal links, copyright
- Warning Banner: Alert messages with icons
- Header: Logo, navigation, personalization
See components/ folder for examples.
# Check if token is set
echo $FIGMA_ACCESS_TOKEN
# If empty, set it again
export FIGMA_ACCESS_TOKEN="your_token"- Ensure your token has both File content: Read and Code Connect: Write permissions
- Verify you have access to the Figma file
- Make sure you're selecting an actual component (purple diamond icon)
- Regular frames won't work - convert to component first (Cmd+Option+K)
- Create components in Figma
- Use Claude in Cursor to generate Visualforce templates
- Review the generated code
- Commit to Git
- Templates automatically sync to Figma Dev Mode
Built for Bristol-Myers Squibb Cell Therapy 360 by the IDEO design team.