This guide explains how to set up a local codebase for an AI coding agent, such as Claude Code, Codex, or Cursor. The agent uses the codebase to build Drupal Canvas assets for Source CMS Content Management System (CMS): Code Components as React components styled with Tailwind CSS, and pages, content templates, and global regions as json-render specs.
This workflow uses the following tools and services:
Source CMS: Serves as the destination site.
GitHub repository: Stores and versions code. This is optional but strongly recommended.
Local terminal: Runs Drupal Canvas Workbench for local preview. You can also run the coding agent in the terminal.
AI coding agent: Uses the local codebase, tools, and agent skills to build Drupal Canvas assets.
Code editor or IDE: Supports manual code changes when required.
Drupal Canvas AI Builder Workflow Summary
Phase
Category
Task
Description
Phase 1:
Getting started and setup
Setup and workflow
(Choose path A or path B)
Path A:
GitHub Sync setup
(Recommended)
Recommended workflow. Uses GitHub as the source of truth.
Connect a GitHub repository, clone it, install dependencies, create a .env file, and login.
GitHub Sync workflow
Pull changes, work in editor/agent, commit/push, and allow synchronization.
Path B:
Manual CLI setup
(Advanced)
Advanced workflow. Allows direct publishing without Github.
Access site, add API client, store secret, select scopes, and save. Create project, select template and AI agent.
Copy .env.example to .env, set URL and credentials.
Manual CLI workflow
Pull latest changes, work locally, and push changes.
Phase 2:
Building with the agent
Local development
AI agent setup
Open the project in the AI coding agent. Seed the project by copying example directories.
Prerequisites
A Source CMS site is created and accessible.
Github is installed on the local computer.
Node.js v20 or a later version is installed on the local computer.
Phase 1: Getting started and setup
Proper setup prepares the local environment and the Source CMS site for site building. The following sections outline the prerequisites, explain how to select an appropriate workflow, and provide instructions for establishing the codebase using either GitHub synchronization or the manual Canvas CLI.
Setup and workflows
Proper site configuration ensures compatibility with generated Drupal Canvas assets. It is recommended to create the Source CMS site from the Blank template. To obtain a larger set of starter components, use the Default site template.
Note
For optimal results, use the Blank or Default site templates.
Choosing a setup workflow
Source CMS GitHub bidirectional synchronization: (Recommended) Select this option to implement the recommended team workflow with GitHub as the source of truth. Commit and push to GitHub. Source CMS synchronizes the repository changes.
Manual Drupal Canvas command-line tool (CLI) synchronization: (Advanced) Select this option to publish directly from a local codebase or when GitHub synchronization is absent.
Source CMS–GitHub sync
This setup utilizes GitHub to manage version control and automatically synchronize select site configuration with Source CMS. The recommended workflow connects the Source CMS site to a GitHub repository. After connecting a repository, Source CMS prepares the Drupal Canvas project structure in that repository and keeps generated Drupal Canvas assets synchronized with version control.
To configure the repository, do the following:
Connect a GitHub repository. For instructions, refer to GitHub sync.
Run the following command in the local terminal to clone the connected repository:
Run the following command to authenticate with Source CMS:
npx canvas login
Workflow with Source CMS–GitHub sync
After configuring the repository, keep version control in sync by pushing local changes to GitHub rather than pushing directly to Source CMS.
To use GitHub as the source of truth for generated Drupal Canvas assets, do the following:
Pull the latest changes from the GitHub repository.
Work locally in a code editor or AI coding agent.
Commit and push changes to GitHub.
Source CMS synchronizes the pushed changes to the site.
Important
Do not run npx canvas push from this local codebase. Allow the GitHub synchronization process to publish repository changes to Source CMS.
Use npx canvas pull only when the repository requires the current Source CMS state. For example, run the command before enabling synchronization for pages, content templates, or global regions that were previously excluded from synchronization. This prevents the GitHub synchronization from treating missing local files as deletions when it next updates Source CMS.
Manual Drupal Canvas CLI synchronize
The manual synchronization workflow allows direct publishing of local codebase changes to Source CMS without relying on the build-in GitHub synchronization. Select this workflow to synchronize changes with Source CMS manually through Drupal Canvas CLI.
To create an API client for Drupal Canvas CLI authentication in Source CMS, do the following:
Workflow with manual Drupal Canvas CLI synchronize
Use the Canvas CLI to manually push and pull assets when automated version control synchronization is not active.
Version control remains strongly recommended for this workflow, especially when multiple users work on the Drupal Canvas assets. The npx canvas pull command synchronizes Code Components. The command does not pull supporting imports unless they are also Code Components. Keep third-party dependencies, shared JavaScript modules, SVGs, images, and other supporting files in version control.
To synchronize Drupal Canvas assets between the local codebase and Source CMS with Drupal Canvas CLI, do the following:
On your local machine, open the terminal.
Run the following command before starting work, because Source CMS can have newer changes:
Run npx canvas pull
Work locally in a code editor or AI coding agent.
Run the following command to publish local changes to Source CMS:
npx canvas push
Phase 2: Building with the agent
Work with an AI coding agent
AI coding agents utilize specific skills and the local codebase to generate and edit Drupal Canvas assets. Both setups yield a local codebase connected to Source CMS. Open the project in the AI coding agent. The codebase includes agent skills in .agents/skills/ to create and edit Code Components, pages, content templates, and global regions.
You can start from the examples, or you can ask the agent to generate new assets.
To seed the project with examples, copy the following directories:
Copy examples/components/ to src/components/.
Copy examples/pages/ to pages/.
Copy examples/regions/ to regions/.
The agent can add packages, shared code, SVGs, and other static assets from the local codebase. Use the Code Components imports and assets reference for supported import patterns. The repository also includes checks for the agent to run during development.
Local preview with Drupal Canvas Workbench
Drupal Canvas Workbench provides a local environment to review changes before synchronization with Source CMS. Use Workbench to preview Code Components, pages, global regions, and content templates before synchronizing changes to Source CMS. You can also ask the AI coding agent to use Workbench to verify its changes against the local preview.
To start Drupal Canvas Workbench from the local terminal, run the following command:
AI coding agents require design references or structural context to accurately generate Drupal Canvas assets.
Your AI coding agent can use one or more references as input, including:
Figma files or frames.
Live URLs.
Existing component libraries or codebases.
Screenshots, copy, brand guidelines, or design tokens.
When using multiple inputs, specify which source is authoritative if the references conflict. Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs using <figma-url>, <url>, and patterns from <path-to-codebase>. Treat Figma as the source of truth for layout. Run local visual QA in Workbench.
Building from a live URL
Your AI coding agents can use a live website as a visual baseline to generate corresponding Drupal Canvas assets.
To build from a live website, do the following:
Open the agent harness.
Enter the following instruction, replacing <url> with the public URL you want to use as a design reference:
Build Drupal Canvas Code Components, page specs, and region specs from <url>. Run local visual QA in Workbench.
After you submit the instruction, the agent inspects the URL, creates local Drupal Canvas assets, and verifies the result in Workbench.
Building from Figma
AI coding agents extract precise design contexts directly from Figma using the Figma MCP server. Figma MCP is useful when starting from a Figma file or URL. The server provides the agent with design context from Figma, such as frames, layers, and design tokens.
Configure Figma MCP in the AI coding agent. For instructions, refer to the Figma MCP server guide.
Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs from <figma-url>. Run local visual QA in Workbench
Navigation menus
To manage site structure effectively, the AI coding agent modifies navigation menus directly on the remote Source CMS site. Source CMS provides an MCP server that the AI coding agent uses for menu and menu link work.
To configure and use the Source MCP for navigation menus, do the following:
Ensure that Source MCP is enabled on the Source CMS site.
Obtain the connection details at /admin/config/services/mcp.
Connect the Source MCP as an HTTP MCP server in the AI coding agent.
Request the agent to inspect existing menus before making changes.
For example, use the following prompt:
Use Source MCP to add menu links for the new pages
Drupal Canvas AI Builder
This guide explains how to set up a local codebase for an AI coding agent, such as Claude Code, Codex, or Cursor. The agent uses the codebase to build Drupal Canvas assets for Source CMS Content Management System (CMS): Code Components as React components styled with Tailwind CSS, and pages, content templates, and global regions as json-render specs.
This workflow uses the following tools and services:
Source CMS: Serves as the destination site.
GitHub repository: Stores and versions code. This is optional but strongly recommended.
Local terminal: Runs Drupal Canvas Workbench for local preview. You can also run the coding agent in the terminal.
AI coding agent: Uses the local codebase, tools, and agent skills to build Drupal Canvas assets.
Code editor or IDE: Supports manual code changes when required.
Drupal Canvas AI Builder Workflow Summary
Phase
Category
Task
Description
Phase 1:
Getting started and setup
Setup and workflow
(Choose path A or path B)
Path A:
GitHub Sync setup
(Recommended)
Recommended workflow. Uses GitHub as the source of truth.
Connect a GitHub repository, clone it, install dependencies, create a .env file, and login.
GitHub Sync workflow
Pull changes, work in editor/agent, commit/push, and allow synchronization.
Path B:
Manual CLI setup
(Advanced)
Advanced workflow. Allows direct publishing without Github.
Access site, add API client, store secret, select scopes, and save. Create project, select template and AI agent.
Copy .env.example to .env, set URL and credentials.
Manual CLI workflow
Pull latest changes, work locally, and push changes.
Phase 2:
Building with the agent
Local development
AI agent setup
Open the project in the AI coding agent. Seed the project by copying example directories.
Prerequisites
A Source CMS site is created and accessible.
Github is installed on the local computer.
Node.js v20 or a later version is installed on the local computer.
Phase 1: Getting started and setup
Proper setup prepares the local environment and the Source CMS site for site building. The following sections outline the prerequisites, explain how to select an appropriate workflow, and provide instructions for establishing the codebase using either GitHub synchronization or the manual Canvas CLI.
Setup and workflows
Proper site configuration ensures compatibility with generated Drupal Canvas assets. It is recommended to create the Source CMS site from the Blank template. To obtain a larger set of starter components, use the Default site template.
Note
For optimal results, use the Blank or Default site templates.
Choosing a setup workflow
Source CMS GitHub bidirectional synchronization: (Recommended) Select this option to implement the recommended team workflow with GitHub as the source of truth. Commit and push to GitHub. Source CMS synchronizes the repository changes.
Manual Drupal Canvas command-line tool (CLI) synchronization: (Advanced) Select this option to publish directly from a local codebase or when GitHub synchronization is absent.
Source CMS–GitHub sync
This setup utilizes GitHub to manage version control and automatically synchronize select site configuration with Source CMS. The recommended workflow connects the Source CMS site to a GitHub repository. After connecting a repository, Source CMS prepares the Drupal Canvas project structure in that repository and keeps generated Drupal Canvas assets synchronized with version control.
To configure the repository, do the following:
Connect a GitHub repository. For instructions, refer to GitHub sync.
Run the following command in the local terminal to clone the connected repository:
Run the following command to authenticate with Source CMS:
npx canvas login
Workflow with Source CMS–GitHub sync
After configuring the repository, keep version control in sync by pushing local changes to GitHub rather than pushing directly to Source CMS.
To use GitHub as the source of truth for generated Drupal Canvas assets, do the following:
Pull the latest changes from the GitHub repository.
Work locally in a code editor or AI coding agent.
Commit and push changes to GitHub.
Source CMS synchronizes the pushed changes to the site.
Important
Do not run npx canvas push from this local codebase. Allow the GitHub synchronization process to publish repository changes to Source CMS.
Use npx canvas pull only when the repository requires the current Source CMS state. For example, run the command before enabling synchronization for pages, content templates, or global regions that were previously excluded from synchronization. This prevents the GitHub synchronization from treating missing local files as deletions when it next updates Source CMS.
Manual Drupal Canvas CLI synchronize
The manual synchronization workflow allows direct publishing of local codebase changes to Source CMS without relying on the build-in GitHub synchronization. Select this workflow to synchronize changes with Source CMS manually through Drupal Canvas CLI.
To create an API client for Drupal Canvas CLI authentication in Source CMS, do the following:
Workflow with manual Drupal Canvas CLI synchronize
Use the Canvas CLI to manually push and pull assets when automated version control synchronization is not active.
Version control remains strongly recommended for this workflow, especially when multiple users work on the Drupal Canvas assets. The npx canvas pull command synchronizes Code Components. The command does not pull supporting imports unless they are also Code Components. Keep third-party dependencies, shared JavaScript modules, SVGs, images, and other supporting files in version control.
To synchronize Drupal Canvas assets between the local codebase and Source CMS with Drupal Canvas CLI, do the following:
On your local machine, open the terminal.
Run the following command before starting work, because Source CMS can have newer changes:
Run npx canvas pull
Work locally in a code editor or AI coding agent.
Run the following command to publish local changes to Source CMS:
npx canvas push
Phase 2: Building with the agent
Work with an AI coding agent
AI coding agents utilize specific skills and the local codebase to generate and edit Drupal Canvas assets. Both setups yield a local codebase connected to Source CMS. Open the project in the AI coding agent. The codebase includes agent skills in .agents/skills/ to create and edit Code Components, pages, content templates, and global regions.
You can start from the examples, or you can ask the agent to generate new assets.
To seed the project with examples, copy the following directories:
Copy examples/components/ to src/components/.
Copy examples/pages/ to pages/.
Copy examples/regions/ to regions/.
The agent can add packages, shared code, SVGs, and other static assets from the local codebase. Use the Code Components imports and assets reference for supported import patterns. The repository also includes checks for the agent to run during development.
Local preview with Drupal Canvas Workbench
Drupal Canvas Workbench provides a local environment to review changes before synchronization with Source CMS. Use Workbench to preview Code Components, pages, global regions, and content templates before synchronizing changes to Source CMS. You can also ask the AI coding agent to use Workbench to verify its changes against the local preview.
To start Drupal Canvas Workbench from the local terminal, run the following command:
AI coding agents require design references or structural context to accurately generate Drupal Canvas assets.
Your AI coding agent can use one or more references as input, including:
Figma files or frames.
Live URLs.
Existing component libraries or codebases.
Screenshots, copy, brand guidelines, or design tokens.
When using multiple inputs, specify which source is authoritative if the references conflict. Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs using <figma-url>, <url>, and patterns from <path-to-codebase>. Treat Figma as the source of truth for layout. Run local visual QA in Workbench.
Building from a live URL
Your AI coding agents can use a live website as a visual baseline to generate corresponding Drupal Canvas assets.
To build from a live website, do the following:
Open the agent harness.
Enter the following instruction, replacing <url> with the public URL you want to use as a design reference:
Build Drupal Canvas Code Components, page specs, and region specs from <url>. Run local visual QA in Workbench.
After you submit the instruction, the agent inspects the URL, creates local Drupal Canvas assets, and verifies the result in Workbench.
Building from Figma
AI coding agents extract precise design contexts directly from Figma using the Figma MCP server. Figma MCP is useful when starting from a Figma file or URL. The server provides the agent with design context from Figma, such as frames, layers, and design tokens.
Configure Figma MCP in the AI coding agent. For instructions, refer to the Figma MCP server guide.
Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs from <figma-url>. Run local visual QA in Workbench
Navigation menus
To manage site structure effectively, the AI coding agent modifies navigation menus directly on the remote Source CMS site. Source CMS provides an MCP server that the AI coding agent uses for menu and menu link work.
To configure and use the Source MCP for navigation menus, do the following:
Ensure that Source MCP is enabled on the Source CMS site.
Obtain the connection details at /admin/config/services/mcp.
Connect the Source MCP as an HTTP MCP server in the AI coding agent.
Request the agent to inspect existing menus before making changes.
For example, use the following prompt:
Use Source MCP to add menu links for the new pages
Local preview
Run npm run dev to start Drupal Canvas Workbench and visually verify components iteratively during the build.
Generation inputs
(Choose one or more sources)
Input sources
Instruct the agent on which source is authoritative when combining multiple inputs.
Build from live URL
Optional input method for visual baselines. Provide public URL and run build/QA prompt.
Build from Figma
Optional input method using design context. Use Figma MCP to provide design context and run build/QA prompt.
Remote Configuration
Configure navigation
Enable Source MCP, get connection details, connect to AI agent, and request menu inspection.
Did not find what you were looking for?
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Local preview
Run npm run dev to start Drupal Canvas Workbench and visually verify components iteratively during the build.
Generation inputs
(Choose one or more sources)
Input sources
Instruct the agent on which source is authoritative when combining multiple inputs.
Build from live URL
Optional input method for visual baselines. Provide public URL and run build/QA prompt.
Build from Figma
Optional input method using design context. Use Figma MCP to provide design context and run build/QA prompt.
Remote Configuration
Configure navigation
Enable Source MCP, get connection details, connect to AI agent, and request menu inspection.
Did not find what you were looking for?
If this content did not answer your questions, try searching or contacting our support team for further assistance.