Skip to content

CLI

The boilerplate includes a CLI for scaffolding collections, globals, and blocks. All commands run through DDEV to keep environments consistent. Access it via DDEV:

Terminal window
ddev boilerplate <command>

Scaffolds a new PayloadCMS collection with sensible defaults.

Terminal window
ddev boilerplate collection [options]

Options:

  • --name=<name> — Collection name, plural, in kebab-case (e.g., blog-posts)
  • --type=<type> — Collection type: public or private

Missing options are asked for interactively.

Example:

Terminal window
# Interactive prompt
ddev boilerplate collection
# With options
ddev boilerplate collection --name=blog-posts --type=public

What it creates:

  • src/collections/[name].ts, built with publicCollection() or privateCollection()

The factory provides the defaults, such as access control and versioning. Public collections also get SEO fields and revalidation hooks.

After running:

  1. Add the collection to payload.config.ts
  2. For public collections, register the route in src/lib/url/slug.ts
  3. Add to src/app/(frontend)/sitemap.ts
  4. Run ddev pnpm generate:types
  5. Create the frontend route in src/app/(frontend)/[name]/

Scaffolds a new PayloadCMS global.

Terminal window
ddev boilerplate global [options]

Options:

  • --name=<name> — Global name, singular, in kebab-case (e.g., site-settings)

Example:

Terminal window
# Interactive prompt
ddev boilerplate global
# With option
ddev boilerplate global --name=site-settings

What it creates:

  • src/globals/[name].ts, built with siteGlobal()

After running:

Add the global to payload.config.ts and run ddev pnpm generate:types.


Scaffolds a new content block with config and component files.

Terminal window
ddev boilerplate block [options]

Options:

  • --name=<name> — Block name in kebab-case (e.g., hero-banner)

Example:

Terminal window
# Interactive prompt
ddev boilerplate block
# With option
ddev boilerplate block --name=hero-banner

What it creates:

  • src/blocks/[name]/config.ts — Block configuration
  • src/blocks/[name]/[name]-block.tsx — React component
  • src/blocks/[name]/[name].scss — Styles

After running:

  1. Register the block in src/blocks/render-blocks.tsx
  2. Add the block to a collection’s blocks array

Adds or removes optional boilerplate features. Features ship outside the lean base and are installed on demand — forms is the first.

Terminal window
ddev boilerplate feature add <name>
ddev boilerplate feature remove <name>
ddev boilerplate feature list

Example:

Terminal window
ddev boilerplate feature add forms

What add forms does:

  • Copies the form renderer into src/components/form/ and the plugin config into src/plugins/
  • Adds the @payloadcms/plugin-form-builder, react-hook-form, and @hookform/resolvers dependencies
  • Registers the plugin in src/plugins/plugins.ts

After running:

  1. ddev pnpm install
  2. ddev pnpm generate:types
  3. Create a migration: ddev pnpm payload migrate:create

See the Forms guide for details.


Beyond the custom CLI, these scripts are available:

Command Purpose
ddev pnpm dev Start development server
ddev pnpm build Build for production
ddev pnpm lint Check with Biome and Stylelint
ddev pnpm lint:fix Fix with Biome and Stylelint
ddev pnpm typecheck Type-check with tsc
ddev pnpm format Auto-format code
ddev pnpm test Run tests
ddev pnpm generate:types Generate PayloadCMS types
ddev pnpm payload migrate Run database migrations
ddev pnpm payload migrate:status Check migration status