agentleFS
PostHogKnown publisherPostHog/posthog-foss/.agents/skills/developing-the-cli/SKILL.md

developing-the-cli

Skill731 starsChanged 2 days agoMITView on GitHub

Changes PostHog's command line in this repo, which ships as two CLIs that must stay in step: posthog-cli, the Rust CLI in `cli/`, and hog, its TypeScript successor in `hog/`. Use before writing, fixing, or reviewing code under `cli/` or `hog/`, including symbol and sourcemap uploads, dSYM, Hermes and ProGuard handling, releases, login and credentials, query, endpoints, and schema commands, or a security fix in either CLI. Carries the rule that every change lands in both CLIs, how to find the matching code on the other side, the upload parity goldens, and the test and release steps for each. Trigger terms: posthog-cli, hog CLI, cli/, hog/, cargo, bun, symbol_sets.rs, upload.ts, parity golden, sampo changeset, port to hog.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When a change does not apply to the other CLI, say why in the PR description, for example "hog prints only the error message, which never …

    line 37
  2. Very specific:

    Add the regression test on both sides too.

    line 76
  3. Very specific:

    Use /writing-tests for both.

    line 77
  4. Very specific:

    Add a mockup of the terminal for each case that changed: success, each error, and each prompt, as a person at a terminal sees it.

    line 82
  5. Very specific:

    When agent output (-o json) changed, show that too.

    line 83
  6. Very specific:

    Put each in a console code block that starts with the command, and give the exit code when it isn't 0.

    line 86
  7. Very specific:

    Use the cli scope in the PR title, as in fix(cli): ..., for a change to either CLI.

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Developing the CLI

PostHog has two command lines in this repo:

CLIFolderLanguageStatus
posthog-clicli/RustPublished. Customers and the SDK build integrations run it today
hoghog/TypeScript, BunVersion 1, the successor. Not published yet; see hog/README.md

Both stay in use until every caller moves to hog, so both must behave the same.

Change both CLIs

A change to one CLI is REQUIRED to land in the other one, in the same PR. This covers features, bug fixes, error handling, new flags, and security fixes. A fix that lands only in cli/ leaves the bug in hog, and the reverse ships a hog that posthog-cli users never get.

The only exceptions are commands that exist on one side:

  • hog/src/commands/legacy.ts lists the commands posthog-cli still owns (logs, tasks, upgrade). A change to those touches only cli/.
  • hog-only commands, such as hog setup, hog api, hog ci and hog auth migrate, have no Rust counterpart.
  • The "Not planned" list in hog/README.md names posthog-cli commands hog will not port.

When a change does not apply to the other CLI, say why in the PR description, for example "hog prints only the error message, which never contains the URL". Reviewers: a PR that touches cli/src/ or hog/src/ without the other side, and without that sentence, is incomplete.

Find the matching code

Port the behavior, not the code. The two CLIs are laid out differently.

  1. Map the command with the table in hog/MIGRATING.md (sourcemap upload becomes error-tracking upload, and so on).
  2. Find the hog side with the layout table in hog/AGENTS.md. Common pairs:

    posthog-clihog
    cli/src/api/symbol_sets.rs (upload protocol)hog/src/error-tracking/upload.ts
    cli/src/sourcemaps/, cli/src/debug_symbols/hog/src/error-tracking/kinds/, .../native/
    cli/src/release/hog/src/error-tracking/release.ts, git.ts
    cli/src/login.rshog/src/commands/auth/, hog/src/posthog/
    cli/src/experimental/hog/src/commands/query/, endpoints/, schema/
  3. Check how the runtimes differ before copying a fix. For example, reqwest puts the request URL in its error text, while Bun's fetch keeps it off error.message, so a redaction needed in Rust may not be needed in hog. Verify such a difference, then name it in the PR.

Follow each side's rules

  • hog: read hog/AGENTS.md before the first edit. It holds the command, output, error and typed-boundary rules.
  • Uploads: hog must send the same bytes, content hashes and requests as posthog-cli, or re-uploads fail with content_hash_mismatch. Read hog/test/parity/README.md before changing anything that reaches an upload. When a Rust change alters what posthog-cli uploads, regenerate the goldens from the new binary as that README describes, and review the diff.
  • posthog-cli: every user-visible change needs a sampo changeset in cli/.sampo/changesets/, as cli/.sampo/README.md describes. hog has no changesets yet.

Test both sides

# posthog-cli
cargo test --locked --manifest-path cli/Cargo.toml
cargo clippy --locked --manifest-path cli/Cargo.toml --all-targets -- -D warnings
cargo fmt --manifest-path cli/Cargo.toml -- --check

# hog
pnpm --filter @posthog/hog unit
pnpm --filter @posthog/hog typecheck

Add the regression test on both sides too. hog tests drive the real CLI with runHog from hog/src/testing.ts, and its respond option fakes PostHog and object storage, so a hog test can cover the same failure as the Rust one without a server. Use /writing-tests for both.

Show the terminal in the PR

A PR that changes what either CLI prints, asks or exits with shows it in the description. Add a mockup of the terminal for each case that changed: success, each error, and each prompt, as a person at a terminal sees it. When agent output (-o json) changed, show that too.

  • Copy the mockup from a real run, such as pnpm --filter @posthog/hog hog <command> or cargo run --manifest-path cli/Cargo.toml -- <command>. Write one by hand only for a state you can't reach locally, and say which.
  • Put each in a console code block that starts with the command, and give the exit code when it isn't 0.
  • Reviewers judge wording, order and hints from the mockup, so they don't have to check out the branch to see what users get.

Before you report done

  • The PR description shows the terminal for each changed case.
  • Both CLIs carry the change, or the PR says why one does not need it.
  • Both test suites pass, and hog/test/parity/ is green.
  • cli/ has a changeset when its behavior changed.
  • Use the cli scope in the PR title, as in fix(cli): ..., for a change to either CLI.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.