pre-cli
The pre command. A coding agent runs it to describe the user's database, train a PRE model, read its rules and
score cases.
It talks to the PRE API through packages/pre-api-client. It never imports PRE. Its sentences come from
packages/pre-words, so they match the report.
Install
pipx install stratyfy-cli # or: uv tool install stratyfy-cli
For development, run poetry install in this folder, then poetry run pre --help. pre --version prints the
version.
The wheel and the sdist bundle pre_api_client, pre_words and pre_report from packages/, so the install
needs nothing else from this repo. hatch_build.py copies them in at build time. The CLI uses hatchling to build,
because poetry-core cannot include files from outside this folder. Poetry still manages the development env.
Commands
Each command prints a short text result and a next step. Add --json to get one JSON object instead. On
failure the command exits with 1 and prints code, message and next_step.
| Command | What it does |
|---|---|
pre login [--no-wait] [--api-url <url>] |
Signs in as gh auth login does. It prints a link and a code. The user signs in with an email code and approves the device. Then it writes a new key for this machine to .pre/config.json. With --no-wait it prints the link and exits; the next pre login waits for that same sign-in. That way an agent can show the user the link first. The default API is https://api.stratyfy.ai/v1. |
pre logout |
Revokes the key on the API and removes it from .pre/config.json. If the API does not answer, it still removes the key and names its id for an admin to revoke. |
pre try [name] |
Lists the sample apps, or downloads one into ./<name>/: its SQLite database, a README, a copy of this folder's key, and a CLAUDE.md and the skill so Claude Code started there knows what to do. |
pre keys list |
Lists the workspace's live keys. The key in use here is marked. |
pre keys create <name> [--to-file <path>] |
Makes a key for a job or an app, not tied to this machine. It is shown once. Inside a coding agent it is written only to a file, never to the screen. |
pre keys revoke <id> |
Revokes one key. It stops working at once, everywhere. |
pre usage [--days 30] |
The workspace's use per day: rows scored and calls. |
pre delete-data [--yes] |
Deletes every dataset and model in the workspace, on the API. It asks first and refuses inside a coding agent. Keys, outcomes and local files stay. See the docs page "Your data". |
pre delete-account |
Prints the page that deletes the account and everything in it, after a code sent by email. No key needed. |
pre version |
Prints the version, as pre --version does. |
pre guide |
Prints the method a coding agent follows, from set-up to the report. It is the plugin's onboard skill, bundled in the CLI. |
pre init --api-key <key> [--api-url <url>] |
Writes a key you already have to .pre/config.json. The key can also come from PRE_API_KEY. |
PRE_API_KEY and PRE_API_URL win over .pre/config.json for every call, so a job on a server needs no config. pre logout still revokes only the folder's own key.
| pre connect <db> | Describes a SQLite or Postgres database: tables, row counts, columns, types, null share, sample values and foreign keys. It opens the database read-only. |
| pre setup claude [--yes] [--dry-run] [--local] | For Claude Code. Run it in your own terminal. It writes the PRE skill to .claude/skills/pre-onboard/, and adds the API host and a remote Postgres host to Claude Code's sandbox network allowlist. It shows the change and asks first. It refuses to write when an agent runs it. See Sandboxes. |
| pre status | Checks that the API answers and accepts the key, and names the workspace. Lists the datasets and models this folder made. |
| pre outcome define --name <slug> --sql <query> [--case account --cases accounts --event churn --event-past churned] | Runs the outcome query and stores it. The query returns one row per case: the case id, then a 0/1 label. It refuses no rows, a label that is not 0 or 1, a repeated case id and a label that is always the same. The words go into every sentence the CLI prints. It guesses each word you leave out from the column names and says so. |
| pre outcome show | Lists the stored outcomes and their queries. |
| pre extract --outcome <slug> --features <query> | Runs the features query (the case id, then the features), joins it to the label and writes .pre/data/<slug>.csv. Nothing is sent. |
| pre extract --outcome <slug> --upload [--refresh] | Sends the CSV the dry run wrote, unchanged. With --refresh, or with no CSV yet, it runs the queries again first. |
| pre train --outcome <slug> [--max-rules N] [--max-conditions N] [--no-wait] [--timeout S] | Trains on the outcome's uploaded dataset. Every column but id is an input. It waits until the model is ready or failed and prints progress to stderr. When ready, it says how well the model predicts on held-out cases: the AUC and how many times the average rate the top 10% hold. |
| pre rules --outcome <slug> or pre rules --model <id> | Prints the rules as sentences, strongest first, with points and direction. The baseline shows as the starting rate. --json gives the API's rules. |
| pre predict --outcome <slug> [--features <query>] | Scores cases with the outcome's model. The query returns the case id, then the model inputs as of today, for example for the accounts still active. Without --features it scores the training cases as of their snapshot date and says so. It writes .pre/data/<slug>.scores.csv: the case id, the score, the points and the rules that fired as sentences, highest score first. It also writes .pre/data/<slug>.scores.json for pre report: the same scores with the rule ids that fired. It refuses a query that lacks an input or repeats a case id. |
| pre report --outcome <slug> [--actions <file.json>] [--labels <file.json>] [--top N] | Writes .pre/reports/<slug>.html and .pre/reports/<slug>.csv from the scores pre predict saved. It sends nothing. The page says how well the model predicts, lists the top rules as sentences and the N cases most likely to have the outcome, with their reasons. The CSV holds the same cases. --actions maps a rule id to one suggested action. --labels maps an input column to a plain label. It refuses a rule id or a column the model lacks. When the scores came from the training cases, the page says so. |
<db> is a SQLite file path, sqlite:///path, or postgresql://user:password@host:5432/db. Use --schema for
a Postgres schema other than public.
A <query> is the SQL itself or a path that ends in .sql. It must be one SELECT or WITH statement. The CLI
opens SQLite with mode=ro and runs Postgres in a read-only transaction, so a query cannot change data. For
Postgres, a database user with read access only is safer still.
What leaves the machine
The CSV that pre extract --upload sends, and the rows that pre predict sends. Before it writes the CSV, pre extract:
- Drops a column when every word of its name is an identifier word and one of them is a core word. Core words
are
email,phone,mobile,ip,address,street,ssn,nameandusername. The other identifier words aremail,number,first,last,full,user,contact,homeandwork. Sowork_emailandfirst_namego, andplan_nameandaddress_verifiedstay. - Drops a column when a text value holds an email address or looks like a phone number.
- Replaces the case id with an HMAC of it in a column named
id. The key is in.pre/secret(mode 600)..pre/data/<slug>.ids.csvmaps each hash back to the case id. It stays on this machine.
The output names each dropped column and the reason.
pre predict sends each case as the same HMAC of its id and the model's inputs, in batches of 1,000. It sends no
other column. It maps the hashes back to the case ids in memory.
Sandboxes
pre setup writes the smallest change it can. It merges into the file, so a second run changes nothing.
It writes .claude/settings.local.json, key sandbox.network.allowedDomains. That is Claude Code's personal
settings file; the team's .claude/settings.json stays as it is. Do not commit it. For a Postgres on this machine, --local
also sets sandbox.network.allowLocalBinding, which opens every local port. It never sets allowAllUnixSockets.
Claude Code is the only agent at launch; others are on the roadmap. It also writes the onboard skill to
.claude/skills/pre-onboard/SKILL.md. It records the copy's SHA-256 in .pre/config.json, and later replaces only
that copy: a skill you edited stays as it is. Commit the skill to share it with the team. Its source is
tools/agent-plugin.
These key names come from secondary sources. They live in pre_cli/sandbox.py.
Local config
.pre/config.json holds the API URL, the key and its id, the database URL, the outcome queries and the dataset
and model ids that later commands create. While a pre login --no-wait waits, it also holds that sign-in. The API
can also list every dataset and model in the workspace. Each command that writes the config also writes
.pre/.gitignore, so git ignores the folder. Set PRE_DIR to use another folder.
Tests
scripts/check pre-cli runs ruff and pytest. The pre status tests start a Prism mock of
services/pre-api/openapi.yaml with npx. They skip when npx is missing.
tests/test_package.py builds the sdist, a wheel from that sdist and a wheel from this folder. It fails if one
holds a file outside pre_cli and the three bundled packages, a services, apps or ground_truth path, a
seed.py or check.py, or the name of the PRE library. PRE must never reach PyPI.
Release
The CLI is on PyPI as stratyfy-cli. The command it installs is pre. .github/workflows/release-cli.yml
publishes it with trusted publishing, so no PyPI token is stored.
- Set the new
versioninpyproject.toml. It is the only place that holds the version. - Merge that change to
master. CI runsscripts/check pre-cli, which builds the package and checks its files. - Tag the merge commit and push the tag:
git tag stratyfy-cli-v<version>, thengit push origin stratyfy-cli-v<version>. - The workflow checks that the tag matches the version, builds, installs the wheel and runs
pre --version. Then it publishes in the GitHub environmentpypi.
Users install it with Python 3.11 or later: pipx install stratyfy-cli.
Metadata
Release files for stratyfy-cli 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stratyfy_cli-0.3.0.tar.gz | 60.6 kB | With provenance | Details for stratyfy_cli-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stratyfy_cli-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for stratyfy_cli-0.3.0-py3-none-any.whl |
Total release size: 164.6 kB
Release files / stratyfy_cli-0.3.0.tar.gz
| Download URL | stratyfy_cli-0.3.0.tar.gz |
|---|---|
| Size | 60.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfca864009b829b7357a9f2f30c8c5664b11eebb087236367ea0a9c5f11336dc
|
|
BLAKE2b-256 checksum How to use checksums |
6d90bb005211fa33cc2e9094f7ec0c06c6e117c12fba2e7f2df1fd57e25247bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / stratyfy_cli-0.3.0-py3-none-any.whl
| Download URL | stratyfy_cli-0.3.0-py3-none-any.whl |
|---|---|
| Size | 104.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb83a5e091249262a7cd1a516a3bc45e03434128b19c7646b8f6d1827b9697e9
|
|
BLAKE2b-256 checksum How to use checksums |
f4d9305543f68e296f916a03d288b1630cd74aef24e9babfda28c648338fe647
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for stratyfy-cli 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for stratyfy_cli-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.