Skip to main content
Use AI to generate block code for the browser editor, or let a coding agent edit a CLI workspace with the Primo MCP tools.
For file-based work, run primo mcp install to connect your coding agent. The workspace’s AGENTS.md explains its layout; MCP tools provide validation and scaffolds. Review generated code, validate it, and check the rendered result before publishing.

Watch the workflow

Build a component with an editable field

Watch the field setup and paste a generated component into Primo. Download video · Download captions
  1. Open the page type to create a reusable block.
  2. Switch to content and create a Text field.
  3. Label the field Headline. Its key is headline.
  4. Set the default content for the field.
  5. Reference the field in your component markup.
  6. Preview the result, then create the block.

Prompt Template

Workflow

1

Generate code

Send the prompt to your chosen AI tool. This workflow uses that external tool to generate code; paste the result into Primo in the next step.
2

Paste into Primo

Copy generated code into a new block’s code editor.
3

Add fields

Switch to Content and add each field with its matching type. Field names in the generated code do not create fields automatically.
4

Test

Preview and refine as needed.

Example

Prompt:
Example output:
Then add fields in Primo: icon (Image), headline (Text), description (Text), cta_link (Link)

Common Issues

AI uses export let: Remove legacy export let declarations. The browser compiler supplies field props automatically unless your component declares its own $props(). If you use $props(), declare every field the component reads.
Missing null checks: Add them, especially for images and links.
Unnecessary imports: Use imports only when their module can be resolved by your preview and publishing workflow. Do not assume that another block is available as a relative Svelte import.

Next Steps

Writing Components

Learn to write components from scratch.

Working with Fields

Master field configuration.