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

textpratique with no valid subcommand prints this
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, pratique runs the server, the same as pratique serve.
  • --config FILE must be the first two arguments, as in pratique --config pratique.yaml gc. The --config=FILE form is not read. Instead of the flag, you can set PRATIQUE_CONFIG.
  • Flags go before paths. Flag parsing stops at the first argument that is not a flag. A flag can start with - or --.
  • pratique help prints the usage and exits with code 0. pratique version prints the version, such as pratique 1.4.0; a build without a version prints dev.
  • An unknown subcommand prints the usage and exits with code 2. A command that fails logs pratique COMMAND failed with the error and exits with code 1.
CommandRuns onReads the config file
serveThe serverYes
config checkAnywhere, such as CIThe file it is given
config exportThe server, or a host that reaches its databaseYes
lockcheckCINo
inventoryCINo
build recordCINo
reportThe serverYes
backupThe serverNo, environment only
restoreThe server, while Pratique is stoppedNo, environment only
tokenThe server, or a host that reaches its databaseYes
gcThe serverYes
healthcheckThe server or its containerYes
audit-keygenAnywhereNo
verify-logA host that can read the databaseYes
versionAnywhereNo

serve

bashstart the server
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:

textstandard 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

bashvalidate a config file, for example in CI
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

bashturn the settings made in the UI into a file
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

bashfail CI when a lockfile bypasses Pratique
pratique lockcheck --registry https://pratique.example.com
pratique lockcheck --registry https://pratique.example.com services/api services/web
ArgumentDefaultMeaning
--registry URL$PRATIQUE_PUBLIC_URLPratique'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

bashreport a project's lockfiles
export PRATIQUE_TOKEN=...
pratique inventory --registry https://pratique.example.com --project acme/api .
# acme/api: reported 412 packages from 2 lockfiles.
ArgumentDefaultMeaning
--registry URL$PRATIQUE_PUBLIC_URLPratique's public URL.
--project NAMENone, requiredThe project's name, such as acme/api.
--token TOKEN$PRATIQUE_TOKENAn 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

bashrecord a CI build, after publishing
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.
ArgumentDefaultMeaning
--registry URL$PRATIQUE_PUBLIC_URLPratique's public URL.
--token TOKEN$PRATIQUE_TOKENAn access token.
--produces SPECNoneWhat 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 NAMEFrom CIThe build's name, such as acme/api.
--number NFrom CIThis run's number.
--commit SHAFrom CIThe commit built.
--repo URLFrom CIThe repository's address.
--branch NAMEFrom CIThe branch built.
--url URLFrom CIA link to this run.
--status STATUSNonesuccess, failure or cancelled.
path...NoneDirectories 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

bashprint a compliance report as JSON
pratique --config pratique.yaml report --days 90 > compliance-$(date +%F).json
FlagDefaultMeaning
--days N30The 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

bashback up SQLite and local files
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

bashrestore a backup, with the server stopped
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 as pratique.db.before-restore- and the time, not deleted.
  • on Postgres. Use pg_restore there.

token

bashmanage tokens from the server's shell
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 createMeaning
--name NAMERequired. Up to 60 characters, shown in the audit log.
--botA token for a CI system or service. Records name it, as bot:NAME.
--owner EMAILA personal token for this person. Give either --bot or --owner.
--publishAllows publishing private packages. A personal token with it must expire within 90 days.
--team NAMEThe team whose policy applies.
--days NDays 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

bashremove unreferenced files now
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

bashcheck that the local server is ready
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

bashcreate an audit log signing key
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

bashverify the audit log
pratique verify-log --public-key PUBLIC_KEY --anchor HEAD
FlagMeaning
--public-key KEYThe public key from audit-keygen. Requires a valid signature on every chained event.
--anchor HEADA head published earlier. Detects removal of the newest events.
--allow-legacyAccepts 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

bashprint the 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.

CommandWhat 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-stdinUses a token from standard input instead of the browser.
pratique-connect doctorChecks each installed tool and the token. Exits with code 1 when something needs fixing.
pratique-connect logoutRevokes the token and restores the earlier settings.
pratique-connect statusShows 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 versionPrints the tool's version.
pratique-connect helpPrints the commands.