Install the us-tariff CLI with Homebrew

Invoice × Tariff editorial

Who this is formacOS and Linux users who want the us-tariff CLI as a single native binary — shell pipelines, cron jobs, ops boxes and machines without Node.js.

Install with brew install invoicetariff/tap/us-tariff-lookup: Homebrew builds the Go CLI into one native binary — no Node.js needed. us-tariff meta reports the bundled snapshot, us-tariff search does English/Chinese HTS lookup, us-tariff changelog lists rule changes. Fully offline; landed-cost math lives in the npm package and web calculator.

What the tap installs

invoicetariff/homebrew-tap is the official Homebrew tap for the us-tariff CLI: the Go build of the same versioned snapshot that powers this site's calculators, the npm package and the Go module — a single native binary, zero runtime dependencies, no API key, no network calls. The command it puts on your PATH is us-tariff.

The formula builds from the release source with the Go toolchain (stdlib-only, so the result is a self-contained static binary). v1 ships the query surface: HTS search, ruleset meta and a machine-readable changelog. Landed-cost math is intentionally not in this build — the Homebrew vs npm comparison below shows which entry point carries it.

Install

Requires Homebrew on macOS or Linux. That's the only prerequisite:

brew install invoicetariff/tap/us-tariff-lookup

What happens under the hood, all automatic:

  • The tap is added for you. The user/repo/formula shorthand clones github.com/invoicetariff/homebrew-tap — no separate brew tap step needed.
  • Go is a build-time dependency only. The formula declares depends_on "go" => :build, so Homebrew installs its own Go toolchain first if you don't have one. The finished product is a single stripped binary; nothing Go-related stays on your runtime path.
  • The formula self-tests on install. Its test block runs us-tariff meta and asserts the bundled snapshot version and as-of date, so a broken install fails loudly. Re-run it any time with brew test invoicetariff/tap/us-tariff-lookup.
  • Two command names resolve. The build is named us-tariff-lookup; the formula symlinks it as us-tariff, which is the name used everywhere in the docs. Uninstall with brew uninstall invoicetariff/tap/us-tariff-lookup (drop the tap afterwards with brew untap invoicetariff/tap if you like).

Your first commands: meta, search, changelog

The whole command surface in one sitting:

us-tariff meta                    # what's inside / which data version
us-tariff search "cotton t-shirt" # EN / 中文 / code prefix, optional limit
us-tariff search 保温杯 20        # Chinese keywords work the same way
us-tariff changelog 5             # recent rule changes, newest first

Every command prints indented JSON with an envelope of rulesetVersion, dataAsOf and disclaimer, plus the payload under result — pipe it straight into jq. The search envelope looks like this (formatting abbreviated):

{
  "rulesetVersion": "0.3.4",
  "dataAsOf": "2026-10-07",
  "disclaimer": "Estimates for planning only — …",
  "result": {
    "count": 1,
    "hits": [
      {
        "entry": {
          "hts8": "61091000",
          "description": "T-shirts, singlets and other vests, knitted, of cotton",
          "descriptionZh": "棉制针织T恤/背心",
          "general": "16.5%",
          "keywordsZh": ["T恤", "棉制", "针织", "上衣"],
          "sample": true
        },
        "matchedBy": "en"
      }
    ]
  }
}

That hit is the golden test case shared across all distributions: cotton t-shirt lands on HTS 61091000 with its official USITC general rate. us-tariff search 保温杯 finds the insulated-bottle line (96170010, 10%) through the bundled 中文 descriptions and keywords, with matchedBy reporting "zh".

Reading the results

The envelope — treat rulesetVersion and dataAsOf as part of every answer you pass downstream, and carry disclaimer through to end users.

Search hits pair a curated MFN entry with the surface that matched:

  • entry.hts8 / entry.description / entry.descriptionZh — the 8-digit code and both descriptions.
  • entry.general — the official USITC Column 1 general rate, as a string like "16.5%".
  • matchedBy — "code", "en" or "zh". Multi-word queries are AND-tokenized and every token must match on one surface (all-in-the-code, all-in-the-English-description, or all-in-the-中文); the check runs code → en → zh and reports the strongest surface that matched. Keep queries single-language — "cotton 保温杯" matches nothing because no single surface contains both tokens.
  • entry.sample — true means the rate line is not yet verified line-by-line against the Federal Register text: planning-grade, not certified entry data.
  • limit defaults to 10 when omitted or <= 0; results keep the snapshot's curation order, not a relevance score; a non-matching query returns "count": 0 with an empty hits array.

Changelog entries carry date, layer, status ("published" = in force, "upcoming" = future effective date, "historical" = superseded layer kept for refund lookups), titleEn and the Chinese title/summary with the Federal Register citation in the raw payload. us-tariff changelog defaults to 10 entries; pass a number to cap it — result.count always reports the total number of bundled entries regardless of the limit.

Homebrew or npm — which entry point for which job

The Homebrew CLI and the npm package are the same engine over the same snapshot. They differ in what wraps it:

Homebrew (this tutorial) npm package (us-tariff-lookup)
Install brew install invoicetariff/tap/us-tariff-lookup npm install us-tariff-lookup
Runtime dependency none — single native Go binary Node.js ≥ 18
Platforms macOS, Linux anywhere Node runs — macOS, Linux, Windows, CI, serverless
Commands 3 — meta, search, changelog (query surface) 5 — meta, search, calc, refund, changelog
Landed-cost math (calc / refund) not included included
Use as a library no — binary only (Go projects: import the Go module directly) yes — TypeScript API (searchHts, calculateLandedCost)
Run without installing no yes — npx us-tariff meta
Updates brew update then brew upgrade npm update (or a fresh npx)

Rules of thumb:

  • Shell pipelines, cron jobs, ops boxes, admin machines without Node.js → Homebrew. One binary, no interpreter to keep patched, trivially scriptable, works air-gapped.
  • JavaScript/TypeScript projects, Windows, CI, anything that needs the stacked calculation or the refund window → npm. calc and refund only exist there, and the library API embeds the engine next to your code.
  • Mixed stacks are a fine pattern: the brew binary for quick terminal lookups, the npm package for pricing the line — both print their rulesetVersion, so you can assert the two sides agree before comparing numbers.

Error handling and limits — the honest inventory

  • No network, so no timeouts, no retries, no rate limits, no API keys. The JSON ships inside the binary; every run is deterministic against the pinned snapshot. Safe in CI, air-gapped deployments and scheduled jobs.
  • Failure modes are explicit and scriptable. No arguments or an unknown command prints usage to stderr and exits with code 2 — check $? in shell pipelines. search with a wrong limit argument just falls back to the default rather than failing.
  • No match is not an error. A query that matches nothing exits 0 with "count": 0 — treat empty results as a data-coverage question (see the FAQ), not a crash.
  • The one real risk is version drift, not failure. brew upgrade moves your numbers when a new formula lands in the tap. Echo rulesetVersion/dataAsOf from us-tariff meta next to any result you store or forward.

Keep the data fresh

The snapshot is rebuilt monthly (and ad-hoc when major actions land) from the open rates repo, and the tap's formula is re-bumped with each CLI release — move up with brew update && brew upgrade invoicetariff/tap/us-tariff-lookup. To see what moved between versions, read us-tariff changelog.

One honest caveat: the release channel can lag the website. At the time of writing (November 2026), CLI release v0.1.1 bundles snapshot v0.3.4 (as of 2026-10-07) while the website's seed has already moved to v0.3.5 (as of 2026-11-25). Never assume parity — read the version from us-tariff meta, and if the numbers must match the site exactly, use the npm package (npx us-tariff meta to check its bundled version) or the web calculator. The live feed with old → new values is the Tariff Radar, with an RSS feed if you want to automate reactions.

What's inside the bundled binary

Counts below are for the current release (snapshot v0.3.4, as of 2026-10-07) — run us-tariff meta to see them for your own build:

Surface Count Notes
Curated MFN codes 484 High-frequency HTS 8-digit codes with official USITC general rates (EN + 中文)
China Section 301 lines 25 Lists 2/3/4A + 2026 four-year-review additions
Global 301 tiers 60 The 2026 global Section 301 program tiers
Section 232 measures 8 steel / aluminium / copper / autos / furniture / pharma / semiconductors / timber
Changelog entries 57 published + upcoming + historical, each sourced officially

The bundled search covers curated high-frequency codes, not the full 5,689-line HTS — the complete table lives in the hs-codes-database repo and on the HTS search page. Need layers the CLI does not model (fees, IEEPA history, per-entry source URLs)? The full JSON ships in the release tarball on GitHub, the Go module exposes it via RulesetSeedRaw()/ChangelogRaw(), and the same data is downloadable from the tariff data page.

No landed-cost math in the brew CLI — use the npm package or the web calculator

The Homebrew build intentionally ships only the query surface. Stacked duty layers, specific/compound rates, MPF/HMF entry fees and per-unit landed cost live in the us-tariff-lookup npm package (same snapshot, TypeScript, works in Node) and on this site's tariff calculator — no code at all. A common pattern: look codes up and track rule changes with us-tariff in the shell, then price the line through the npm package with the same rulesetVersion so both sides agree digit for digit.

Frequently asked questions

Does the Homebrew CLI calculate landed cost like the npm package?
No. The brew formula ships the Go CLI's query surface — meta, search, changelog (3 commands). The stacked calculation (MFN + 301 + 232 + MPF/HMF, per-unit landed cost) and the refund window live in the us-tariff-lookup npm package (commands calc and refund) and the web calculator. Use the two together against one rulesetVersion: brew for lookups in the shell, npm for money math.
Do I need Go or Node.js installed to use it?
Neither at runtime. The formula declares Go as a build-time dependency, so Homebrew installs its own Go toolchain if needed, compiles the stdlib-only source into a single native binary, and the CLI runs without any interpreter afterwards. Node.js is only relevant for the npm variant of the same engine.
Does it call any API, and does it need an API key?
No and no. The ruleset JSON is compiled into the binary, nothing touches the network at runtime, and there are no keys, quotas or timeouts — it works offline, in air-gapped environments and behind strict firewalls.
How current is the data compared with the website?
The snapshot is rebuilt monthly and the tap is re-bumped with each CLI release, but the release channel can lag the site: at the time of writing, release v0.1.1 bundles snapshot v0.3.4 (as of 2026-10-07) while the website seed is at v0.3.5 (as of 2026-11-25). Always read the version from us-tariff meta instead of assuming parity; brew update && brew upgrade moves you up when a new release lands. If numbers must match the site exactly, use the npm package or the web calculator.
Can I use it on Windows?
Homebrew targets macOS and Linux, so there is no native Windows formula. On Windows, use the npm package (npx us-tariff search … works without a global install), or the Go module if you build Go projects. Under WSL2, the Linux Homebrew route of this tutorial works as written.
Why can't search find my product?
The bundled search covers a curated set of high-frequency codes (484 in the current release), not all 5,689 HTS 8-digit lines — check the full table in the hs-codes-database repo or the HTS search page. Also keep queries single-language: every token must match on one surface (code, English description or 中文), so a mixed "cotton 保温杯" query matches nothing.
invoicetariff/homebrew-tap on GitHub

MIT licensed, single native binary for macOS and Linux. Source repos, releases and the sibling npm / Go / PHP packages are linked from the open source page.