CLI reference
The pratique binary runs the server and a set of subcommands for CI, operations and audits. This page lists each one, with its flags and defaults.
Usage
usage: pratique [--config FILE] [serve | config check FILE | config export | lockcheck --registry URL [path...] | inventory --registry URL --project NAME [path...] | report [--days N] | build record --registry URL [path...] | backup DIR | restore [--force] DIR | token create|list|revoke | gc | audit-keygen | verify-log | healthcheck | version]
- With no subcommand,
pratiqueruns the server, the same aspratique serve. --config FILEmust be the first two arguments, as inpratique --config pratique.yaml gc. The--config=FILEform is not read. Instead of the flag, you can setPRATIQUE_CONFIG.- Flags go before paths. Flag parsing stops at the first argument that is not a flag. A flag can start with
-or--. pratique helpprints the usage and exits with code 0.pratique versionprints the version, such aspratique 1.4.0; a build without a version printsdev.- An unknown subcommand prints the usage and exits with code 2. A command that fails logs
pratique COMMAND failedwith the error and exits with code 1.
| Command | Runs on | Reads the config file |
|---|---|---|
serve | The server | Yes |
config check | Anywhere, such as CI | The file it is given |
config export | The server, or a host that reaches its database | Yes |
lockcheck | CI | No |
inventory | CI | No |
build record | CI | No |
report | The server | Yes |
backup | The server | No, environment only |
restore | The server, while Pratique is stopped | No, environment only |
token | The server, or a host that reaches its database | Yes |
gc | The server | Yes |
healthcheck | The server or its container | Yes |
audit-keygen | Anywhere | No |
verify-log | A host that can read the database | Yes |
version | Anywhere | No |
serve
pratique --config pratique.yaml
pratique serve
Starts the web UI, the package routes and the background jobs. Settings come from environment variables and the config file. See settings reference.
When PRATIQUE_ADMIN_TOKEN is not set and no OIDC, SAML or LDAP sign-in is configured, the server
generates an admin token for this run and prints it to standard error:
Generated admin token for this run (set PRATIQUE_ADMIN_TOKEN to keep one):
9f2c...
On SIGINT or SIGTERM, the server stops taking new requests and waits up to 30 seconds for
requests in progress.
config check
pratique config check pratique.yaml
# pratique.yaml is valid: 6 quarantine settings, 16 rules, 3 exceptions, 2 custom feeds
Reads the file, checks every key and value, and then checks the server settings the same way the server does at startup. An unknown key, an unknown rule or a bad value is an error.
Each ${VAR} in the file must be set in the environment, or the check fails. In CI, set those variables
to placeholder values. The check also applies the server rules, such as "PRATIQUE_PUBLIC_URL is required
on a non-loopback address".
config export
pratique config export > pratique.yaml
Reads the database and prints YAML for what has been set: the default quarantine and the quarantine for each registry and package, reserved names, the metadata cache, the storage cleanup policy, teams and their rules, rules, and exceptions that have not ended, with their expiry.
Secrets are not included. Team tokens, server settings, sign-in settings and custom threat feeds are not included
either. Add them yourself, with ${VAR} for secrets.
lockcheck
pratique lockcheck --registry https://pratique.example.com
pratique lockcheck --registry https://pratique.example.com services/api services/web
| Argument | Default | Meaning |
|---|---|---|
--registry URL | $PRATIQUE_PUBLIC_URL | Pratique's public URL. Sources must use this host. |
path... | . | Directories or files to search. |
Reads package-lock.json, npm-shrinkwrap.json, yarn.lock,
pnpm-lock.yaml, uv.lock, poetry.lock, composer.lock and
requirements*.txt. It skips node_modules, .git, .venv,
venv, vendor, __pycache__, .tox, dist and
build.
It fails when a lockfile would fetch from anywhere other than Pratique, including Git dependencies and direct URLs.
Each finding prints as file:line: source, with credentials removed from URLs. Local paths are allowed. It
also fails when it finds no lockfiles, with "no lockfiles found, so nothing was checked". It does not contact the
server and needs no token. It does not read go.sum.
inventory
export PRATIQUE_TOKEN=...
pratique inventory --registry https://pratique.example.com --project acme/api .
# acme/api: reported 412 packages from 2 lockfiles.
| Argument | Default | Meaning |
|---|---|---|
--registry URL | $PRATIQUE_PUBLIC_URL | Pratique's public URL. |
--project NAME | None, required | The project's name, such as acme/api. |
--token TOKEN | $PRATIQUE_TOKEN | An access token. |
path... | . | Directories or files to search. |
Sends the names and versions in the project's lockfiles to /api/inventory, not code. It reads the same
files as lockcheck, and go.sum. Each report replaces the project's last one, and the versions
it lists are never removed by storage cleanup.
It fails with "no lockfile found, so nothing was reported" when there is nothing to send, and when the project uses a version already reported as malware. Each such version prints with its report ID.
build record
pratique build record --registry https://pratique.example.com \
--produces npm:acme-api@1.2.3=dist/acme-api-1.2.3.tgz .
# acme/api #57: recorded 1 artifact made and 412 packages used.
| Argument | Default | Meaning |
|---|---|---|
--registry URL | $PRATIQUE_PUBLIC_URL | Pratique's public URL. |
--token TOKEN | $PRATIQUE_TOKEN | An access token. |
--produces SPEC | None | What the build made, as npm:name@1.2.3, or npm:name@1.2.3=path/to/file to record the file's SHA-256. Repeat it for each artifact. |
--name NAME | From CI | The build's name, such as acme/api. |
--number N | From CI | This run's number. |
--commit SHA | From CI | The commit built. |
--repo URL | From CI | The repository's address. |
--branch NAME | From CI | The branch built. |
--url URL | From CI | A link to this run. |
--status STATUS | None | success, failure or cancelled. |
path... | None | Directories or files to search for lockfiles. With no path, no lockfiles are read. |
On GitHub Actions and GitLab CI, the command reads the name, number, commit, repository, branch and link from the
CI environment. Elsewhere, --name and --number are required. Reporting the same name and
number again replaces the record.
It fails when the build used a version reported as malware, or when a file stored under an artifact's version is not the one this build made. The second case also opens an incident. It compares with what is stored, so run it after you publish.
report
pratique --config pratique.yaml report --days 90 > compliance-$(date +%F).json
| Flag | Default | Meaning |
|---|---|---|
--days N | 30 | The period to cover: 30, 90 or 365. |
Prints the same report as the Reports page. It opens the server's database, so run it with the server's settings. See compliance reports.
backup
PRATIQUE_DATA=/data pratique backup /backups/pratique
# Backed up the database and 214 new files to /backups/pratique
Takes exactly one argument, the destination directory. It writes DIR/pratique.db, a consistent copy
made while the server runs, and copies package files that are not in DIR/blobs/ yet.
It reads PRATIQUE_DATA (default ./data) and PRATIQUE_DATABASE_URL from the
environment only, not from the config file. When PRATIQUE_DATABASE_URL is set, it refuses to run:
back up Postgres with pg_dump. See back up and restore.
restore
PRATIQUE_DATA=/data pratique restore /backups/pratique
PRATIQUE_DATA=/data pratique restore --force /backups/pratique
Puts a backup made by backup into PRATIQUE_DATA. It checks the backup's database with
SQLite's integrity check, then copies the database and any package files that are missing. It refuses to run:
- while something answers on
PRATIQUE_LISTEN, because the running server keeps the database open - over an existing database without
--force. With--force, the current database is kept aspratique.db.before-restore-and the time, not deleted. - on Postgres. Use
pg_restorethere.
token
pratique token create --name ci --bot --days 365 > ci-token
pratique token create --name laptop --owner alice@example.com --days 90
pratique token list
pratique token revoke 12
For setup scripts and automation. The rules are the same as on the Access tokens page, and
each change is in the audit log with the actor cli. create prints only the token, so a
script can capture it; it is shown once.
| Flag of create | Meaning |
|---|---|
--name NAME | Required. Up to 60 characters, shown in the audit log. |
--bot | A token for a CI system or service. Records name it, as bot:NAME. |
--owner EMAIL | A personal token for this person. Give either --bot or --owner. |
--publish | Allows publishing private packages. A personal token with it must expire within 90 days. |
--team NAME | The team whose policy applies. |
--days N | Days until it expires, from 0 to 365. 0 never expires. The default is 90. |
list prints each token's ID, name, owner, kind, access, expiry and last use, never the token itself.
revoke ID deletes a token.
gc
pratique --config pratique.yaml gc
# Removed 12 unreferenced files
Deletes stored files that no record refers to and that are older than one hour (15 minutes in firewall mode), and old temporary files. The server does this every day. It does not apply the cleanup policy. See storage and backups.
healthcheck
pratique healthcheck && echo ready
Requests /readyz on the address in PRATIQUE_LISTEN, with a 5 second timeout, and exits
with 0 only for HTTP 200. A listener on 0.0.0.0 or :: is checked at
127.0.0.1. When PRATIQUE_TLS_CERT is set, it uses HTTPS without checking the certificate,
because it only asks the same machine. The Docker image uses this command as its health check.
audit-keygen
pratique audit-keygen
# PRATIQUE_AUDIT_KEY=...
# Public key, for verify-log: ...
Prints a new Ed25519 signing key as PRATIQUE_AUDIT_KEY, and its public key. Keep the two in different
places. See audit log.
verify-log
pratique verify-log --public-key PUBLIC_KEY --anchor HEAD
| Flag | Meaning |
|---|---|
--public-key KEY | The public key from audit-keygen. Requires a valid signature on every chained event. |
--anchor HEAD | A head published earlier. Detects removal of the newest events. |
--allow-legacy | Accepts events from before the chain existed, which cannot be checked. |
Reads the database at PRATIQUE_DATABASE_URL, or pratique.db in PRATIQUE_DATA,
and needs read access only. It prints the number of chained, signed and older events and the head, or fails at the
first problem it finds.
version
pratique version
docker run --rm ghcr.io/justpolidor/pratique:latest version
Include the version in bug reports, and check it after an upgrade. The Docker image sets it from the
VERSION build argument: docker build --build-arg VERSION=1.4.0 .
pratique-connect
A separate tool for developer machines, downloaded from your Pratique server. It signs in through the browser and sets up npm, pnpm, Yarn, Bun, pip, uv, Go and Composer. See one-command setup.
| Command | What it does |
|---|---|
pratique-connect login [server] | Signs in and sets up every installed tool. Without a server, renews the token for the server this machine uses. |
pratique-connect login server --token-stdin | Uses a token from standard input instead of the browser. |
pratique-connect doctor | Checks each installed tool and the token. Exits with code 1 when something needs fixing. |
pratique-connect logout | Revokes the token and restores the earlier settings. |
pratique-connect status | Shows the server, who is signed in, when the token expires, both versions and which tools were set up. |
pratique-connect update [server] | Replaces the tool with the server's current build. |
pratique-connect version | Prints the tool's version. |
pratique-connect help | Prints the commands. |