Migrate from posthog-cli to hog
posthog-cli is deprecated and has been replaced by hog. We're rewriting the CLI docs for hog. Until then, the other CLI pages describe posthog-cli, and this guide maps each posthog-cli command, flag and variable to hog.
hog is the successor to posthog-cli. It does what posthog-cli does, with new command names, HOG_ environment variables, and output that agents can read.
Open your coding agent in the repository and give it this prompt:
It finds every place posthog-cli runs, makes the changes, and stops when it needs you, for example to approve a login.
This guide is written for a coding agent to follow from top to bottom. Some steps need a person. When you reach one, stop, say what they need to do and why, and continue once they confirm. Steps for a person lists them.
The steps move one repository: its scripts, its CI and the machine you work on. The sections after the steps are the reference: every variable, command and flag that changed.
The goal
- Nothing in the repository runs
posthog-cli, depends on@posthog/cli, or reads aPOSTHOG_CLI_variable. - The build uploads the same symbols with hog. hog sends the same bytes and content hashes, so keep the release names, paths and settings as they are.
- In GitHub Actions, GitLab.com and Depot CI, the job logs in with its OIDC token instead of a stored personal API key.
- 1
Find where posthog-cli runs
Search the whole repository, including hidden folders:
TerminalLook in particular at:
package.json:@posthog/clias a dependency, and scripts that callposthog-cli. Leave lockfiles to the package manager.- CI config:
.github/workflows/,.gitlab-ci.yml,.depot/workflows/,.circleci/,bitbucket-pipelines.yml,Jenkinsfile,vercel.json,netlify.toml. - Build scripts: Dockerfiles, Makefiles, shell scripts, Fastlane lanes, Gradle tasks and Xcode build phases.
- Environment files:
.env*, and any file passed with--dotenv-file. - The names of CI secrets, such as
POSTHOG_CLI_API_KEY. You can't read their values, and you don't need to. PostHog/resolve-release@v1in a GitHub Actions workflow. It runs posthog-cli inside the action, so it changes too.
Also look for a PostHog build plugin:
@posthog/nextjs-config,@posthog/webpack-plugin,@posthog/rollup-plugin,@posthog/nuxt, thecom.posthog.androidGradle plugin, posthog-ios'supload-symbols.sh, or theposthog-react-nativeXcode and Gradle scripts. A plugin runs the CLI for the build, so it changes differently.List what you found before you change anything, so the person can check it.
- 2
Install hog
Use the package manager the project already uses. Its lockfile tells you which one:
Yarn 2 and later have no global installs, and Yarn 1 has no
dlx, so use npm for those.When the project ran posthog-cli through
@posthog/cliinpackage.json, remove@posthog/cliand addhogwith that package manager, so the lockfile changes with it. When it installed posthog-cli globally in CI, install hog the same way, with the same package manager.A project without Node, or a machine without a project, can use Homebrew or the install script:
hog is two filesEvery install puts
hog-worker, the program hog runs forhog error-tracking, next tohog. posthog-cli is one file and hog is two, so a Dockerfile or CI cache that copied theposthog-clibinary must copy bothhogandhog-workerinto the same folder.hog upgradereplacesposthog-cli update.In GitHub Actions
A workflow that installed posthog-cli with curl or a download step, outside a Node project, uses
PostHog/setup-hoginstead. It downloads the newest hog 1.x andhog-worker, checks them against the checksums of the hog release, caches them, and puts hog onPATHfor the later steps:YAMLTo control when hog changes, pin the version, and the checksum of each archive your runners use, from the
SHA256SUMSof the hog release:YAMLA workflow that installs hog with the project's package manager doesn't need setup-hog.
- 3
Log in on the machine
- Run
hog auth migratewhen posthog-cli was logged in on this machine. It moves that login to hog. - Otherwise run
hog auth login. An agent passes--region usor--region eu, or--hostfor self-hosted PostHog, after asking the person which. It gets a link and exit code 3: give the link to the person, and runhog auth login --waitonce they approve.
hog auth statusshows which login hog uses and why. - Run
- 4
Log in from CI
posthog-cli in CI almost always logs in with a personal API key, stored as a CI secret such as
POSTHOG_CLI_API_KEY. That key is a poor fit for CI:- It acts as the person who created it, so everything CI does runs as them, and it stops working when they leave the organization.
- It works until someone deletes it, so a copy that leaks, through a log or a compromised action, keeps working.
- It often has more scopes and projects than the job needs, because a person made it for themselves.
- Every workflow and person with access to the secret can use it.
GitHub Actions, GitLab.com and Depot CI
Use the job's OIDC token, so CI stores no key at all. The CI provider signs a token that says which repository, branch and workflow the run comes from. hog trades it for a PostHog token that lasts a few minutes, works in one project, has only the scopes an admin allowed, and only for the runs the admin allowed, such as pushes to
main.- In the repository, logged in, run
hog ci setup --scope error_tracking:write. List every scope the job needs, like--scope error_tracking:write,query:read. - hog asks which runs may get a token, such as pushes to
main. An agent gets the presets PostHog offers: ask the person which one fits, and pass it with--preset. - An organization admin approves the request in PostHog. This needs a person.
hog ci setup --waitchecks on it. - Add the
hostandprojectIdthat hog prints toposthog.json, and the snippet it prints to the job. The snippet lets the job get an OIDC token. For self-hosted PostHog, hog leaves the host out and says to setHOG_HOSTin the job instead. - Remove
POSTHOG_CLI_API_KEYfrom the job.HOG_PERSONAL_API_KEYwins over OIDC, so don't set it either.
Once a run passes with OIDC, the old key has nothing left to do: the person deletes it from the CI secrets, and deletes it under Personal API keys in their PostHog account settings if nothing else uses it.
Every other CI provider
These providers have no OIDC login for PostHog yet, so the job keeps a personal API key. Rename the variables the job sets, with the table below. The secret keeps its value. Only the variable the job sets changes, so the job can set
HOG_PERSONAL_API_KEYfrom the same secret until someone renames it. Give the key only theerror_tracking:writescope, or the scopes the job needs, and only the project it uploads to.PostHog/resolve-release
PostHog/resolve-releasefinds or creates the error tracking release for a build, and outputs its ID. v1 runs posthog-cli with a personal API key. v2 runs hog with the job's OIDC token.To upgrade from v1 to v2:
- Change
PostHog/resolve-release@v1toPostHog/resolve-release@v2. - Set
hog-versionto1for the newest hog 1.x, or to an exact version such as1.0.0with its checksum inhog-sha256, as in setup-hog. - Add
permissions: id-token: writeto the job, and runhog ci setup --scope error_tracking:writeonce, as above. - Remove the
api-keyinput. Delete its secret once a run passes. - Keep
project-id, or move it and the host intoposthog.json.
diffv2 also puts hog on
PATH, so later steps in the job can run it. A workflow that only needs hog, and doesn't use therelease-idoutput, usesPostHog/setup-hoginstead. - 5
Rewrite the commands
Replace each command with the commands table, and check its flags against flags that changed. A script that reads hog's output passes
-o textor-o json, as Output explains. - 6
Update build plugins
OptionalWhen a PostHog build plugin is the only thing that runs posthog-cli, update the plugin to a version that runs hog itself. The plugin config stays the same.
Plugin First version that runs hog @posthog/nextjs-config1.13.0 @posthog/webpack-plugin1.9.0 @posthog/rollup-plugin1.7.0 @posthog/nuxt1.10.0 com.posthog.android(Android Gradle plugin)1.9.0 upload-symbols.sh(posthog-ios)4.3.0 posthog-react-native(JavaScript source map scripts)4.89.0 Older versions run posthog-cli and need
personalApiKey, so keep the key until the plugin is on one of these versions. In GitHub Actions, GitLab.com and Depot CI, the plugin can then use the job's OIDC token too: runhog ci setupas in Log in from CI, then removepersonalApiKeyfrom the plugin config.The Android, iOS and React Native integrations run hog when it's installed, so install hog where the build runs, as in Install hog. Without hog, they keep running posthog-cli and warn that it's deprecated. React Native's native symbol uploads run through the posthog-ios and Gradle plugin versions the app resolves, so they follow those rows. To keep posthog-cli while hog is installed, set
postHogExecutable = "posthog-cli"in the Android Gradle plugin. With OIDC, removepostHogApiKeyfrom the Android Gradle plugin config.The plugins still read posthog-cli's environment variables, such as
POSTHOG_RELEASE_MODE, and print a warning to rename each one, as in the table below. Check the result
Checkpoint- The search from step 1 finds nothing, except the lockfile before the next install.
hog auth statusshows a login, on the machine and in CI.hog config checkpasses when the repository has aposthog.json.hog error-tracking process <build output> --dry-run, oruploadwhen the build injects chunk IDs itself, lists the same symbol sets posthog-cli uploaded, and sends nothing.- The CI job passes, and its upload step lists the symbol sets it uploaded.
Steps for a person
When your coding agent runs the migration, it stops and asks you to do these, because an agent can't:
An agent can't do these. Ask for each one, and say why:
- Approve the browser login from
hog auth login. - Approve
hog ci setupin PostHog. It needs an organization admin. - Delete
POSTHOG_CLI_API_KEYfrom the CI secrets once a run passes with hog. - Delete the personal API key in PostHog when nothing else uses it.
Reference
What stays the same
- Your login.
hog auth migratemoves the keyposthog-cli loginsaved in~/.posthog/credentials.jsoninto hog's store. It checks the key with PostHog first, and a key PostHog rejects stays out of hog's store. hog doesn't read that file otherwise and never changes it. - Uploads. hog sends the same bytes and content hashes, so either CLI can re-upload what the other uploaded. Chunk IDs and releases don't change.
- posthog.json. hog reads the
languagesentriesposthog-cli exp schemawrites, and the endpoint YAML filesposthog-cli exp endpointswrites. - Global flags.
--host,--dotenv-file,--no-fail,--skip-ssl-verificationand--rate-limitwork as before. posthog-cli took them only before the command, and hog also takes them after it.
Environment variables
hog doesn't read posthog-cli's variables. Rename these:
| posthog-cli | hog |
|---|---|
POSTHOG_CLI_API_KEY, POSTHOG_CLI_TOKEN | HOG_PERSONAL_API_KEY |
POSTHOG_CLI_PROJECT_ID, POSTHOG_CLI_ENV_ID | HOG_PROJECT_ID |
POSTHOG_CLI_HOST | HOG_HOST |
POSTHOG_CLI_ORGANIZATION_ID | hog api call --organization-id |
POSTHOG_CLI_DOTENV_FILE | HOG_DOTENV_FILE |
POSTHOG_CLI_DRY_RUN | HOG_DRY_RUN |
POSTHOG_CLIENT_RATE_LIMIT | HOG_RATE_LIMIT |
POSTHOG_CLI_SOURCEMAP_UPLOAD_CONCURRENCY | HOG_UPLOAD_CONCURRENCY |
POSTHOG_RELEASE_MODE | HOG_RELEASE_MODE |
POSTHOG_HOME | HOG_HOME |
POSTHOG_CLI_INSTALL_DIR, for the install script | HOG_INSTALL_DIR |
posthog-cli api also read POSTHOG_API_KEY, POSTHOG_HOST, POSTHOG_PROJECT_ID and POSTHOG_ORGANIZATION_ID.
Apps often set these for other reasons, so rename them only where they were there for posthog-cli.
HOG_HOME moves only the ~/.posthog folder, where hog auth migrate finds posthog-cli's login.
hog keeps its own settings, and its logins when there is no keychain, in another folder, as Credentials explains.
A dotenv file that --dotenv-file names needs the new names too.
In CI, you can set both sets of names while some jobs still run posthog-cli.
Commands
| posthog-cli | hog |
|---|---|
login | auth login, plus auth status (or whoami), auth add for more scopes, and auth logout |
update | upgrade |
sourcemap inject --directory <dir> | error-tracking inject <dir> |
sourcemap upload --directory <dir> | error-tracking upload <dir> --kind js. Without --kind, hog also uploads the native debug files it finds |
sourcemap process --directory <dir> | error-tracking process <dir> --kind js. Without --kind, hog also uploads the native debug files it finds |
hermes inject --directory <dir> | error-tracking inject <dir> |
hermes clone -m <file1> -c <file2> | error-tracking clone <file1> <file2> |
hermes upload --directory <dir> | error-tracking upload <dir> |
dsym upload --directory <dir> | error-tracking upload <dir> |
proguard upload --path <file> --map-id <id> | error-tracking upload <file> --map-id <id> |
symbol-sets upload --directory <dir> | error-tracking upload <dir> |
exp hermes, exp proguard, exp dsym | The same as hermes, proguard and dsym above |
symbol-sets download --id <id> -o <dir> | error-tracking download <id> --output-dir <dir> |
symbol-sets download --ref <ref> | error-tracking download <ref>, with --ref when the ref looks like an ID |
symbol-sets extract <file> -o <dir> | error-tracking extract <file> --output-dir <dir> |
release resolve | error-tracking release -o text |
release resolve --json | error-tracking release -o json |
exp query run <query> | query run <query> |
exp query check <query> | query check <query> |
exp endpoints list, get, open, run, diff | endpoints list, get, open, run, diff. list shows one page, and --offset picks the next |
exp endpoints pull -o <dir> | endpoints pull --to <dir> |
exp endpoints push | endpoints push |
exp schema pull -o <file> | schema pull --file <file> |
exp schema status | schema status |
api tools, search, info, schema, call | api tools, search, info, schema, call, with -o json for --json |
api skill list, api skill install <id> | skills list, skills add <skill...>. add takes any listed skill and writes to the folder your agent reads |
hog et is short for hog error-tracking.
hog error-tracking upload detects what each path holds, so one command uploads JavaScript, Hermes, ProGuard, dSYM and ELF symbols, and --kind skips detection.
Run hog <command> --help for every flag, or hog commands -o json for all of them at once.
These posthog-cli commands don't come to hog. Remove them from scripts and CI, and tell the person when a repository depends on one:
api agents-md.hog setupwrites the AGENTS.md note for a project it sets up.exp logs import,exp task, andexp query editor.
Flags that changed
- Paths are arguments.
--directory,--path,-mand-cbecome positional arguments, and one command takes several paths. -ois the output format. It takestextorjson. posthog-cli's-opaths become--toinendpoints pull,--fileinschema pull, and--output-dirindownloadandextract.--stdinbecomes-.hog error-tracking upload -andprocess -read one path per line from stdin, like--stdindid.injecthas no stdin form, so pass its paths as arguments.- Old aliases are gone. Use
--release-namefor--project, and--release-versionfor--version.--file(for--directory) and--ignore(for--exclude) are gone with the flags they stood for. --includeand--excludeare gone. List the paths as arguments, or keep them inerrorTracking.sourcesinposthog.json, whereignoreglobs skip files.--skip-release-on-failis gone. hog always retries without the release when PostHog says a chunk belongs to another release, as posthog-cli did.--main-dsymis gone. hog takes the release from--release-name,--release-version,--info-plist,posthog.jsonor git.dsym upload --no-release-bindis gone. hog has no such flag, so remove it from a script that passes it.symbol-sets upload --source-rootis gone, with no replacement.endpoints runtakes-o.--jsonand--format jsonbecome-o json,--format tablebecomes-o text, and-qis gone.endpoints diff -vbecomes--verbose. hog'sdiffhas no short form for it.--debugand--raware global.--debugprints each request to stderr for every command, and--rawprints PostHog's whole response, asexp query check --rawdid.
Dry runs
posthog-cli's --dry-run skipped uploads and release without doing anything.
hog's --dry-run does the work and shows the result without changing anything: uploads list each symbol set with its content hash, and schema pull, endpoints pull and push show what they would change.
HOG_DRY_RUN=1 turns on --dry-run for every command that has one. Commands that only read run as usual.
Commands that change something but have no dry run fail when HOG_DRY_RUN is set: auth login, auth logout, auth add, auth migrate, mcp add, setup, skills add and upgrade.
Output
hog prints tables and colors for a person at a terminal, and JSON when an agent runs it, when stdout is a pipe, or with -o json.
A script that reads hog's output should pass -o text or -o json, so the format doesn't depend on where it runs:
posthog-cli exp query run prints one JSON array per row.
hog query run -o json prints one object instead: columns, with the name and ClickHouse type of each, rows, as arrays in column order, and hasMore, which is true when PostHog cut the rows off.
A script that read one row per line reads .rows instead:
--raw prints PostHog's whole response, as --debug did in posthog-cli.
posthog-cli waits for a query until PostHog finishes it.
hog does the same at a terminal and in CI.
An agent or a pipe outside CI waits up to a minute, then gets {"status":"running","queryId":"<query-id>","next":"hog query run --wait <query-id>","hint":"…"} and exit code 4.
hog query run --wait <query-id> waits for that query again.
A query that joins a run another caller named with an ID beyond letters, digits, _ and - waits until it finishes, as in posthog-cli.
Errors go to stderr, as JSON with a stable code in JSON mode.
Each error also names the hog feedback command to report it, as a last line for a person and as feedback in the JSON. posthog-cli's errors don't.
Exit codes
posthog-cli exits with 1 for every failure, and with 0 when a check such as exp endpoints diff finds a problem.
hog gives each outcome its own code, so a script can tell them apart without reading stderr:
| What happened | posthog-cli | hog |
|---|---|---|
| The command worked | 0 | 0 |
| The command failed | 1 | 1 |
A check found problems: errors in query check, drift in endpoints diff, a stale SDK in schema status | 0 | 1 |
| A usage error | 2 | 2 |
| A person has to act: log in, approve in the browser, add a scope, or answer a question | 1 | 3 |
The work started and is still running. The output names the --wait command that resumes it | Not used | 4 |
--no-fail turns every failure into 0 in both CLIs. In hog that covers 1, 3 and 4. A usage error keeps code 2 in both.
A pipeline that reads exit code 1 as "not logged in" reads 3 with hog.
posthog.json
hog reads more from posthog.json than posthog-cli did: the host, error tracking sources and release, the endpoints folder, and defaults for --no-fail and --rate-limit.
When the file is invalid, every command stops except hog config check, which lists the problems, and hog config schema.
posthog-cli rewrites posthog.json with only languages when it pulls a schema, so it drops hog's settings.
Run only hog's schema pull once a project uses hog settings.
Where hog writes
posthog-cli writes and deletes files wherever a repository's files point it. hog keeps those writes inside the project:
schema pullrefuses anoutput_pathinposthog.jsonoutside the project, and any module path inside the repository that links out of it. A module outside the repository, such as../web/typed.ts, needs--fileon each run.- hog won't write a
posthog.jsonthat links out of its folder. endpoints pullwrites only inside the endpoints folder, and leaves alone a file there that links somewhere else.endpoints.dirinposthog.jsonmust be inside the project.error-trackingcommands refuse a folder inerrorTracking.sourcesthat resolves outside the project, through.., an absolute path or a link.error-trackingcommands skip a bundle whose sourcemap is outside the selected paths, and never open that map, so they don't read, rewrite, upload or delete it. Pass the folder that holds the maps too.
A path you pass with --file, a file you name with --to, or a folder you pass to an error-tracking command can be anywhere.





