hack.foo
Guides

Choose command context

These examples use the Compose runtime in v4.2.4. Verify hack version before using the archived command reference.

Use exec when the target service is already running. Use run for a one-off command in a fresh service container. Use host exec for a command that must run on the current host with resolved project environment.

hack exec web -- node --version
hack run web node --version
hack host exec --scope web -- node --version

Replace web and the command with your project's actual service and tool. These examples report the installed Node version in three different execution contexts; they do not install Node. The host path needs Node on the host. Inspect service prerequisites and the matching reference before running migrations or other data-changing commands.

An agent uses the same execution model. Ask it to read project instructions, select the intended host and instance, and inspect state before starting new work.


Source: v4.2.4 · docs/site/guides/run-commands.md.