- Home
- Skills
- D Oit
- Do Novelist Ai
- Shell Script Quality
shell-script-quality_skill
- TypeScript
0
GitHub Stars
8
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill d-oit/do-novelist-ai --skill shell-script-quality- BATS.md3.6 KB
- CI-CD.md4.0 KB
- CONFIG.md5.7 KB
- PATTERNS.md6.0 KB
- README.md3.8 KB
- SHELLCHECK.md2.2 KB
- SKILL.md5.0 KB
- TROUBLESHOOTING.md7.2 KB
Overview
This skill lints and tests POSIX/Bash shell scripts using ShellCheck and BATS to improve reliability and maintainability. It combines a stepwise workflow—lint, fix, test, and CI integration—with ready-to-use templates and troubleshooting tips. Use it to enforce 2025 best practices and catch common runtime and style issues early.
How this skill works
The skill runs ShellCheck across your script files to surface syntax, quoting, and portability warnings and provides concrete fix patterns for common codes (e.g., SC2086, SC2155). It also runs BATS tests to exercise functions and CLI behavior, using a test template and patterns for setup/teardown, environment handling, and status/output assertions. Finally, it offers CI snippets to run linting and tests automatically on pull requests.
When to use it
- Validating new or modified bash/sh scripts before merging
- Adding or improving automated tests for shell utilities
- Fixing ShellCheck warnings and applying best-practice fixes
- Setting up CI/CD lint-and-test steps for repositories with scripts
- Ensuring portability and safe error handling for deployment scripts
Best practices
- Run ShellCheck early and fix issues immediately in a validation loop
- Quote variables and avoid unquoted expansions (address SC2086)
- Use set -euo pipefail and a main guard in scripts for safe sourcing
- Write focused BATS tests that assert exit status and output, and use setup/teardown to isolate state
- Integrate lint and test steps into CI to prevent regressions
Example use cases
- Lint an entire scripts directory: find scripts -name "*.sh" -exec shellcheck {} +
- Add a BATS test for a utility function that validates input and error messages
- Create a GitHub Actions job that runs ShellCheck and then installs and runs BATS tests
- Apply the provided script template for a new deploy helper with robust error handling
- Use the validation loop: change → shellcheck → fix → bats → CI
FAQ
Annotate the code with a specific disable comment (e.g., # shellcheck disable=SCXXXX) or add a .shellcheckrc to selectively disable rules. Prefer small, targeted exceptions over blanket disabling.
How do I test scripts that rely on relative paths?
Use $BATS_TEST_DIRNAME to compute test-relative paths and source scripts with a main execution guard so tests can source files without running the main logic.