Overview
Reads a brand guide or style reference, extracts design tokens (colors, fonts, spacing, tone rules, logo usage), then applies those constraints to a target document. Reports compliance violations, makes corrections according to the specified strictness level, and produces a styled output alongside a compliance report.
Workflow
<Definition - Brand Profile> A structured extraction from a brand guide containing:
- colors: primary, secondary, accent, background, text_primary, text_secondary
- typography: heading_font, body_font, heading_sizes (h1/h2/h3), body_size, line_height
- tone: voice style, encouraged patterns (dos), prohibited patterns (donts), terminology preferences
- logo: placement, minimum_size, clear_space
- formatting: margins, paragraph_spacing, bullet_style, table_style, header_footer rules
Not all fields will be present in every brand guide. The profile contains only what was explicitly found. </Definition - Brand Profile>
<Definition - Compliance Score> Percentage of audited dimensions that pass. Calculated as: (passing_categories / total_auditable_categories) * 100. Categories: colors, typography, tone, formatting, logo, terminology. </Definition - Compliance Score>
<Workflow - Enforce Template description="End-to-end brand enforcement: parse guide, audit, correct, output." tools=[file_read, file_read_pdf, file_read_docx, file_read_pptx, run_python, file_write, open_in_session_tab] triggers=["User asks to apply brand guide", "enforce template", "match this style", "make it consistent with our brand"]
-
[Decide] Is {{brand_guide}} a file path or a saved profile name?
- File path: proceed to step 2.
- Profile name: check artifacts/brand-profiles/{{brand_guide}}-profile.yaml. If found, load it and skip to step 4. If not found, ask user for the file path. Validate: One path is chosen. If fails: Ask user to clarify whether they are referencing a saved profile or providing a new file.
-
[Agent] Parse the brand guide file using the appropriate reader (file_read_pdf for PDF, file_read_docx for DOCX, file_read for other formats). Extract all design token information into a structured brand profile per <Definition - Brand Profile>. Validate: At least one category (colors, typography, or tone) successfully extracted with concrete values. If fails: Report which categories could not be extracted and ask user to point to specific pages/sections containing the brand rules. Offer to proceed with partial rules.
-
[Ask user] Present extracted brand profile summary. Confirm it looks correct before proceeding. Validate: User confirms or provides corrections. If fails: Adjust profile per user feedback and re-present.
-
[Agent] Load the source document ({{source_document}}) using the appropriate reader. Preserve full structure (headings, paragraphs, tables, images, metadata). Validate: Document loads successfully and contains parseable content. If fails: Report the format issue. Ask user for an alternative format or path.
-
[Agent] Audit the source document against the brand profile. Check each applicable dimension:
- Color compliance: Are colors consistent with the palette? Flag off-brand colors with their locations.
- Typography compliance: Correct fonts, sizes, and hierarchy?
- Tone compliance: Does language match voice guidelines? Flag jargon violations or banned terminology.
- Formatting compliance: Margins, spacing, bullet styles correct?
- Logo compliance: Proper placement and sizing? (if applicable and detectable)
- Terminology compliance: Preferred terms used? Banned terms present?
Produce a compliance report table:
Category Status Issues Found Severity Calculate overall compliance score per <Definition - Compliance Score>. Validate: At least one category assessed. Report table generated. If fails: Proceed with best-effort assessment on available categories.
-
[Decide] What is the strictness level?
- "advisory": Save compliance report to artifacts/compliance-report-[name].md. Present to user. Skip to step 9.
- "moderate" or "strict": Proceed to step 7. Validate: Strictness is one of the three valid values. If fails: Default to "moderate".
-
[Agent] Apply corrections using run_python:
- Swap off-brand colors to nearest brand-approved color.
- Replace fonts with brand typography.
- Adjust heading hierarchy to match brand sizes.
- Fix spacing, margins, bullet styles.
- Replace banned terminology with preferred alternatives.
- (strict only) Rewrite flagged tone violations to match brand voice.
- (strict only) Insert/reposition logo if template requires it. Validate: Corrections applied without corrupting document structure. Re-audit shows improved compliance score. If fails: Report which items could not be auto-corrected. Present them for manual review.
-
[Agent] Generate styled output file in {{output_format}} format:
- "same": Match the input file format.
- "docx": Apply styles via python-pptx/openpyxl, set fonts, colors, paragraph formatting.
- "html": Generate with inline styles matching brand tokens.
- "pptx": Apply slide master colors, fonts, logo placement.
- "md": Apply tone corrections and structure formatting. Save to: artifacts/styled-[original-name].[ext] Validate: Output file created, non-empty, and valid format. If fails: Fall back to markdown output with compliance notes inline.
-
[Agent] Save compliance report to artifacts/compliance-report-[original-name].md. Open styled output (if created) and compliance report in session tabs. Present summary:
- Compliance improved: [X]% to [Y]%
- [N] corrections applied
- [M] items flagged for manual review
- Output saved: artifacts/styled-[filename].[ext] Validate: User can view the output. If fails: Provide file path and inline summary.
-
[Ask user] "I've extracted your brand profile. Want me to save it so you can reference it by name next time without re-uploading the guide?"
- Yes: Save to artifacts/brand-profiles/[brand-name]-profile.yaml
- No: Done. Validate: If yes, profile file saved and readable. If fails: Provide extracted profile as inline YAML for user to save manually.
</Workflow - Enforce Template>


