The agent loop

Let an agent write, check, render, look at, and repair a template over the CLI, hosted MCP, or the hosted assistant, all on the same files.

The product is a tight loop an agent can run on its own: write, check, render, look, repair. Every agent gets the same loop over the same files. A developer's agent uses the CLI, the hosted assistant in the dashboard uses its own tools, and any other agent uses MCP.

StepDeveloper's agent (CLI)Hosted assistantMCP
Read the projectFiles on diskinspect_project, read_filetemplates_open_workspace
EditIts own editorpatch_filestemplates_patch_workspace
Checksamva templates checkcheck_projecttemplates_check_workspace
Render a fixturesamva templates render --fixture no-trackingrender_fixturetemplates_render_fixture
Look at itsamva templates snapshotscreenshot_fixturetemplates_snapshot_fixture
Savegit commit, git pushsave_workspace, after you approvetemplates_save_workspace
Publishsamva templates publishYou publishtemplates_publish

What each step returns

  • Check compiles every template and validates every fixture, then returns diagnostics: a code, a location, and a fix for each finding. --json adds the range and severity in a form a tool can apply.
  • Render returns the subject, preheader, HTML, and plain text for one named fixture. On the CLI, --locale and --time-zone render for a specific reader. A build that failed returns no render beside the findings that explain it.
  • Look returns screenshots of one fixture. The CLI writes desktop and mobile PNG files, in light and dark, to .samva/snapshots; the MCP tool and the hosted assistant return desktop and mobile images.
  • Save appends one Git commit after validating every template and fixture. Publish needs a clean, pushed commit.

A typical repair

  1. The agent runs samva templates check --json and reads the findings.
  2. It fixes the location a finding names, such as guarding input.trackingUrl with input.trackingUrl && ....
  3. It renders the fixture that exercises the change, for example samva templates render order-shipped --fixture no-tracking.
  4. It takes a snapshot and looks at the mobile and dark variants.
  5. It commits when the check is clean.

What agents can read

  • The hosted MCP server publishes the template guide, the full reference, and a machine-readable contract as resources: samva://guide/template-editor, samva://reference/sml, and samva://reference/contract. The contract lists the components with their props, the forms of the static profile, the formatters, and the diagnostic codes, generated from the compiler so it does not drift. See Connect an agent over MCP.
  • The @samva/markup package ships the same contract as @samva/markup/contract.json, a readable generated/reference.md, and the sml skill, so an agent working in a clone has everything without a connection.
  • The samva Agent Skill routes an agent to the template authoring reference.
  • This documentation is available as Markdown, and llms.txt lists every page.

Two edits, one meaning

The canvas, the assistant, and a developer's push all land as revisions of the same file. When two revisions touch the same lines, the conflict surfaces for explicit resolution instead of one edit silently winning.

Related documentation

On this page