forgewp CLI Command Reference
Exhaustive reference for every forgewp CLI command: build and export, diagnostics, scaffolding generators, route synchronization, localization, and database seeding.
The forgewp command-line interface is the primary operational tool for managing, developing, and exporting ForgeWP themes. It is executed via your package manager in the root directory of any ForgeWP project (pnpm forgewp <command>, npx forgewp <command>, or bun x forgewp <command>).
Commands are organized into five primary functional categories:
1. Build & Export Commands
forgewp export
Compiles your React, TypeScript, and Tailwind CSS project into an installable PHP-backed WordPress hybrid theme with block-editor integration.
pnpm forgewp export [options] [theme-directory]CLI Flags
Flag Type Description --validatebooleanExecutes post-export verification checks to confirm all generated templates, blocks, and asset manifests are complete. --strictbooleanFails on editable from/pick issues; with --validate, also fails on validation warnings. Recommended together for CI/CD.--skip-buildbooleanReuses the existing dist/ production assets from a previous build instead of running Vite again.--no-zipbooleanGenerates the compiled theme directory inside .forgewp/out/<slug>/ without packaging it into a .zip archive.-h, --helpbooleanDisplays available command options. |
|---|
Examples
# Standard export producing .forgewp/<theme-slug>.zip
pnpm forgewp export
# Production release build with strict validation gating
pnpm forgewp export --validate --strict
# Fast iteration inspecting generated PHP without re-running Vite
pnpm forgewp export --skip-build --no-zipforgewp analyze
Scans your project's components and generates a detailed report on selective hydration islands, bundle chunk sizes, and client runtime overhead.
pnpm forgewp analyzeWhat It Checks
- Identifies all interactive components extracted into
.forgewp-islands/. - Resolves Rollup chunk mappings from
dist/.vite/manifest.json. - Reports client JavaScript bundle weights per route.
- Alerts you if any unhydrated components contain DOM event listeners or state hooks.
Tip
Run forgewp analyze after pnpm forgewp export to verify that your theme's static pages maintain 0 KB of client JavaScript and that hydration islands are loaded only where intended.
2. Project Health & Maintenance
forgewp doctor
Executes comprehensive preflight diagnostic checks across your project to verify runtime environments, configuration, and internal framework files.
pnpm forgewp doctorDiagnostic Checks Performed
- Node.js Runtime Environment: The doctor checks Node.js
^22.18.0 || >=24.11.0, matching the compiler dependencies. See System Requirements to choose a compatible version. - User Configuration & Layout: Confirms presence and validity of
wp.config.ts,package.json,index.html, and adapter critical files. - Mock Database Schema: Validates syntax and presence of
cms/mock-data.tsorcms/mock-data.json. - System Framework Integrity: Compares hidden framework internal bridges against standard system blueprints.
- Hydration Diagnostics: Scans for static lint issues, such as unhydrated interactive event handlers inside
<WpQueryLoop>.
forgewp repair
Automatically restores missing or corrupted internal framework blueprint files and virtual bridges.
pnpm forgewp repairWhat It Does
- Restores internal framework files and virtual bridges back to their pristine template state.
- Preserves your typed TypeScript schemas (
cms/*.tsfiles are never overwritten). - Re-seeds default starter posts in
cms/mock-data.tsif the database file was deleted.
forgewp clean
Clears compiler caches, build directories, and temporary artifacts.
pnpm forgewp cleanPruned Directories
.forgewp/(build cache and packaged export output)dist/(compiled Vite assets).vite/(Vite dev server cache)
forgewp fresh
Factory resets the project to a clean slate, removing custom scaffolded pages and blocks while restoring default starter blueprints.
pnpm forgewp freshCaution
forgewp fresh can permanently remove custom files inside src/app/pages/, src/blocks/, and src/components/ (including ui/). It also clears build output and restores supported starter files. Commit or back up your project first; this is not a routine cache or mock-data reset. --force, -f, or -y skips confirmation.
3. Code Scaffolding Commands (make:*)
Scaffolding commands create type-safe components, block definitions, page templates, and schemas with best-practice folder conventions.
forgewp add <component>
Installs pre-built UI components from the ForgeWP component registry into src/components/ui/.
pnpm forgewp add <component> [options]Options
--style=shadcn|forgewp: Specifies design token preset.--overwrite: Replaces existing local component files.
Examples
pnpm forgewp add navbar
pnpm forgewp add hero footer --overwriteforgewp make:block <Name>
Scaffolds a custom Gutenberg block in src/blocks/<Name>.tsx configured with defineBlock().
pnpm forgewp make:block <Name> [--attributes=attr1,attr2]Example
pnpm forgewp make:block TestimonialCard --attributes=quote,author,ratingThis writes editable React source at src/blocks/TestimonialCard.tsx, with string attributes, editor controls, and starter visitor markup. It does not generate PHP at scaffold time. Export compiles that source into WordPress block metadata, PHP rendering, and shared editor assets. Attribute names must be unique JavaScript property identifiers, such as title or cta_label; change field types and controls in the generated source when needed.
Run pnpm forgewp make:block --help for options and the authoring-path guide. Help works outside a theme without creating files or asking for a name.
forgewp make:page <Name>
Scaffolds a custom WordPress Page Template in src/app/pages/<Name>.tsx.
pnpm forgewp make:page ContactUsThis creates the React page component with an exported pageConfig, registers the route in src/app/routes.tsx, and enables WordPress template selection in wp-admin.
forgewp make:section <Name>
Scaffolds a reusable editable layout section that can be rendered inside a page or registered as a standalone Gutenberg block.
pnpm forgewp make:section HeroSection --page=front-page --blockforgewp make:shell <Name>
Scaffolds a multi-column parent container block supporting child blocks via Gutenberg <InnerBlocks />.
pnpm forgewp make:shell SplitFeatureShell --children=feature-item --layout=2-colforgewp make:island <Name>
Scaffolds an isolated client hydration component inside src/components/islands/<Name>.tsx.
pnpm forgewp make:island LiveSearchModalforgewp make:editable <Name>
Scaffolds a colocated client-editable schema inside cms/editables/<slug>.ts with typed field definitions.
pnpm forgewp make:editable AboutPage --fields=hero_title:text,hero_body:richText,team_photo:imageforgewp make:form <Name>
Scaffolds a native WordPress form schema in cms/forms/<name>.ts and a companion React form component in src/components/forms/<Name>Form.tsx.
pnpm forgewp make:form Newsletter --fields=email:email,consent:checkboxforgewp make:post-type <slug>
Registers a custom post type in wp.config.ts and seeds initial mock items in cms/mock-data.ts.
pnpm forgewp make:post-type property --customFields=price,location,bedroomsforgewp make:loop <Name>
Generates a responsive card grid component wrapped in <WpQueryLoop> for a specific post type.
pnpm forgewp make:loop PropertyGrid --postType=propertyforgewp make:sandbox <type>
Seeds an offline mock database schema for specialized workflows.
pnpm forgewp make:sandbox ecommerce
pnpm forgewp make:sandbox auth4. Route & Data Synchronization
forgewp sync:routes
Scans your navigation menu definitions in cms/menus.ts and automatically scaffolds missing page templates in src/app/pages/ and route declarations in src/app/routes.tsx.
pnpm forgewp sync:routesforgewp sync:hooks
Synchronizes isomorphic WordPress data hook types and definitions across multi-theme monorepositories.
pnpm forgewp sync:hooksforgewp seed
Preview mock-data seeding before changing configuration:
pnpm forgewp seed mock-data --dry-run
pnpm forgewp seed:mock-data --dry-run --jsonThis loads wp.config.ts and the mock fixtures, then reports each post type's fixture count, enabled strategy, and normalized seed records, including slugs, serialized content, custom fields, and featured-image references. It uses the same record normalization as the PHP generator. Disabled or omitted post types have no seed records. When seeding is not configured, the preview leaves it disabled.
--json emits the report as JSON for tools (configuration warnings can still appear on stderr). The report includes developmentOnly and sideloadImages. It does not change files, export PHP, contact WordPress, download images, or inspect the database's seed markers or WP_DEBUG value. Actual activation behavior depends on those site conditions. Preview currently supports mock data only; product preview is outside this workflow.
Inspects local mock data and can add an initial seed configuration to wp.config.ts when no seed: block exists. It does not directly connect to MySQL or deploy a theme. Review the configuration and export/install the theme to generate and run WordPress-side seed routines.
pnpm forgewp seed
pnpm forgewp seed:products
pnpm forgewp seed:mock-dataTo seed an installed theme using its generated routines, run the corresponding command on the WordPress host, where WP-CLI is installed:
wp forgewp seed-mock-data
wp forgewp seed-productsThese WP-CLI commands are registered only when their seeders are generated; the product seeder also depends on the WooCommerce integration. Normal guards still apply. Adding --force bypasses the development guard and seed/hash checks and can overwrite content. Review Database Seeding Strategies before using these on an existing site.
5. Internationalization Commands
forgewp i18n:extract
Scans all JSX components and templates for useWpI18n() calls, extracting all translation keys into cms/translations.ts in a sorted, non-destructive format.
pnpm forgewp i18n:extractforgewp i18n:translate
Translates missing language keys across your target locales using the machine translation provider configured in wp.config.ts (deepl, google, libretranslate, or local).
pnpm forgewp i18n:translateTranslations are written back to the CMS translation catalog. The command selects empty values for translation and skips populated entries. Setting i18n.cache additionally enables a persistent response cache for successful translations. Cached matches fill blank catalog entries before requesting a provider. Remote requests may have their own costs and rate limits.
Summary of All Commands
Command Category Description exportBuild Compiles project into an installable WordPress theme ZIP. analyzeBuild Inspects bundle sizes and selective hydration islands. doctorDiagnostics Runs system health checks across config and environment. repairMaintenance Auto-heals missing or corrupted internal framework files. cleanMaintenance Deletes build caches ( .forgewp/, dist/, .vite/).freshMaintenance Resets project workspace to factory defaults. addScaffolding Copies pre-built UI components from component registry. make:blockScaffolding Generates a custom Gutenberg block component. make:pageScaffolding Generates a custom WordPress Page Template. make:sectionScaffolding Generates a shared layout section. make:shellScaffolding Generates a container block with <InnerBlocks />.make:islandScaffolding Generates an interactive hydration island component. make:editableScaffolding Generates a colocated editable schema in cms/editables/.make:formScaffolding Generates a native form contract and React component. make:post-typeScaffolding Registers a custom post type and seeds mock data. make:loopScaffolding Generates a <WpQueryLoop> card feed component.make:sandboxScaffolding Seeds mock database schemas for ecommerce or auth. sync:routesSync Scaffolds pages matching navigation menu items. sync:hooksSync Propagates data hook definitions across workspaces. seedSync Synchronizes mock items into local WordPress database. i18n:extractLocalization Scans components and extracts translatable strings. i18n:translateLocalization Translates missing keys via configured translation engine. |
|---|
Next Steps
Now that you have reviewed the forgewp CLI reference, proceed to the create-forgewp Scaffolder Reference to explore interactive project creation, non-interactive automation flags, and CI/CD project initialization.
Additional flags and automation details
There are 25 canonical command keys in the current CLI dispatcher, including seed:products and seed:mock-data. Some share an implementation. Use pnpm forgewp --help for the command list; only commands that implement their own help parser should be called with subcommand --help.
Command Additional supported inputs add--name=Name, --style=shadcn or --style=forgewp, --overwrite. Prefer equals syntax for named inputs.make:block--name=Name; attributes support --attributes / --attrs forms.make:page, make:island--name=Name as an alternative to a positional name.make:editable--name=Name, --fields=name:type,...; fields also accept a separate value.make:form--name=Name, --fields=name:type,..., --mailTo=admin (or an address / option:key).make:section--name=Name, --page=front-page, --fields=title:text,description:richText, --block. Creates a shared section schema/component and optional block wrapper.make:shell--name, --children, --layout, --grid-class, --class, --template-lock, --category, --icon, --description, --yes. Use equals syntax for repeatable automation.make:loop--name=Name, --postType=portfolio or --post-type=portfolio.make:post-type--name=portfolio, --customFields=client_name or --custom-fields=client_name.sync:routes--force / --override permits overwriting generated page source.sync:hooks--dry-run / -n previews; --verbose / -v includes skipped projects.fresh--force, -f, or -y bypasses its destructive reset confirmation.seedPositional target: all, products / product, or mock-data / mock / posts. |
|---|
The dispatcher also recognizes convenience aliases such as make-block, make-section, section, shell, page, island, loop, post-type, editable, form, sandbox, sync-routes, sync-hooks, i18n-extract, i18n-translate, reset (fresh), and inspect (analyze). Prefer canonical colon-form commands in scripts and documentation.
seed:products and seed:mock-data dispatch to the same seeder script as seed; the dispatcher does not insert a positional target. For an explicit selection, use pnpm forgewp seed products or pnpm forgewp seed mock-data. This local command inspects CMS source and can add a missing seed block to wp.config.ts; export afterward to regenerate the theme's PHP seeders. The separate wp forgewp seed-products / seed-mock-data commands run inside WordPress when registered.
Command effects matter in automation: add --overwrite, route sync with force, sync:hooks, repair, and fresh can write or replace source. Review the affected paths and keep a commit or backup before running them. clean also removes packaged exports inside .forgewp/, so keep release artifacts elsewhere.
make:mail
pnpm forgewp make:mail contact-receiptCreates cms/mail/contact-receipt.json with plain-text subject and body defaults. Run it from the theme root containing wp.config.ts. Existing files are preserved. Reference the name using a native form's notificationTemplate or confirmation.template; per-form text overrides the source defaults, and saved WordPress admin edits take priority. The Native Forms guide includes a complete configuration example.