用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill shell-script-generator命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | shell-script-generator |
| description | Generate clean shell scripts following best practices. Use when this capability is needed. |
| metadata | {"author":"garnertb"} |
Generate shell scripts following best practices.
#!/bin/bash)[[ "$TRACE" ]] && set -xsource all dependencies before setting the -e or +e flags.#/ comment prefix:
#!/bin/bash
#/ Usage: my-script [options] <required_arg>
#/
#/ Brief description of the script's purpose.
#/
#/ OPTIONS:
#/ -h | --help Show this message.
#/ -o <arg> An option.
-h and --help arguments, print usage, and exit:
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
grep '^#/' <"$0" | cut -c 4-
exit 2
fi
set -eo pipefail (or set -o errexit) to cause the script to
exit when a command fails.
|| true on programs that you intentionally let exit non-zero.|| true is not a good practice,
though it can be used in test scripts, if necessary.set -o errexit -o nounset -o pipefail
nounset does require some extra code to either explicitly define
variables (e.g. FOO=) or provide a default value, which may be blank:
(e.g. ${FOO:-}).$?.$ signs.${var} for interpolation only when required (e.g., ${greeting}world).&& and ||.then, do, etc on same line, not newline.[[ ... ]] in your if-expression if you can test for exit code instead.test or [ for portable conditionals; use [[ for advanced Bash
features like glob matching.# Test for exit code (-q mutes output)
if grep -q 'foo' somefile; then ...; fi
# Test for output (-m1 limits to one result)
if [[ "$(grep -m1 'foo' somefile)" ]]; then ...; fi
$[x+y] or $((x+y)) for mathematical expressions.for loops with seq or C-style syntax:
for i in $(seq 0 9); do ...; done
for ((n=0; n<10; n++)); do ...; done
printf, it's more powerful than echo.<<heredocs for multi-line strings:
<<eof allows interpolation; <<'eof' or <<"eof" disables it.<<-eof strips leading tabs for better indentation.1 (stdout) and 2 (stderr) are standard; others (3+) are
free but shared by subprocesses—coordinate usage to avoid conflicts.sed, perl, etc in a standalone function with a
descriptive name.declare desc="description" at the top of functions, even above
argument declaration.eval $(type FUNCTION_NAME | grep 'declare desc=') && echo "$desc"
regular_func() {
declare arg1="$1" arg2="$2" arg3="$3"
# ...
}
variadic_func() {
local arg1="$1"; shift
local arg2="$1"; shift
local rest="$@"
# ...
}
.sh or .bash extension if file is meant to be included/sourced. Never
on executable script.Converted and distributed by TomeVault — claim your Tome and manage your conversions.