--- trigger: model_decision description: When executing external commands, shell scripts, or system processes --- ## Command Execution Principles ### Security **Never execute user input directly:** - ❌ `exec(userInput)` - ❌ `shell("rm " + userFile)` - ✅ Use argument lists, not shell string concatenation - ✅ Validate and sanitize all arguments **Run with minimum permissions:** - Never run commands as root/admin without explicit human approval. If elevated permissions are absolutely required, STOP and request authorization. - Use least-privilege service accounts ### Portability **Use language standard library:** - Avoid shell commands when standard library provides functionality - Example: Use file I/O APIs instead of `cat`, `cp`, `mv` **Test on all target OS:** - Windows, Linux, macOS have different commands and behaviors - Use path joining functions (don't concatenate with /) ### Error Handling **Check exit codes:** - Non-zero exit code = failure - Capture and log stderr - Set timeouts for long-running commands - Handle "command not found" gracefully ### Non-Interactive Command Execution (MANDATORY) **All shell commands MUST run without interactive prompts.** AI agents cannot respond to prompts — a stuck prompt kills the entire workflow. **Required Flags:** | Tool | Non-Interactive Pattern | |---|---| | `npx` | Always `npx -y ` | | `npm install` | `CI=true npm install` or `CI=true npm ci` | | `npm create` / `npm init` | Pass `--` + all template/option flags | | Scaffolding (`create-vite`, etc.) | Run `--help` first, then pass all options as CLI flags | | `pnpm` | `pnpm install --no-frozen-lockfile` | | `yarn` | `yarn install --no-immutable` | **Rules:** 1. **Set `CI=true`** environment variable for all npm/yarn/pnpm commands 2. **Never run bare scaffolding commands** — always specify template and options as flags 3. **Run `--help` first** on any unfamiliar scaffolding tool to discover non-interactive flags 4. **Last resort**: pipe `yes |` if no non-interactive flag exists Running an interactive command that blocks the agent is a **critical failure**.