The PatternFly CLI is a command-line tool for scaffolding projects, performing code modifications, and running project-related tasks. It streamlines everyday development work and PatternFly upgrades, making it convenient and easy to work straight from the terminal. You can run it in the terminal on its own, or use it from an AI-enabled editor (such as Cursor) so coding agents can rely on the same predictable commands for scaffolding, updates, and git workflows. The published package is @patternfly/patternfly-cli on npm.
The npm package installs two equivalent entry points: patternfly-cli and the shorter alias pfcli. The examples below use patternfly-cli, but you can substitute pfcli in your own usage if you prefer.
What does the PatternFly CLI help with?
- Project scaffolding: Quickly set up new PatternFly based projects for development and prototyping via predefined templates.
- Code modifications: Automate repetitive code changes to help accelerate PatternFly version upgrades.
- Task execution: Run project-related tasks such as committing and pushing changes, pulling updates, and deploying your app to GitHub Pages.
How do I set up PatternFly CLI?
Prerequisites
There are a few key prerequisites to meet before using PatternFly CLI. For macOS, WSL, and Linux, we recommend using install script to address the following prerequisites (you might still need administrator access for system packages). For a Windows-based system, you will need to install the following items manually:
- Node.js (Versions 20–24) and npm
- Corepack, which is included with Node.js. After installing npm, enable via
corepack enable - GitHub CLI
Installation
Install script (macOS and Linux)
You can pipe the repository install script into bash. This installs Node.js with nvm when node is not available, enables Corepack, installs GitHub CLI when it is missing, and installs the CLI globally from npm:
curl -fsSL https://raw.githubusercontent.com/patternfly/patternfly-cli/main/scripts/install.sh | bashThe script might prompt you to include sudo when your system package manager installs GitHub CLI.
Windows
After installing the prerequisites on your machine, install the published package globally:
npm install -g @patternfly/patternfly-cliHow do I use PatternFly CLI?
After installation, you can verify the latest version of the CLI has been installed by running the following terminal command:
patternfly-cli --versionTypical workflow
If you're starting a new project and publishing it, this is the usual sequence:
patternfly-cli create my-app # create a new project from a template
cd my-app
patternfly-cli init # set up Git and connect to GitHub
patternfly-cli save # commit and push your changes
patternfly-cli deploy # publish to GitHub PagesFor an existing project, use patternfly-cli update to migrate to a newer PatternFly version.
Available CLI commands
Once the PatternFly CLI is installed, you can run the following commands via patternfly-cli [command]:
Command | Usage |
|---|---|
create | Create a new project from the available templates. |
list | List all available templates (built-in and optional custom). |
update | Migrate your project to a newer PatternFly version using codemods, which handle import changes, component renames, and other breaking changes automatically. |
cli-upgrade | Upgrade the globally installed CLI to the latest npm release. It runs npm install -g @patternfly/patternfly-cli@latest—use your package manager’s equivalent if you did not install with npm. |
init | Initialize a git repository and optionally create a GitHub repository. |
save | Commit and push changes to the current branch. |
load | Pull the latest updates from GitHub. |
deploy | Build and deploy your app to GitHub Pages. |
For the most up-to-date flags and behavior guidance, refer to PatternFly CLI README on GitHub.
Predefined templates
The following predefined templates ship with PatternFly CLI:
Template name | Description |
|---|---|
starter | Starter template for a PatternFly React TypeScript project |
compass-starter | Starter template for a PatternFly Compass theme TypeScript project |
nextjs-starter | Starter template for a PatternFly Next.js project |
To use a template, pass the template name to patternfly-cli create [template name] or choose the template from the interactive prompt triggered by the generic patternfly-cli create comman. To print a list of all templates from your installed version, run patternfly-cli list.
Template definitions can be found in the patternfly-cli repo.
Custom templates
In addition to the predefined templates, you can add your own templates by passing a JSON file with --template-file (or -t). Custom templates are merged with the predefined list—if a custom template has the same name as a predefined template, the custom definition is used.
Create a project based on custom templates:
patternfly-cli create my-app --template-file ./my-templates.jsonList templates included in custom file:
patternfly-cli list --template-file ./my-templates.jsonJSON format (Array of template objects, shown in the same shape as the built-in templates):
[
{
"name": "my-template",
"description": "My custom project template",
"repo": "https://github.com/org/repo.git",
"options": ["--single-branch", "--branch", "main"],
"packageManager": "npm"
}
]name(required): Template identifierdescription(required): Short description shown in prompts andlistrepo(required): Git clone URLoptions(optional): Array of extra arguments forgit clone(such as["--single-branch", "--branch", "main"])packageManager(optional):npm,yarn, orpnpm; defaults tonpmif omitted
Uninstalling PatternFly CLI
Uninstall script (macOS and Linux)
You can pipe the repository uninstall script into bash. It removes the globally installed @patternfly/patternfly-cli package with npm. It does not remove Node.js, nvm, Corepack, or GitHub CLI:
curl -fsSL https://raw.githubusercontent.com/patternfly/patternfly-cli/main/scripts/uninstall.sh | bashWindows
If you installed the published package globally with npm, remove it with:
npm uninstall -g @patternfly/patternfly-cli