Skip to content

Working with an AI agent

Velocity CMS is built to be worked on by a coding agent such as Claude Code, Codex or Cursor. There are two kinds of work, and each has its own tools:

  • Changing the site’s code: adding a content type, a section, a form or a plugin. The agent follows the rules and skills the CMS installs, and check reviews the result.
  • Changing the site’s content: writing entries and building pages. Claude and ChatGPT connect to the site’s MCP server by themselves. An agent or a script that takes a token uses an access token, with the content commands or the MCP server.

npx velocity-cms init writes these into the site:

FileWhat it is
.agents/cms.mdThe CMS’s rules for an agent changing the site.
.agents/skills/cms-*/SKILL.mdNine skills, one per task. The same files are written to .claude/skills/.
AGENTS.mdA line that points at the two above. Your own notes in it are left alone.

The nine skills:

SkillFor
cms-add-to-siteAdding the CMS to an Astro site.
cms-add-content-typeA new content type and its fields.
cms-add-sectionA new kind of section: its block and the component that draws it.
cms-add-formA form and the section that shows it.
cms-connect-pageMaking an existing page read its content from the CMS.
cms-import-contentBringing content in from files.
cms-set-up-crmThe pipeline, custom fields and forms that start deals.
cms-write-pluginA plugin for the site.
cms-deployDeploying the site.

After you upgrade the CMS, bring them up to date:

Terminal window
npx velocity-cms agents

It replaces .agents/cms.md and the cms-* skills and leaves the site’s own skills alone. Keep your own notes in AGENTS.md, not in cms.md.

Terminal window
npx velocity-cms check

check looks at a site the way a reviewer would. Each finding names the rule (a heading of cms.md), the file and the fix, and an error exits with 1, so it can run in CI. --json prints the findings as JSON. It finds:

  • A page that reads the CMS but is built ahead of time, directly or through its layout.
  • A block with no component, or a component with no block.
  • A section that offers a form and never draws one.
  • Code that reads around the CMS’s helpers.
  • A missing secret, adapter, address or cache tag.
  • .env in git.
  • Agent rules older than the CMS the site runs.

Every site serves an MCP server at /api/cms/mcp, and an app that can sign in by itself needs only that address. There is no token to copy and nothing to set up on the site.

  1. In the editor, open Settings, Access tokens and copy the MCP address from the Connected apps card. It is your site’s address followed by /api/cms/mcp, such as https://example.com/api/cms/mcp.
  2. In the app, add it as a custom connector. In Claude: Settings, Connectors, Add custom connector. In ChatGPT: Settings, Connectors, and add a custom one. Paste the address and leave everything else empty.
  3. Press Connect in the app. It opens your site’s editor in the browser.
  4. Sign in with your passkey or an email link if you are not signed in. A link from the email lands on the same question.
  5. Choose what the app may do, then press Allow. You are sent back to the app, and it is connected.
On the questionWhat it means
What it may doWho the app acts as: “Writes and edits” (an editor) or “Writes drafts” (an author). Never an owner.
May publishLeft off, everything the app writes waits as a draft for someone to publish.
May read contacts, deals and what forms receivedLets it read and change personal data. Left off, those tools are not listed to it.

Only an owner can connect an app. Each connected app is listed on the Connected apps card with what it may do, who connected it and when it was last used. The button at the end of its row disconnects it, and it is refused from its next request. An app also stops working when the person who connected it is no longer an owner, or when it has not been used for 90 days. Connect it again from the app.

This is OAuth 2.1 as the Model Context Protocol describes it: the site says where to sign in, the app registers itself, and its tokens renew themselves. Any MCP client that signs in this way works, including Claude Code (claude mcp add --transport http my-site https://example.com/api/cms/mcp, then /mcp), Cursor and VS Code.

An access token is for an agent or a script that cannot sign in by itself: the content commands below, your own code, or an MCP client you would rather hand a token.

An owner makes one in the editor under Settings, Access tokens, or from the site’s folder:

Terminal window
npx velocity-cms token "Claude on my laptop" --save

--save writes the token to .env as VELOCITY_CMS_TOKEN and never prints it.

OptionWhat it does
--role editor or --role authorWho the token acts as. Never an owner: people, plugins, settings and content types stay with a person.
--publishLets it publish. Without it, a token writes drafts only.
--personal-dataLets it read contacts and submissions. Without it, it sees neither.
--days nHow long it works, from 1 to 365 days.

A token can be taken away at once in the editor, and stops working when the person who made it is no longer an owner. Only a hash of it is kept.

With VELOCITY_CMS_TOKEN in .env, these work over the site’s API. Add --site https://example.com to work on the live site instead of the one on your computer.

Terminal window
npx velocity-cms types # the content types and their fields
npx velocity-cms type pages # one type in full, with the blocks its pages take
npx velocity-cms entries pages # a type's entries
npx velocity-cms entry <id> # one entry, its values by field key
npx velocity-cms create posts hello --data '{"title":"Hello"}'
npx velocity-cms update <id> --data '{"title":"Hello again"}'
npx velocity-cms publish <id>
npx velocity-cms sections <id> # a page's sections, in order
npx velocity-cms upload ./photo.jpg # prints the name an image field stores
npx velocity-cms export posts --out posts.json
npx velocity-cms import posts ./posts # a JSON file, a Markdown file or a folder of them

import reads front matter by field key, puts a Markdown file’s text into the formatted text field, uploads local pictures and keeps old slugs. --dry-run says what it would do. forms, submissions <form> and pipeline read the forms and the CRM when the token may read personal data.

Every site serves an MCP server at /api/cms/mcp. An app that signs in by itself is connected as above. An agent that takes a token sends it as a bearer:

https://example.com/api/cms/mcp
Authorization: Bearer vcms_…

For an agent on the same computer as the site, npx velocity-cms mcp is the same server on standard input and output.

Formatted text is read and written the same way, as { "markdown": "..." }: headings, lists, quotes, bold, italics, code in backticks and links, and where the field allows them tables, fenced code, --- dividers, pictures of the library by name, > [!TIP] callouts, <details>, a video or map address alone on its line, entry: links to the site’s entries and the template’s colours as [words]{colour=brand}. What a tool hands back can be changed and sent straight back.

Its tools call the same services as the editor, as the app or the token:

ToolsWhat they do
describe_site, get_content_type, list_blocks, list_imagesSay what the site has: its types, fields, blocks and images.
list_entries, get_entry, create_entry, update_entry, duplicate_entry, trash_entry, entry_historyRead and write entries, by field key.
get_sections, add_section, update_section, move_section, remove_section, set_sectionsBuild a page from sections.
publish_entry, unpublish_entry, schedule_entry, preview_linkPublish, schedule and preview. A token that may not publish is refused.
list_forms, create_form, list_submissions, and the tools for contacts, the pipeline, custom fields and dealsForms and the CRM. The tools for contacts, deals and submissions are listed only to a token that may read personal data.
design_new_sectionSays how to add a new kind of section in code.

Formatted text can be written as { "markdown": "..." }.

A page is built only from the blocks its field allows today, with their own fields and named looks. A tool refuses a block, a field or a look the template does not have, and names what it would take. An agent cannot send markup, a color or a size of its own, so what it builds looks like the site and stays editable in the editor.

For an idea no section can show, design_new_section hands the agent the site’s published colors and fonts, its blocks, and the steps to add a new kind of section in the site’s code: a block in the model and a component that draws it. The new section is then on the theme, and anyone can use it from the editor.