Specialist skill for writing Bash shell scripts. Applies best practices and error handling patterns. Use when writing new bash scripts (.sh/.bash), improving or reviewing existing scripts, adding error handling, or editing files in the scripts/ folder.
Ships in shell-script. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
[!NOTE] Original: https://sharats.me/posts/shell-script-best-practices/
This article is about a few quick thumb rules I use when writing shell scripts that I've come to appreciate over the years. Very opinionated.
bash. Using zsh or fish or any other, will make it hard for others to understand / collaborate. Among all shells, bash strikes a good balance between portability and DX.#!/usr/bin/env bash, even if you don't give executable permission to the script file..sh (or .bash) extension for your file. It may be fancy to not have an extension for your script, but unless your case explicitly depends on it, you're probably just trying to do clever stuff. Clever stuff are hard to understand.set -o errexit at the start of your script.
bash exits instead of continuing with the rest of the script.set -o nounset. You may have a good excuse to not do this, but, my opinion, it's best to always set it.
"${VARNAME-}" instead of "$VARNAME", and you're good.set -o pipefail. Again, you may have good reasons to not do this, but I'd recommend to always set it.
set -o xtrace, with a check on $TRACE env variable.
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi.TRACE=1 ./script.sh instead of ./script.sh.[[ ]] for conditions in if / while statements, instead of [ ] or test.
[[ ]] is a bash [ ] or test.[[ ]] condition. But even there I'd recommend quoting.bash arrays will likely serve you much better.local variables in functions.-h or --help or help or just h or even -help, and in all these cases, print help text and exit.echo 'Something unexpected happened' >&2 for this.--silent instead of -s). These serve to document your commands explicitly.
cd "$(dirname "$0")", which works in most cases.shellcheck. Heed its warnings.#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
echo 'Usage: ./script.sh arg-one arg-two
This is an awesome bash script to make your life better.
'
exit
fi
cd "$(dirname "$0")"
main() {
echo do awesome stuff
}
main "$@"
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/shell-script:shell-scriptfrom shell-script
npx claudepluginhub rishubil/skills --plugin shell-script