Documentation Index
Fetch the complete documentation index at: https://mux-goals-8h36.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Tool hooks are experimental. Expect breaking changes while we iterate.
What do you want to do?
Block dangerous commands
Prevent force pushes, rm -rf, etc.
Lint after file edits
Run ruff, eslint, tsc after changes
Set up environment
direnv, nvm, virtualenv
Block dangerous commands
Create.mux/tool_pre to validate commands before they run. Exit non-zero to block:
Lint after file edits
Create.mux/tool_post to run validation after tools complete:
hook_output and the agent can fix them.
hook_output is only shown in the UI when the hook produces output. For a cleaner experience,
only print output when the hook has an effect—e.g., skip “Formatted: file” messages if the file
was already formatted.Set up environment
Create.mux/tool_env to configure your shell environment. This file is sourced before every bash tool call:
Unlike hooks,
tool_env doesn’t need to be executable—it’s sourced, not run. It only affects
bash tools.Reference
Environment Variables
Environment Variables
All hooks receive these environment variables:
Mux flattens the tool input into
Flattened result fields are available as
| Variable | Description |
|---|---|
MUX_TOOL | Tool name: bash, file_edit_replace_string, file_read, etc. |
MUX_WORKSPACE_ID | Current workspace identifier |
MUX_TOOL_INPUT_PATH | Path to file containing full tool input (always set) |
MUX_TOOL_INPUT_<...> environment variables (see the appendix below). Fields longer than 8KB are omitted—use MUX_TOOL_INPUT_PATH for full access.Post-hook only (tool_post):| Variable | Description |
|---|---|
MUX_TOOL_RESULT_PATH | Path to file containing full tool result |
MUX_TOOL_RESULT_<...>. Fields longer than 8KB are omitted—use MUX_TOOL_RESULT_PATH for full access.Exit Codes
Exit Codes
| Exit Code | tool_pre behavior | tool_post behavior |
|---|---|---|
0 | Tool executes normally | Success, output shown to agent |
| Non-zero | Tool blocked, error shown to agent | Failure, error shown in hook_output |
Hook Priority & Location
Hook Priority & Location
Mux searches for each hook file in this order:
- Project-level:
.mux/<hook> - User-level:
~/.mux/<hook>
tool_pre, tool_post, and tool_env.For SSH workspaces, hooks execute on the remote machine.Timeouts
Timeouts
Hooks must complete within 10 seconds or they’re terminated. Long-running tools (builds, tests) don’t count against this—only hook execution time.Keep hooks fast—if you need longer operations, consider running them asynchronously or in the background.
Comparison
Comparison
| Feature | .mux/tool_pre | .mux/tool_post | .mux/tool_env |
|---|---|---|---|
| Purpose | Block dangerous commands | Lint/validate results | Environment setup |
| Runs | Before tool | After tool | Sourced in bash shell |
| Applies to | All tools | All tools | bash tool only |
| Use case | Block force-push | Run ruff/eslint | direnv, nvm, virtualenv |
Appendix: Tool input env vars (auto-generated)
Appendix: Tool input env vars (auto-generated)
Mux also provides flattened tool input env vars so hook scripts can stay compact.
- Scalars become
MUX_TOOL_INPUT_<FIELD> - Nested objects become
MUX_TOOL_INPUT_<PARENT>_<CHILD> - Arrays also include
..._COUNTand per-index variables like..._<INDEX>
More examples
Format files after edits
Format files after edits
Log tool execution times
Log tool execution times
Python hook
Python hook