Shell scripts that are longer than a configurable threshold (default: 10 non-empty lines) should include comments explaining their purpose, approach, and any non-obvious logic. This rule counts non-empty lines and comment lines (lines starting with #). If the script exceeds the threshold but has at most one comment line (typically just the shebang), the rule reports a warning. Comments improve maintainability and help other developers (and AI models) understand the script without executing it.
#!/bin/bash# Deploy script: builds, tests, and deploys the applicationnpm installnpm run buildnpm run test# Copy artifacts and restart the servicecp dist/* /var/www/systemctl restart app# Verify the deploymentcurl -s http://localhost/health
Add comments to the script explaining what it does, why certain steps are needed, and any non-obvious logic. At minimum, add a header comment describing the script purpose.
skill-missing-comments
Shell script lacks explanatory comments
Rule Details
Shell scripts that are longer than a configurable threshold (default: 10 non-empty lines) should include comments explaining their purpose, approach, and any non-obvious logic. This rule counts non-empty lines and comment lines (lines starting with
#). If the script exceeds the threshold but has at most one comment line (typically just the shebang), the rule reports a warning. Comments improve maintainability and help other developers (and AI models) understand the script without executing it.Incorrect
Long script with no explanatory comments
Correct
Script with explanatory comments
How To Fix
Add comments to the script explaining what it does, why certain steps are needed, and any non-obvious logic. At minimum, add a header comment describing the script purpose.
Options
Default options:
Require comments only for scripts longer than 20 lines:
Require comments for any script longer than 5 lines:
When Not To Use It
Disable this rule for auto-generated scripts where comments would be immediately overwritten.
Related Rules
skill-missing-shebangResources
Version
Available since: v0.2.0