Skip to content

Hooks

Customize any mine command by dropping a script into ~/.config/mine/hooks/. No plugin system needed — just an executable file with the right name and mine picks it up automatically.

  • Zero config — drop a script into ~/.config/mine/hooks/ and it’s active immediately
  • Four hook stages — prevalidate, preexec, postexec, and notify
  • Wildcard patternstodo.* matches all todo subcommands, * matches everything
  • Any language — bash, python, ruby, Go binaries, anything executable
  • Transform or notify — modify command context or fire-and-forget side effects
Terminal window
# Create a hook that runs before adding todos
mine hook create todo.add preexec
# List all active hooks
mine hook list
# Test a hook with sample input
mine hook test ~/.config/mine/hooks/todo.add.preexec.sh

Scripts follow a naming convention parsed right-to-left: <command-pattern>.<stage>.<ext>

~/.config/mine/hooks/
├── todo.add.preexec.sh # Runs before todo add
├── todo.done.notify.py # Notified after todo done
├── todo.*.postexec.sh # Runs after any todo subcommand
└── *.notify.sh # Notified on every command

The command pattern uses dot-separated segments. Wildcard * matches any characters (Go filepath.Match rules) — a bare * matches all commands. Scripts must be executable (chmod +x).

Every mine command passes through four hook stages:

StageModeWhen it runs
prevalidatetransformBefore input validation
preexectransformBefore the command executes
postexectransformAfter the command executes
notifynotifyFire-and-forget, after everything else

Transform hooks (prevalidate, preexec, postexec) receive JSON on stdin and return modified JSON on stdout. They chain in alphabetical order — each hook’s output becomes the next hook’s input. Use these when you need to modify the command’s arguments, flags, or results.

Notify hooks receive JSON on stdin but their output is ignored. They run in the background and never block the command. Use these for side effects like logging, syncing to external services, or sending notifications.

  • Transform hooks: 5 seconds (blocks the command pipeline)
  • Notify hooks: 30 seconds (runs in background)

If a hook exceeds its timeout, mine kills the process and reports an error.

CommandDescription
mine hook listList all discovered hooks
mine hook create <pattern> <stage>Scaffold a starter hook script
mine hook test <path>Dry-run a hook with sample input

See the hook command reference for the full JSON protocol, all subcommands, and detailed examples.