You need Go 1.24 or newer. GoReleaser 2.x and Docker are needed only to build release artifacts.
make build # bin/tmh
make test # go test -race ./...
make lint # go vet, the generated-file checks, ShellCheck, gofmt and staticcheck
make check # lint and test
make docs # regenerate the command reference after changing a command
CI runs the tests on Linux and macOS with Go 1.24 and the latest Go, make
lint, ShellCheck, and goreleaser check; the Docs workflow builds the
documentation site. Every change must pass all of them. make lint skips
ShellCheck when it isn’t installed (brew install shellcheck).
| Path | What it is |
|---|---|
cmd/tmh |
main: wires the real transport, keyring, clock and terminal into the command tree. |
cmd/gen, internal/gen |
The generator for the resource commands, docs/reference/resources.md and docs/reference/code-samples.json. |
cmd/docgen, internal/docgen |
The generator for the command reference in docs/reference/commands/. |
internal/doctest |
Reads the docs for the documentation tests: code blocks, links, anchors and shell commands. |
internal/commands |
The root command and the hand-written commands. |
internal/commands/generated |
Generated resource commands. Never edit them by hand. |
internal/api |
The HTTP client: tokens, retries, idempotency, problem details. |
internal/events |
The events tail forwarder: canonical JSON and the local signature. |
internal/config |
Profiles, config.toml, state.toml and the keyring store. |
internal/testkit |
The fake transport and harness every command test runs through. |
openapi/ |
The vendored Developer API document and SDK IR. See its README. |
docs/topics/, docs/reference/ |
The user documentation; see Documentation. |
examples/ |
Shell scripts using tmh against the Sandbox. |
docs/adr/ |
Architecture decisions. Read them before changing behavior they cover. |
Use the terms in GLOSSARY.md in names, messages and docs.
The resource commands come from openapi/sdk-ir.json, the IR the TeachMeHIPAA
monorepo builds from the Developer API document (ADR-0001). To pick up an API
change:
openapi/, as
openapi/README.md describes, then update OPENAPI_VERSION.make generate. It rewrites the commands, the resource reference and
the command reference.make check. internal/commands/generated/coverage_test.go fails if
any IR method lacks exactly one command.make lint runs go run ./cmd/gen -check and go run ./cmd/docgen -check,
which fail when the committed commands or references differ from what the IR
and the command tree generate. To change the commands’ shape, change
internal/gen and regenerate; never edit generated files.
Tests run tmh <args> through internal/testkit: an injected fake transport,
an in-memory keyring, a fake clock and captured stdout and stderr. Assert on
output, exit code and the requests sent. The events package checks
signatures against vectors computed independently from the platform’s
canonical string. No test calls the live API or touches the real keyring.
internal/commands/exit_code_tables_test.go parses the exit-code tables in
the README and docs/topics/exit-codes.md and fails if either differs from
the codes tmh returns, so update them together.
| Path | What it is | Kept in sync by |
|---|---|---|
README.md |
Overview, install, quickstart, links | The doc tests |
docs/topics/*.md |
Topic pages, each opening with a synopsis, and the recipes | The doc tests |
docs/reference/commands/*.md |
Every command and flag, from the command tree with cobra/doc |
make docs; go run ./cmd/docgen -check and internal/docgen’s test |
docs/reference/resources.md |
Every API operation and its command, with an example, from the IR | make generate; go run ./cmd/gen -check and internal/gen’s test |
docs/reference/code-samples.json |
One shell sample per IR operationId, vendored by the monorepo’s API reference as its cli samples |
make generate; go run ./cmd/gen -check, internal/gen’s test and code_samples_test.go |
docs/README.md, examples/README.md |
Indexes | Hand-written; links checked |
examples/*.sh |
Scripts against the Sandbox | ShellCheck; the doc tests check their tmh commands |
Write for partner developers, in the terms of GLOSSARY.md. The doc tests
are plain go test:
console block preceded by <!-- doctest: <name> --> is
run by internal/commands/docs_test.go against the fake transport: each
$ line runs, and what it prints, stderr and stdout interleaved as on a
terminal, must equal the lines after it. The fake API behind each session
is in docs_sessions_test.go, keyed by the name. Sessions support tmh,
export, echo $?, cat <file>, > file and printf %s "$VAR" |. A
command that fails must be followed by echo $?, so a failure never reads
as success.console, sh or bash block must
be marked <!-- doctest: illustrative -->, for examples that can’t run
deterministically, such as tmh login prompting or anything piped to
jq. Their tmh commands, and those in examples/*.sh, are still parsed
against the real command tree, so a renamed command, flag or argument
fails the test.text block marked <!-- doctest: synopsis --> holds one
tmh … usage line per line. Each line’s command must exist, and each
--flag or -f on it must be a flag of that command.jq program in the illustrative blocks, the example
scripts and the code samples must compile with the jq on PATH (the
test skips without one).code_samples_test.go holds code-samples.json to the
IR: one sample per operationId, the release in OPENAPI_VERSION, and each
sample calling its operation’s command once, with real flags and every
required body field set by a flag, -d or --data. The sample values
and the optional flag each sample shows live in internal/gen/samples.go.internal/doctest checks that every relative link and #anchor
in every Markdown file resolves, with GitHub’s heading anchors.The documentation site is GitHub’s own Pages build of Jekyll
(actions/jekyll-build-pages) over the Markdown, so the site renders it as
github.com does and needs no generator of ours. scripts/stage-pages.sh
_pages copies the published files into _pages/ with front matter and
.github/pages/_config.yml; the README becomes the home page and links
between .md files become links between pages. The pages are wrapped in
Liquid raw blocks, so {{ }} in examples prints as written. To preview the
site, run the action’s image:
scripts/stage-pages.sh _pages
docker run --rm -v "$PWD":/github/workspace -e GITHUB_WORKSPACE=/github/workspace \
-e INPUT_SOURCE=_pages -e INPUT_DESTINATION=_site -e INPUT_TOKEN="$(gh auth token)" \
-e GITHUB_REPOSITORY=TeachMeHIPAA/teachmehipaa-cli ghcr.io/actions/jekyll-build-pages:v1.0.13
.github/workflows/docs.yml checks the references and the doc tests and
builds the site on every pull request, and on main deploys it to GitHub
Pages with actions/deploy-pages. Pages must be enabled once in the
repository settings (Settings → Pages → Source: GitHub Actions) before the
first deploy succeeds; until then the deploy job fails, and
https://teachmehipaa.github.io/teachmehipaa-cli/ 404s. With a custom
domain, change url and baseurl in .github/pages/_config.yml.
Use Conventional Commits (feat:,
fix:, docs:, chore:…). GitHub release notes are generated from them:
feat and fix commits get their own sections, ! marks a breaking change,
and docs, test, chore and ci commits are left out. Add user-facing
changes to CHANGELOG.md under [Unreleased] too.
Releases are built by GoReleaser from .goreleaser.yaml and run only from the
Release workflow, which is workflow_dispatch only. By default it builds a
snapshot of every artifact and uploads it to the workflow run, publishing
nothing. Run the same build locally with:
make snapshot # goreleaser release --snapshot --clean
./dist/tmh_darwin_arm64*/tmh version
Without Docker, skip the image with
goreleaser release --snapshot --clean --skip=docker.
Nothing has been published. These steps must happen first:
go install and the
deb and rpm links all download release assets anonymously.main
branch:
TeachMeHIPAA/homebrew-tap: the cask is written to Casks/tmh.rb.TeachMeHIPAA/scoop-bucket: the manifest is written to
bucket/tmh.json.Contents: read and write on those two
repos only.release environment in this repo’s settings, with you as a
required reviewer and deployments limited to tags matching v*. Add the
token there as the secret TAP_GITHUB_TOKEN. (A run creates the
environment without protection if it doesn’t exist, so create it first.)tmh package on GitHub (Packages), link
it to this repo, and make it public; new GHCR packages start private.Without TAP_GITHUB_TOKEN, GoReleaser skips the tap and bucket, and the
publish job refuses to run.
[Unreleased] notes in CHANGELOG.md under the new version and
date, and commit that on main.Tag the commit and push the tag:
git tag -a v1.0.0 -m "tmh 1.0.0"
git push origin v1.0.0
tmh-snapshot artifact and
check an archive, the cask and the Scoop manifest.release environment. The job fails unless the ref is a
v* tag. It publishes the GitHub release with archives, packages and
checksums.txt; pushes ghcr.io/teachmehipaa/tmh:<version> and :latest
for amd64 and arm64; updates the tap and bucket; and signs
checksums.txt with keyless Sigstore. A tag with a prerelease suffix,
such as v1.1.0-rc.1, is marked a prerelease, skips the tap and bucket,
and doesn’t move latest.brew install --cask teachmehipaa/tap/tmh,
docker run --rm ghcr.io/teachmehipaa/tmh version, and the cosign
verify-blob command from the README.notarize.macos).