Hooks are executable shell scripts that perform the actual work of deploying, health-checking, rolling back, streaming logs, and cleaning up services.
All hooks are generated by muster setup from stack-specific templates. You can edit them freely after setup.
| Name | Description |
|---|---|
deploy.sh | hookBuild and deploy the service. Called by muster deploy. |
health.sh | hookVerify the service is healthy. Called by muster deploy, muster status, and muster dev. |
rollback.sh | hookRevert to the previous version. Called by muster rollback and deploy failure recovery. |
logs.sh | hookStream or tail service logs. Called by muster logs <service>. |
cleanup.sh | hookStop processes, remove containers. Called by muster cleanup and muster dev (Ctrl+C). |
Hooks can also be defined as recipes in a justfile with matching recipe names (deploy, health, rollback, logs, cleanup). Supported for both local and remote execution.
Muster injects environment variables into every hook execution. The variables available depend on the service configuration and project context.
| Name | Description |
|---|---|
MUSTER_SERVICE_NAME | stringDisplay name of the service. |
MUSTER_DEPLOY_STATUS | stringDeploy outcome: success, failed, or skipped. Available in post-deploy hooks only. |
MUSTER_DEPLOY_TIMEOUT | numberTimeout in seconds for the deploy operation. Default: 120 |
MUSTER_DEPLOY_MODE | stringPer-service deploy mode, if configured in muster.json. |
MUSTER_PROJECT_DIR | stringAbsolute path to the project root. |
MUSTER_CONFIG_FILE | stringPath to the muster.json configuration file. |
Available when a service has Kubernetes configuration in muster.json.
| Name | Description |
|---|---|
MUSTER_K8S_DEPLOYMENT | stringKubernetes deployment name (e.g. myapp-api). |
MUSTER_K8S_NAMESPACE | stringKubernetes namespace (e.g. production). |
MUSTER_K8S_SERVICE | stringService key with underscores converted to hyphens (e.g. api-v1). |
When credentials.enabled is true in your service configuration, muster exposes one variable per entry in credentials.required[], uppercased and prefixed:
MUSTER_CRED_<KEY> # one per entry in credentials.required[], uppercasedCredential modes control how values are persisted:
Available when the project is inside a git repository.
| Name | Description |
|---|---|
MUSTER_GIT_COMMIT | stringCurrent HEAD SHA. |
MUSTER_GIT_PREV_COMMIT | stringSHA of the last successful deploy. |
MUSTER_GIT_COMMIT_COUNT | numberNumber of commits between the previous deploy and the current HEAD. |
MUSTER_GIT_DIFF_SUMMARY | stringShort diff stat summarizing changes since the last deploy. |
If a .env file exists in the project root, muster automatically loads it before running deploy, rollback, and dev hooks. Variables are exported without overriding existing environment variables.
When you run muster setup, hooks are generated from templates tailored to each stack type. Infrastructure services get specialized pull-only templates that skip docker build and use pull/restart instead.
| Name | Description |
|---|---|
k8s | stackKubernetes: kubectl apply, kubectl rollout, image tagging. |
compose | stackDocker Compose: docker compose up, docker compose pull. |
docker | stackPlain Docker: docker build, docker run. |
bare | stackGeneric shell commands, systemd restart. No container runtime required. |
dev | stackPID-managed background processes for local development. |
just | stackJustfile recipe-based hooks. Muster calls just deploy, just health, etc. |
Muster includes two layers of protection to prevent hooks from executing dangerous or tampered commands.
Before running deploy hooks, muster scans for dangerous patterns. If any are detected, the deploy is blocked.
Blocked patterns:
rm -rf /
mkfs
dd if=
curl | bash
wget | sh
chmod 777
nc -l / ncat -lWhen muster setup generates hooks, it also creates a signed manifest at .muster/hooks/hooks.manifest. This manifest contains SHA-256 hashes of all hook files, HMAC-signed with a machine-local key stored at ~/.muster/.hook_signing_key.
Before each deploy, muster verifies the manifest signature and compares file hashes. If verification fails — because a hook was modified outside of normal editing or the manifest was tampered with — the deploy is blocked.
muster hooks approve to re-sign the manifest with the new file hashes.