Revision: 1 Last modified: 2026-12-04T17:48:16Z
Resolves the project's release/tag prefix — the <PREFIX> in <PREFIX>-<version> (§11.4.151).
It is the single source of truth for that naming. Every release-tag-creating or version-naming script, in the main repo and in every owned submodule, is required to obtain its prefix from here so that one release shares one prefix and is greppable across every repo:
git tag -l "$(scripts/release_prefix.sh)-*"Run it (or source it) when: you are about to name a tag or a version and need the prefix without hardcoding it.
bash,git(optional — used to find the project root; a no-git fallback exists).- Nothing else. No permissions, no network, no writes.
| # | Source | Notes |
|---|---|---|
| 1 | HELIX_RELEASE_PREFIX in the environment |
Authoritative when set |
| 2 | HELIX_RELEASE_PREFIX in the git-ignored project-root .env |
Parsed, never sourced — a hostile .env cannot execute code (§11.4.10). Quotes are stripped; whitespace trimmed |
| 3 | Fallback: lowercased snake_case of the project-root directory name (§11.4.29) | Always resolvable from the checkout, no operator input |
Env vars (NAMES only): HELIX_RELEASE_PREFIX, HELIX_PROJECT_ROOT.
HELIX_PROJECT_ROOT is an explicit override for a layout the automatic resolution cannot handle. It wins over every
tier only when it names an existing, readable and searchable (-x) directory. An invalid value prints a
warning and falls through — it is not silently ignored (§11.4.6).
# As a command
prefix="$(bash scripts/release_prefix.sh)"
# Sourced (no subprocess; useful in loops)
. scripts/release_prefix.sh
prefix="$(helix_release_prefix)"
# In a tag name
git tag -a "$(bash scripts/release_prefix.sh)-1.0.0" -m "Release 1.0.0"
# List this project's tags
git tag -l "$(bash scripts/release_prefix.sh)-*"
# Explicit override for an unusual layout
HELIX_PROJECT_ROOT=/srv/checkouts/thing bash scripts/release_prefix.shReal output from this checkout on 2026-12-04 (a worktree whose directory name is a session id, so tier 3 fired):
$ bash scripts/release_prefix.sh
pi_agent_2f2d6f42_3ec9_435_5164e256
$ echo $?
0
That is tier 3 in action — the directory name slugged to snake_case. In a normal project (~/Projects/thing) the
same command prints thing, and with HELIX_RELEASE_PREFIX=atmosphere in the environment it prints atmosphere.
| Code | Meaning |
|---|---|
0 |
Prefix printed on stdout (never empty) |
1 |
Genuinely unresolvable root — release_prefix: cannot resolve a prefix (no HELIX_RELEASE_PREFIX, no .env value, empty root name) on stderr |
Non-zero happens only for a genuinely unresolvable root: a directed error, never a guess (§11.4.6).
-
Sourcing vs running. The last line checks
[ "${BASH_SOURCE[0]:-$0}" = "${0}" ]; when sourced it defineshelix_release_prefixand prints nothing. Sourcing a command substitution to get a subprocess is a common mistake — pick one. -
Project-root resolution is anchored to this file's own location, never the caller's cwd. This is a fixed defect, and the reason matters:
- the old primary mechanism ran
git rev-parse --show-toplevelin the caller's cwd. Inside a nestedconstitution/submodule (which has its own.git) that returns the submodule's toplevel, so the project's.envis never found and the prefix silently degrades to the directory name; - from a directory with no git repo at all, the old fallback was one level short.
Both produced the wrong prefix depending purely on where the caller happened to run — which a downstream consumer read through to a correctly-tagged dispatch being wrongly refused.
- the old primary mechanism ran
-
Two layouts are both supported and had to be reconciled:
- EMBEDDED —
constitution/is a nested git submodule of a consuming project:git -C "$self_dir" rev-parse --show-superproject-working-treereturns the consuming project's root. - STANDALONE —
constitution/is cloned as its own top-level repo:--show-toplevelcorrectly returns that repo's own root, so.env.example's documentedhelix_constitutionfallback holds. A fixed "two levels up" would have landed above a standalone clone and picked up the containing directory's name.
- EMBEDDED —
-
Unregistered nested
constitution/. Aconstitution/with its own.gitbut no formal gitlink registration would otherwise be treated as standalone. The script widens to the parent only whenbasename "$root"is literallyconstitutionand the parent carries real evidence: a.envthat genuinely contains aHELIX_RELEASE_PREFIX=assignment (verified through the same parser tier 2 uses — file existence alone is not enough), or a.gitmodulesline exactlypath = constitution. -
An unreadable or content-irrelevant parent
.envdoes not widen. A parent with onlyAPI_KEY=xdoes not widen. Achmod 000.envdoes not widen. A clone namedHelixConstitutionunder an unrelatedworkspace/does not widen. -
HELIX_PROJECT_ROOTset to a readable-but-not-searchable directory (chmod 444) warns and falls through, rather than passing validation and then failing oncdwith empty stdout. -
Snake_case fallback examples:
HelixConstitution→helix_constitution;My App→my_app;pi_agent_2f2d6f42_…→ unchanged (already snake_case).
helix_release_prefixchecks tier 1 (HELIX_RELEASE_PREFIXin the environment) and returns it.- Otherwise
_hrp_project_rootresolves the root, in this order:HELIX_PROJECT_ROOT(validated-d/-r/-x, warned and skipped when invalid) →git -C "$self_dir" rev-parse --show-superproject-working-tree(embedded layout) →git -C "$self_dir" rev-parse --show-toplevel(standalone, with the gated widen-to-parent heuristic) →$self_dir/..(not inside any git repository at all: an unpacked tarball, a bare file copy). - Tier 2:
_hrp_from_env_file "$root/.env"— greps the lastHELIX_RELEASE_PREFIXassignment (ignoring comments), trims whitespace, strips a matching pair of quotes. Never sources it. - Tier 3:
_hrp_snake_case "$(basename "$root")"— camelCase→snake, non-alnum→_, lowercase, squeeze/trim. - An empty result is an error (exit
1) with a message naming all three missing sources.
scripts/release_tag.sh— the primary consumer; builds<PREFIX>-<version>from this.docs/scripts/release_tag.md.scripts/release.sh/scripts/release/release_all.sh— the release pipeline, which also names versions.scripts/update_constitution.sh— reads remotehelixconstitution-v*release tags.constitution/.env.example— documents theHELIX_RELEASE_PREFIXvariable and the standalone fallback.scripts/lib/constitution_layout.sh— layout resolution used by the update/install scripts.- §11.4.151 (project-prefixed naming), §11.4.29 (snake_case), §11.4.6 (no guessing), §11.4.10 (never source
.env).
2026-12-04 — bash -n clean, and the read-only command executed for real (it writes nothing):
$ bash -n scripts/release_prefix.sh && echo PARSE-OK
PARSE-OK
$ bash scripts/release_prefix.sh; echo "RC=$?"
pi_agent_2f2d6f42_3ec9_435_5164e256
RC=0The printed value is tier 3 applied to this worktree's directory name. To see tier 1 instead:
$ HELIX_RELEASE_PREFIX=demo bash scripts/release_prefix.sh
demo