The Builder CLI is a command-line tool that powers several key functions for developers including code generation, code sync, and more.
- Command-line scripts are accessible through the builder.io/dev-tools NPM package.
- Some of the commands in this document are for Publish Spaces, while others are for Fusion Spaces.
Prerequisite for Publish
If you have a Publish Space, you must have integrated your codebase with Builder to use the Builder CLI. For more details, see Publish Quickstart.
To access a snippet ID:
- Within a Fusion Project, click the Develop tab.
- Click Generate Code.
- Adjust the code by prompting the AI as desired. For more details, see Get Started with Fusion.
- Click Sync Code.
An add script appears which includes the snippet ID.
Space type: Fusion or Publish Space
The auth command re-triggers authentication from the command line. This is useful should you need to change your authenticated Space or you are having any issues with authentication.
npx "@builder.io/dev-tools@latest" authTo reset your credential and log out, include the --reset flag.
npx "@builder.io/dev-tools@latest" auth --resetSpace type: Fusion or Publish Space
The auth status shows information about your Space and user account.
npx "@builder.io/dev-tools@latest" auth statusSpace type: a Fusion Space
Requirements: a local repository
The index-repo command analyzes your entire repository to understand your component architecture and typically achieves high mapping accuracy, enabling effective code generation.
npx "@builder.io/dev-tools@latest" index-repoThe index-repo command can take the following flags:
| flag | description |
|---|---|
| Your Space's Public API Key |
| Provide a specific package or scope to focus the command, such as |
| Increase the scope of indexing outside of the current directory by providing a comma-separated list of absolute paths. This is not necessary if component definitions are in the workspace you are indexing. |
| Skip the display headers. This is useful for CI or automation. |
| When set to |
| When set to |
| When set to |
| Provide the working directory for the command. |
| Allow the re-indexing process to focus on a specific component or list of components. This is useful when testing or refining document creation.
|
To instead generate code using a web interface, visit Figma to Builder. If you'd rather generate code through a command-line interface, Generate Code with Builder CLI.