Introducing a new way to review your PRs.

Read the announcement

chakra-ui / panda

🐼 Universal, Type-Safe, CSS-in-JS Framework for Design Systems ⚡️

View on GitHub

19 documents · Updated Sep 23, 2026

docs / cli-workflows

CLI workflows

Panda’s CLI gives a project one user-facing path for creating its setup, turning source styles into generated artifacts, keeping those artifacts current, and inspecting the result. The panda and pandacss commands use the project configuration and send work to Panda’s shared build services.

See also Developer tooling and Node and PostCSS integration.

Command model

The CLI is the project operator’s entry point to Panda. A command selects one build or inspection goal, loads the project context, and either writes an artifact or keeps the process open for changes.

The main command groups are:

GoalCommandsResult
Create project setuppanda initPanda configuration and optional PostCSS setup
Build the style systempanda, panda codegenGenerated style helpers and types
Build CSSpanda cssgenCSS from project sources or one CSS artifact
Keep output current--watch on generation commandsRebuilds after source or configuration changes
Inspect or publish build dataanalyze, debug, ship, spec, emit-pkgReports, debug output, build information, specifications, or package exports
Run token documentationstudioA live, built, or previewed token documentation site

--cwd changes the project used by a command. --config selects a configuration file when the project has more than one possible config path. Most build commands also support quiet output, a log file, and polling for file watching.

Command entry point

The published package packages/…/package.json exposes both panda and pandacss binaries. The binary starts the command dispatcher in packages/…/cli-main.ts, while packages/…/cli-default.ts reports errors in a user-readable form and checks for package updates.

References: packages/…/package.json• L1-12 packages/…/bin.js• L1-3 packages/…/cli-default.ts• L1-9 packages/…/cli-main.ts• L40-44

Project setup workflow

panda init turns a project with no Panda setup into a project that can load a Panda config and generate its style system. It can also create the PostCSS connection and update the project’s ignore rules.

The workflow is:

  1. Choose flags directly or use --interactive to answer setup questions.
  2. Create or update the Panda config, unless an existing config blocks the operation without --force.
  3. Optionally create a PostCSS config.
  4. Load the new project context.
  5. Update ignore rules and run code generation unless --no-codegen is set.

Interactive setup covers the CSS syntax, JSX framework, generated file extension, strict token typing, PostCSS use, and ignore-file updates. This lets a new project choose its integration before its first build.

Initialization outputs

Initialization prepares the inputs that later commands need. The generated system normally lives in the configured output directory, and panda init can leave that directory ready for immediate use by running code generation.

Input choiceEffect on the project
--postcssAdds the PostCSS config needed for PostCSS-driven CSS generation
--outdirSelects where generated project artifacts are written
--jsx-frameworkSelects the framework shape for generated JSX helpers
--syntaxSelects the style authoring syntax used by generated helpers
--strict-tokensRequests stricter token checks in the generated system
--no-gitignoreLeaves the project ignore file unchanged
--no-codegenCreates setup without producing the generated system

References: packages/…/cli-main.ts• L45-119 packages/…/interactive.ts• L4-97 packages/…/types.ts• L3-12 packages/…/cli.test.ts• L66-100

Generation workflow

Generation reads the Panda configuration and project source files, extracts style use, and writes the generated system that application code consumes. The default panda command combines source generation with CSS generation, while panda codegen focuses on the generated system and panda cssgen focuses on CSS.

The shared workflow is:

flowchart LR
    A[Project config and source files] --> B[Load Panda project context]
    B --> C[Extract style use]
    C --> D[Generate helpers and types]
    C --> E[Generate CSS]
    D --> F[Application imports generated system]
    E --> G[Application loads styles]

Default generation

Running panda is the normal project build path. It accepts source globs and build choices such as the output directory, preflight reset, excluded files, class-name hashing, minification, CSS optimization, and token-only output.

The command ends after one build unless --watch is set. With watching enabled, the process stays active so source and configuration changes can update the generated output during development.

References: packages/…/cli-main.ts• L269-310 packages/…/types.ts• L78-92 packages/…/cli.test.ts• L150-164

Code generation

panda codegen generates the project’s style system without making CSS the primary output. Use it when the project needs updated helpers, types, or related generated modules after a configuration change.

--clean removes old generated output before the new result is written. --watch keeps the generated system aligned with configuration changes, and --cpu-prof can record a profile for a long-running generation process.

References: packages/…/cli-main.ts• L121-174 packages/…/types.ts• L70-76 packages/…/cli.test.ts• L102-121

CSS generation

panda cssgen extracts style use and writes the project CSS. It can produce the full stylesheet, a selected CSS artifact such as tokens or preflight, or separate files by CSS layer and recipe.

The command can replace the project’s default source include with one glob. It can also choose an output file, use a CSS optimizer, produce a smaller output, or keep the design-system CSS out of the result with --minimal.

References: packages/…/cli-main.ts• L176-267 packages/…/types.ts• L14-29 packages/…/cli.test.ts• L124-148

Watch workflow

Watch mode turns a one-time build into a development loop. The CLI first creates a complete result, then observes both project source files and configuration files so later changes can refresh only the active output path.

This diagram shows the relationship between an edit and a refreshed artifact.

sequenceDiagram
    participant Dev as Developer
    participant CLI as Panda CLI
    participant Files as Config or source files
    participant Output as Generated output

    Dev->>Files: Edit file
    Files-->>CLI: Change event
    CLI->>CLI: Refresh project context
    CLI->>Output: Regenerate active artifact
    Output-->>Dev: Updated helpers or CSS

--poll uses polling instead of file-system events. This is useful in environments where normal file events do not cross a container, virtual machine, or mounted volume reliably. Watch processes do not close their log stream after the first build because they remain active.

Watched change types

The CLI treats source removal, source edits, source creation, and configuration changes as separate events. A removed file leaves the project input set. An added or changed file becomes part of the next extraction, while a config change rebuilds the project context before generation continues.

References: packages/…/cli-main.ts• L156-173 packages/…/cli-main.ts• L237-266 packages/…/cli-main.ts• L514-538

Operating workflows

After setup and generation, the CLI provides commands for checking usage, explaining output, producing build metadata, and exposing generated files as a package. These commands use the same project context as the build commands, so they describe or package the project that its config and source globs define.

Inspection commands

panda analyze reports how tokens and configured recipes are used in selected source files. It prints the report or saves it as JSON, and its scope can be limited to tokens or recipes.

panda debug writes diagnostic files that show what Panda extracted and generated. It can write to a selected directory, print results without writing them with --dry, or limit the output to configuration data.

References: packages/…/cli-main.ts• L388-438 packages/…/cli-main.ts• L440-477 packages/…/types.ts• L41-58 packages/…/cli.test.ts• L178-192

Build information workflow

panda ship writes a build information file for the extracted project result. The file gives downstream tooling a stable record of the build and can be regenerated in watch mode when source or configuration changes.

The output path defaults to the generated system area. --outfile selects another path, and --minify reduces the size of the JSON result.

References: packages/…/cli-main.ts• L479-540 packages/…/types.ts• L60-68 packages/…/cli.test.ts• L194-204

Package export workflow

panda emit-pkg creates or updates a package.json for generated Panda output. Its exports make generated CSS, tokens, types, and available framework or design-system entry points consumable as package imports.

This workflow is useful when a project publishes its generated system or shares it across packages. It preserves existing package fields when the package file already exists and adds the generated entry points to its exports.

References: packages/…/cli-main.ts• L542-634 packages/…/types.ts• L94-99 packages/…/cli.test.ts• L206-219

Documentation workflow

panda spec creates machine-readable theme specifications for documentation and related tools. panda studio serves, builds, or previews a token documentation site when the optional Studio package is installed.

Studio uses the project config and can change its output directory, base path, host, or port. The command reports a clear install error when the optional package is not available.

References: packages/…/cli-main.ts• L312-386 packages/…/types.ts• L31-39 packages/…/types.ts• L101-106 packages/…/CHANGELOG.md• L308-345

Error and log workflow

CLI failures are reported as command-line errors rather than raw process traces. Panda errors include their code and hint when available, and source-location errors include the file position and source frame.

Commands can suppress normal messages with --silent or write logs to a file with --logfile. A failed command sets a non-zero process status, which lets package scripts and continuous integration detect the failure.

Migration commands

The mcp and init-mcp command names remain as migration notices. They no longer start or configure the MCP service in this package; users must use @pandacss/mcp instead.

References: packages/…/errors.ts• L5-30 packages/…/cli-main.ts• L636-642 packages/…/CHANGELOG.md• L18-24

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the panda and pandacss binary names aligned with the published package entry points.
  • Keep command flags aligned with the corresponding flag types and the config fields passed into the shared build services.
  • When changing watch behavior, check source events, config reloads, log-stream lifetime, and polling behavior together.
  • When changing generated output paths, check init, the default command, codegen, cssgen, ship, and emit-pkg because they share the project output contract.
  • When changing optional Studio or moved MCP behavior, keep the user-facing install or migration message aligned with the package that now owns the feature.

Important failure modes

TriggerConsequenceGuard
panda init runs against an existing config without --forceThe project is not overwritten and the user must decide whether to keep or replace the setupUse the existing-config result before starting a fresh setup
A command uses the wrong --cwd or --configPanda reads a different project or cannot find the intended configurationPass the project root and config path together when the current directory is not the project root
A watched file is mounted without reliable file eventsSource edits do not trigger a rebuildUse --poll in the affected environment
studio runs without @pandacss/studio installedThe command cannot serve, build, or preview the token siteInstall the optional package before using Studio
A project still calls panda mcp or panda init-mcpThe command stops with a migration error instead of starting MCPUse @pandacss/mcp directly
A command fails while a package script expects successThe process exits with a failure status and the downstream task stopsRead the formatted error and its hint or source location before retrying

Key files

FileWhy to read it
packages/…/cli-main.tsDefines the user-facing commands and connects each workflow to Panda’s build services
packages/…/interactive.tsShows the setup choices exposed by interactive initialization
packages/…/types.tsDefines the flag contracts for each command family
packages/…/cli-default.tsShows the executable startup path and top-level error handling
packages/…/errors.tsExplains how command failures become terminal output and process status
packages/…/package.jsonDefines the published command names, supported Node version, and package boundary
packages/…/cli.test.tsDemonstrates the expected end-to-end results for setup, generation, inspection, shipping, and package export workflows