一键导入
bash-scripting
Use when creating or modifying bash shell scripts, needing script templates, error handling patterns, or shell scripting best practices.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when creating or modifying bash shell scripts, needing script templates, error handling patterns, or shell scripting best practices.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when creating Justfiles, needing modern command runners, or implementing just command runner patterns for task automation.
Use when you need detailed kitty terminal API reference, remote control commands, window management, or advanced kitty integration patterns.
Use when creating Makefiles, needing build automation, defining make targets, or implementing standard makefile patterns and recipes.
Comprehensive guide for Python type annotations, type checking, and modern typing patterns. Use when: (1) Adding type hints to Python code, (2) Configuring mypy/pyright/ty type checkers, (3) Understanding generics, protocols, and advanced type patterns, (4) Migrating to modern Python typing, (5) Setting up strict type checking in CI/CD, (6) Building type-safe APIs and libraries. Covers Python 3.10+ modern syntax, type narrowing, structural typing, and best practices.
Use when you need to explore, search, or understand codebases using structural AST patterns. Ideal for finding specific code patterns, understanding code architecture, discovering API usage, or locating code smells across multiple files.
Use when you need to perform code refactoring, semantic transformations, or structural rewrites across multiple files. Ideal for API migrations, code modernization, breaking change adoption, or systematic code transformations.
| name | bash-scripting |
| description | Use when creating or modifying bash shell scripts, needing script templates, error handling patterns, or shell scripting best practices. |
Comprehensive guide for writing robust, maintainable bash scripts.
Bash is the standard shell on most Linux and macOS systems. This skill provides templates, patterns, and best practices for creating production-ready shell scripts.
#!/bin/bash
set -euo pipefail
main() {
echo "Hello, World!"
}
main "$@"
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Configuration
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_NAME="$(basename "$0")"
# Error handling
trap 'echo "Error on line $LINENO" >&2; exit 1' ERR
trap 'echo "Interrupted" >&2; exit 130' INT
# Usage information
usage() {
cat << EOF
Usage: ${SCRIPT_NAME} [OPTIONS] [ARGUMENTS]
Options:
-h, --help Show this help message
-v, --verbose Enable verbose output
-d, --dry-run Show what would be done without executing
Examples:
${SCRIPT_NAME} --verbose
${SCRIPT_NAME} --dry-run
EOF
}
# Parse arguments
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
exit 0
;;
-v|--verbose)
VERBOSE=1
shift
;;
-d|--dry-run)
DRY_RUN=1
shift
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
}
# Logging functions
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
log_verbose() {
[[ ${VERBOSE:-0} -eq 1 ]] && log "$@"
}
log_error() {
log "ERROR: $*" >&2
}
# Main logic
main() {
parse_args "$@"
log_verbose "Starting script..."
# Your logic here
log "Script completed successfully"
}
main "$@"
set -e # Exit on error
set -u # Error on undefined variables
set -o pipefail # Catch errors in pipelines
set -euo pipefail # All three combined
# Catch errors
trap 'echo "Error on line $LINENO" >&2' ERR
# Cleanup on exit
trap 'rm -rf "$TEMP_DIR"' EXIT
# Handle signals
trap 'echo "Interrupted"; exit 130' INT TERM
# CORRECT - Always quote variables
file="${1:-default.txt}"
cat "${file}"
# WRONG - Unquoted variables break on spaces
cat ${file} # Fails if file="my file.txt"
name="${1:-default}" # Use default if unset/null
name="${1:?required}" # Error if unset/null
name="${1:=default}" # Assign default if unset
readonly name="${1}" # Make read-only
if command -v git >/dev/null 2>&1; then
echo "Git is installed"
fi
if [[ -f "$file" ]]; then
echo "File exists"
fi
if [[ -d "$dir" ]]; then
echo "Directory exists"
fi
for file in *.txt; do
[[ -f "$file" ]] || continue # Skip if no match
process "$file"
done
while IFS= read -r line; do
echo "$line"
done < "file.txt"
while getopts "hvd:" opt; do
case $opt in
h) usage; exit 0 ;;
v) VERBOSE=1 ;;
d) DIR="$OPTARG" ;;
?) usage >&2; exit 1 ;;
esac
done
shift $((OPTIND-1))
run() {
if [[ ${DRY_RUN:-0} -eq 1 ]]; then
echo "[DRY RUN] Would execute: $*"
else
"$@"
fi
}
run rm -rf "${dir}"
confirm() {
read -r -p "Are you sure? [y/N] " response
[[ "$response" =~ ^[Yy]$ ]]
}
if confirm; then
rm -rf "$dir"
fi
TEMP_DIR=$(mktemp -d)
trap 'rm -rf "$TEMP_DIR"' EXIT
[[ ${VERBOSE:-0} -eq 1 ]] && set -x # Trace execution
debug() {
[[ ${DEBUG:-0} -eq 1 ]] && echo "DEBUG: $*" >&2
}
#!/bin/bash
set -euo pipefail
SOURCE="${1:-.}"
DEST="${2:-backup}"
timestamp=$(date +%Y%m%d_%H%M%S)
mkdir -p "$DEST"
tar -czf "${DEST}/backup_${timestamp}.tar.gz" "$SOURCE"
echo "Backup created: ${DEST}/backup_${timestamp}.tar.gz"
#!/bin/bash
set -euo pipefail
process_file() {
local file="$1"
# Process logic here
echo "Processed: $file"
}
export -f process_file
find . -name "*.txt" -print0 | xargs -0 -P4 -I{} bash -c 'process_file "$@"' _ {}