Skip to main content

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 Removes the key from .pre/config.json. The key keeps working until an admin revokes it, so the output names its id.
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 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 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:

  1. 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, name and username. The other identifier words are mail, number, first, last, full, user, contact, home and work. So work_email and first_name go, and plan_name and address_verified stay.
  2. Drops a column when a text value holds an email address or looks like a phone number.
  3. 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.csv maps 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.json, key sandbox.network.allowedDomains. 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. The onboard skill comes with the plugin (tools/agent-plugin), not with pre setup.

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.

  1. Set the new version in pyproject.toml. It is the only place that holds the version.
  2. Merge that change to master. CI runs scripts/check pre-cli, which builds the package and checks its files.
  3. Tag the merge commit and push the tag: git tag stratyfy-cli-v<version>, then git push origin stratyfy-cli-v<version>.
  4. The workflow checks that the tag matches the version, builds, installs the wheel and runs pre --version. Then it publishes in the GitHub environment pypi.

Users install it with Python 3.11 or later: pipx install stratyfy-cli.

Metadata

Release files for stratyfy-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stratyfy-cli 0.1.0
File Size Uploaded Provenance Actions
stratyfy_cli-0.1.0.tar.gz 47.5 kB With provenance Details for stratyfy_cli-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stratyfy-cli 0.1.0
File Interpreter ABI Platform Actions
stratyfy_cli-0.1.0-py3-none-any.whl Python 3 none any Details for stratyfy_cli-0.1.0-py3-none-any.whl

Total release size: 125.2 kB

Release files / stratyfy_cli-0.1.0.tar.gz

Download URL stratyfy_cli-0.1.0.tar.gz
Size 47.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4235983b5ec0ebdc4aba9d8bbf6e68f02dcd80060cd7750e72612f03b2db5a8b
BLAKE2b-256 checksum
How to use checksums
0479ef014ee7ac0bbc39e25cb2cdd276db53fd4c14e13d24a4b6ebfd5316e810
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 10, 2026.

Transparency log

Release files / stratyfy_cli-0.1.0-py3-none-any.whl

Download URL stratyfy_cli-0.1.0-py3-none-any.whl
Size 77.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cbfaaf19728b47b3672ba9b7e44623f6c2edea20d50a441679db79325d03e66
BLAKE2b-256 checksum
How to use checksums
bc098fb4416c5e74a86fd858e59763bee7d07c10ee7c60c04084e4553c6e69f3
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 10, 2026.

Transparency log

Security for stratyfy-cli 0.1.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.

Select from 2 files

Attestation for stratyfy_cli-0.1.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 10, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page