shell-scripting
Best practices for writing shell scripts. Use when writing bash, sh, zsh, or other shell code for automation, scripting, or command-line tasks.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Shell Scripting
Best Practices
Favor Long Options
When writing shell scripts, prefer long options (e.g., --verbose) over short options (e.g., -v) for improved readability and maintainability.
Why long options?
-
Self-documenting:
grep --ignore-caseis clearer thangrep -i - Easier maintenance: Future readers understand intent without checking man pages
- Reduced errors: Less likely to misinterpret what a short flag does
Example:
# Good: Clear and self-documenting
find /var/log --name "*.log" --type f --mtime +30 --delete
# Avoid: Requires knowledge of what each flag means
find /var/log -name "*.log" -type f -mtime +30 -delete
Exception: Short options are acceptable for:
- Extremely common commands where the short form is universally understood (e.g.,
ls -la) - Interactive terminal usage where brevity matters
- Commands without long option equivalents
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!