一键导入
bash-expert
Write reliable shell commands and scripts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write reliable shell commands and scripts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | bash-expert |
| description | Write reliable shell commands and scripts |
Follow these steps when writing or executing shell commands:
Always use set -e at the top of multi-line scripts so the script exits on the first error rather than silently continuing.
Quote all variables with double quotes: "$var" not $var. Unquoted variables break on spaces and special characters.
Capture stderr alongside stdout when you need full output: use command 2>&1 or check both streams separately.
Check exit codes explicitly for commands where failure matters but doesn't abort the script:
if ! command; then
echo "command failed" >&2
exit 1
fi
Use mktemp for temporary files rather than hard-coded paths like /tmp/foo. This avoids collisions between concurrent runs.
Prefer find . -name '*.ts' -print0 | xargs -0 over for f in $(find ...) when filenames may contain spaces.
Use || true to suppress errors for optional commands (e.g. rm -f file || true).
Limit output when running commands that may produce large output: pipe through head -n 100 or slice with tail -n 50.
Explain what a command does in a comment above it when it is non-obvious — especially for pipes and compound expressions.
Test destructive commands (rm, overwrite) with echo or --dry-run first if supported by the tool.