Install the CLI
The Groundrule CLI is the npm package @groundrule/cli. It installs one command, groundrule. You can run it with npx without installing anything, install it globally, or add it to a project as a devDependency with a pinned version. This page covers all three, plus the Node.js requirement, versions, and updates.
Requirements
Section titled “Requirements”| Requirement | Details |
|---|---|
| Node.js | Version 22 or later. The package declares "node": ">=22". |
| git | Needed to check only your changes, to find the repository name, and to fetch packs from GitHub. Without git, check audits every file. |
| Operating system | macOS, Linux, or Windows. |
| Network | Only for login, logout, whoami, propose, scan --upload, and for repositories connected to the platform. Offline repositories need no network after the package is installed. |
Check your Node.js version:
node --versionIf it prints v20.x or older, install a current release from nodejs.org or with your version manager (for example nvm install 22).
Option 1: run it with npx (recommended)
Section titled “Option 1: run it with npx (recommended)”npx downloads the package on first use, caches it, and runs it. Every page in these docs uses this form:
npx @groundrule/cli --versionYou should see the version number, such as 0.1.0.
Use this form for one-off commands, for trying Groundrule out, and in CI. In CI, add --yes so npx never stops to ask before downloading:
npx --yes @groundrule/cli checkOption 2: install it globally
Section titled “Option 2: install it globally”A global install puts groundrule on your PATH:
npm install --global @groundrule/cligroundrule --versionFrom then on, npx @groundrule/cli <command> and groundrule <command> do the same thing.
Option 3: add it to a project (pin a version)
Section titled “Option 3: add it to a project (pin a version)”Add the CLI as a devDependency when everyone on the team, and CI, should run the same version:
npm install --save-dev --save-exact @groundrule/cli@0.1.0With pnpm or Yarn:
pnpm add --save-dev --save-exact @groundrule/cli@0.1.0yarn add --dev --exact @groundrule/cli@0.1.0Then run it through your package manager, which finds the local copy:
npx groundrule checkYou can also add scripts to package.json:
{ "scripts": { "standards:sync": "groundrule sync", "standards:check": "groundrule check" }}The bundled packs (groundrule:packs/...) ship inside the CLI. Pinning the CLI version also pins the packs your offline repositories use.
Check the version
Section titled “Check the version”npx @groundrule/cli --versionnpx @groundrule/cli -vgroundrule doctor also prints your Node.js version and fails if it’s older than 22. See Inspect your rules.
Update
Section titled “Update”| How you run it | How to update |
|---|---|
npx @groundrule/cli |
npx reuses its cached copy. Ask for the newest one with npx @groundrule/cli@latest <command>. |
| Global install | npm install --global @groundrule/cli@latest |
| Project devDependency | Change the version in package.json (or run npm install --save-dev --save-exact @groundrule/cli@<version>) and commit the lockfile. |
When a repository is connected to the platform and the CLI is older than a rule it receives, the CLI skips that rule and warns: “Skipped <ID> from the platform: it doesn’t match this CLI’s spec (upgrade @groundrule/cli).” Update the CLI to get the rule back.
Notes by operating system
Section titled “Notes by operating system”macOS and Linux
- Sign-ins are saved in
~/.config/groundrule/credentials.json, or in$XDG_CONFIG_HOME/groundrule/whenXDG_CONFIG_HOMEis set. groundrule loginopens your browser withopen(macOS) orxdg-open(Linux). On a server without a browser, use--no-browserand open the printed link on any device. See Sign in from the CLI.
Windows
- Sign-ins are saved in
%APPDATA%\groundrule\credentials.json, unlessXDG_CONFIG_HOMEis set. groundrule loginopens your default browser.- Run the commands in PowerShell, Command Prompt, or Git Bash. Quote arguments with spaces in the way your shell expects, for example
npx @groundrule/cli propose "Never call Stripe directly".
Global options
Section titled “Global options”These work with every command:
| Option | What it does |
|---|---|
-C, --cwd <dir> |
Run as if the command started in <dir>. Useful in scripts and monorepos. |
-v, --version |
Print the version and exit. |
-h, --help |
Show help. groundrule <command> --help shows one command’s options. |
Colors turn off when the output isn’t a terminal, or when NO_COLOR is set.
If something goes wrong
Section titled “If something goes wrong”npxcan’t find the package, or you see a permissions error on a global install. Usenpxinstead of a global install, or fix npm’s global folder permissions as the npm documentation describes.- “Unsupported engine” or a syntax error on start. Your Node.js is older than 22. Upgrade it.
- The command prints
(run groundrule --help for usage). An option or argument was wrong. The command exits with code 2. Runnpx @groundrule/cli <command> --help.
- CLI quickstart: sign in, connect a repository, and run your first check.
- Use Groundrule without the platform: run everything offline, with no account.