Shell scripts are a powerful way to automate tasks. But they can be dangerous if not written carefully. This guide provides 49 best practices to make your scripts safe, portable, and maintainable.
Whether you are writing bash or POSIX shell scripts, these rules help you avoid common mistakes. They cover everything from command injection prevention to error handling and portability.
Each rule comes with clear examples of what to do and what not to do. Use this guide when writing, reviewing, or fixing shell scripts for any system.
Global
mkdir -p ~/.claude/skills/shellProject
mkdir -p .claude/skills/shellSource Repository
Lark Sharedlarksuite/cli
Manage Feishu resources from terminal with user and bot authentication and permission handling
Runcomfy Cliagentspace-so/runcomfy-agent-skills
One binary one login runs hundreds of AI models from your command line
Tzstxixu-me/skills
Create extract and manage tzst archives with safe defaults and scripting support
Xdropxixu-me/skills
Upload and download files securely from your terminal with Xdrop CLI
Runcomfy Clidoany-ai/skills
One binary, one auth, hundreds of AI models from your terminal
Runcomfy Cliruncomfy-com/skills
Control hundreds of AI models from your command line with one simple tool
Hyperframes Cliheygen-com/hyperframes
Scaffold, lint, inspect, preview, and render video compositions from your terminal
Sentry Clisentry/dev
Manage your Sentry projects and issues directly from the terminal