| name | missing-command-nix |
| description | Enforce a Nix-based fallback workflow when shell commands are missing. Use whenever an agent tries to run a command that is unavailable in the current workspace, especially before installing tools or changing the host environment. |
Missing Command Nix
Workflow
When a command is missing, do not install it globally.
- Check whether the current project directory contains
devenv.nix or flake.nix.
- If either file exists, use the project's Nix environment to run the command.
- If neither file exists, use
nix-shell to run the command with the needed package.
- Keep the command scoped to the task and avoid mutating global package state.
Project Nix Files
Detect project Nix files from the workspace root or the directory where the command is being run:
test -f devenv.nix || test -f flake.nix
If flake.nix exists, prefer:
nix develop -c <command> <args>
If devenv.nix exists and devenv is available inside the project workflow, prefer the repository's existing devenv command pattern.
No Project Nix Files
If both devenv.nix and flake.nix are absent, run the missing command through nix-shell:
nix-shell -p <package> --run '<command> <args>'
Use the package name that provides the missing command. If unsure, inspect local project docs first, then choose the narrowest plausible package.
Examples
nix-shell -p jq --run 'jq --version'
nix-shell -p ripgrep --run 'rg pattern .'