LLM Export
Generate LLM-ready prompts from email analysis results for automated fixing.
generateFixPrompt
Generates a structured Markdown prompt that an LLM can use to fix email compatibility issues.
function generateFixPrompt(options: ExportPromptOptions): stringParameters
interface ExportPromptOptions {
originalHtml: string; // The original email HTML/JSX/MJML
warnings: CSSWarning[]; // Warnings from analyzeEmail()
scores: Record<string, {
score: number;
errors: number;
warnings: number;
info: number;
}>;
scope: "all" | "current"; // Fix all clients or just one
selectedClientId?: string; // Required when scope is "current"
format?: "html" | "jsx" | "mjml" | "maizzle"; // Input format (default: "html")
}Returns
A Markdown string containing:
- Context — format, scope, issue counts
- Original email code — the full source in a code block
- Compatibility scores table — per-client scores
- Detected issues — grouped by severity with before/after fixes
- Instructions — what the LLM should do
Example
import {
analyzeEmail,
generateCompatibilityScore,
generateFixPrompt,
} from "@emailens/engine";
const warnings = analyzeEmail(html);
const scores = generateCompatibilityScore(warnings);
const prompt = generateFixPrompt({
originalHtml: html,
warnings,
scores,
scope: "all",
format: "html",
});
// Send `prompt` to Claude, GPT, or any LLM to get a fixed versionScoped to a single client
const prompt = generateFixPrompt({
originalHtml: html,
warnings,
scores,
scope: "current",
selectedClientId: "outlook-windows-legacy",
format: "html",
});This generates a focused prompt with only Outlook Classic (Word engine) issues and fixes.
Framework-specific prompts
When format is set to "jsx", "mjml", or "maizzle", the generated prompt includes framework-specific instructions. For example, with format: "jsx" the prompt tells the LLM to use React Email components (Row, Column, Font, etc.) rather than raw HTML tables.
const prompt = generateFixPrompt({
originalHtml: jsxSource,
warnings,
scores,
scope: "all",
format: "jsx",
});
// Prompt includes: "Use React Email components..."Use with the MCP server
The MCP server's preview_email tool returns data in a format that pairs well with generateFixPrompt. After previewing an email in Claude, you can ask Claude to fix the issues and it will have all the context it needs.