ShellCheck Configuration and Static Analysis Comprehensive guidance for configuring and using ShellCheck to improve shell script quality, catch common pitfalls, and enforce best practices through static code analysis. When to Use This Skill - Setting up linting for shell scripts in CI/CD pipelines - Analyzing existing shell scripts for issues - Understanding ShellCheck error codes and warnings - Configuring ShellCheck for specific project requirements - Integrating ShellCheck into development workflows - Suppressing false positives and configuring rule sets - Enforcing consistent code quality…

| while read -r script; do\n echo \"Linting: $script\"\n\n if ! shellcheck \"$script\"; then\n echo \"ShellCheck failed on $script\"\n exit 1\n fi\ndone\n```\n\n### GitHub Actions Workflow\n\n```yaml\nname: ShellCheck\n\non: [push, pull_request]\n\njobs:\n shellcheck:\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v3\n\n - name: Run ShellCheck\n run: |\n sudo apt-get install shellcheck\n find . -type f -name \"*.sh\" -exec shellcheck {} \\;\n```\n\n### GitLab CI Pipeline\n\n```yaml\nshellcheck:\n stage: lint\n image: koalaman/shellcheck-alpine\n script:\n - find . -type f -name \"*.sh\" -exec shellcheck {} \\;\n allow_failure: false\n```\n\n## Handling ShellCheck Violations\n\n### Suppressing Specific Warnings\n\n```bash\n#!/bin/bash\n\n# Disable warning for entire line\n# shellcheck disable=SC2086\nfor file in $(ls -la); do\n echo \"$file\"\ndone\n\n# Disable for entire script\n# shellcheck disable=SC1091,SC2119\n\n# Disable multiple warnings (format varies)\ncommand_that_fails() {\n # shellcheck disable=SC2015\n [ -f \"$1\" ] && echo \"found\" || echo \"not found\"\n}\n\n# Disable specific check for source directive\n# shellcheck source=./helper.sh\nsource helper.sh\n```\n\n### Common Violations and Fixes\n\n#### SC2086: Double quote to prevent word splitting\n\n```bash\n# Problem\nfor i in $list; do done\n\n# Solution\nfor i in $list; do done # If $list is already quoted, or\nfor i in \"${list[@]}\"; do done # If list is an array\n```\n\n#### SC2181: Check exit code directly\n\n```bash\n# Problem\nsome_command\nif [ $? -eq 0 ]; then\n echo \"success\"\nfi\n\n# Solution\nif some_command; then\n echo \"success\"\nfi\n```\n\n#### SC2015: Use if-then instead of && ||\n\n```bash\n# Problem\n[ -f \"$file\" ] && echo \"exists\" || echo \"not found\"\n\n# Solution - clearer intent\nif [ -f \"$file\" ]; then\n echo \"exists\"\nelse\n echo \"not found\"\nfi\n```\n\n#### SC2016: Expressions don't expand in single quotes\n\n```bash\n# Problem\necho 'Variable value: $VAR'\n\n# Solution\necho \"Variable value: $VAR\"\n```\n\n#### SC2009: Use pgrep instead of grep\n\n```bash\n# Problem\nps aux | grep -v grep | grep myprocess\n\n# Solution\npgrep -f myprocess\n```\n\n## Performance Optimization\n\n### Checking Multiple Files\n\n```bash\n#!/bin/bash\n\n# Sequential checking\nfor script in *.sh; do\n shellcheck \"$script\"\ndone\n\n# Parallel checking (faster)\nfind . -name \"*.sh\" -print0 | \\\n xargs -0 -P 4 -n 1 shellcheck\n```\n\n### Caching Results\n\n```bash\n#!/bin/bash\n\nCACHE_DIR=\".shellcheck_cache\"\nmkdir -p \"$CACHE_DIR\"\n\ncheck_script() {\n local script=\"$1\"\n local hash\n local cache_file\n\n hash=$(sha256sum \"$script\" | cut -d' ' -f1)\n cache_file=\"$CACHE_DIR/$hash\"\n\n if [[ ! -f \"$cache_file\" ]]; then\n if shellcheck \"$script\" > \"$cache_file\" 2>&1; then\n touch \"$cache_file.ok\"\n else\n return 1\n fi\n fi\n\n [[ -f \"$cache_file.ok\" ]]\n}\n\nfind . -name \"*.sh\" | while read -r script; do\n check_script \"$script\" || exit 1\ndone\n```\n\n## Output Formats\n\n### Default Format\n\n```bash\nshellcheck script.sh\n\n# Output:\n# script.sh:1:3: warning: foo is referenced but not assigned. [SC2154]\n```\n\n### GCC Format (for CI/CD)\n\n```bash\nshellcheck --format=gcc script.sh\n\n# Output:\n# script.sh:1:3: warning: foo is referenced but not assigned.\n```\n\n### JSON Format (for parsing)\n\n```bash\nshellcheck --format=json script.sh\n\n# Output:\n# [{\"file\": \"script.sh\", \"line\": 1, \"column\": 3, \"level\": \"warning\", \"code\": 2154, \"message\": \"...\"}]\n```\n\n### Quiet Format\n\n```bash\nshellcheck --format=quiet script.sh\n\n# Returns non-zero if issues found, no output otherwise\n```\n","content_type":"text/markdown; charset=utf-8","language":"markdown","size":7951,"content_sha256":"65ba7c3e5ac0132e1fa4f75fe9776a68cb3c14b60d2b504f63e3ffad781e5723"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"ShellCheck Configuration and Static Analysis","type":"text"}]},{"type":"paragraph","content":[{"text":"Comprehensive guidance for configuring and using ShellCheck to improve shell script quality, catch common pitfalls, and enforce best practices through static code analysis.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"When to Use This Skill","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Setting up linting for shell scripts in CI/CD pipelines","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Analyzing existing shell scripts for issues","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Understanding ShellCheck error codes and warnings","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Configuring ShellCheck for specific project requirements","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Integrating ShellCheck into development workflows","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Suppressing false positives and configuring rule sets","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Enforcing consistent code quality standards","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Migrating scripts to meet quality gates","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Detailed patterns and worked examples","type":"text"}]},{"type":"paragraph","content":[{"text":"Detailed pattern documentation lives in ","type":"text"},{"text":"references/details.md","type":"text","marks":[{"type":"code_inline"}]},{"text":". Read that file when the navigation tier above is insufficient.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Best Practices","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Run ShellCheck in CI/CD","type":"text","marks":[{"type":"strong"}]},{"text":" - Catch issues before merging","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Configure for your target shell","type":"text","marks":[{"type":"strong"}]},{"text":" - Don't analyze bash as sh","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Document exclusions","type":"text","marks":[{"type":"strong"}]},{"text":" - Explain why violations are suppressed","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Address violations","type":"text","marks":[{"type":"strong"}]},{"text":" - Don't just disable warnings","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Enable strict mode","type":"text","marks":[{"type":"strong"}]},{"text":" - Use ","type":"text"},{"text":"--enable=all","type":"text","marks":[{"type":"code_inline"}]},{"text":" with careful exclusions","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Update regularly","type":"text","marks":[{"type":"strong"}]},{"text":" - Keep ShellCheck current for new checks","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use pre-commit hooks","type":"text","marks":[{"type":"strong"}]},{"text":" - Catch issues locally before pushing","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Integrate with editors","type":"text","marks":[{"type":"strong"}]},{"text":" - Get real-time feedback during development","type":"text"}]}]}]}]},"metadata":{"date":"2026-11-02","name":"shellcheck-configuration","author":"@skillopedia","source":{"stars":42106,"repo_name":"agents","origin_url":"https://github.com/wshobson/agents/blob/HEAD/plugins/shell-scripting/skills/shellcheck-configuration/SKILL.md","repo_owner":"wshobson","body_sha256":"0442d7cb63b35ac5eccb60450822b66bf036381d476f5aed7a148aa635c5c598","cluster_key":"bacab54ee25dd71f680be0859fec8088f633e2631ee99a77e1b099fe30bb9700","clean_bundle":{"format":"clean-skill-bundle-v1","source":"wshobson/agents/plugins/shell-scripting/skills/shellcheck-configuration/SKILL.md","text_bytes":7951,"source_commit":"7e2fb559cf4b824b27f1fec49fe88f7511066d26","skills_sh_rank":2126,"attachment_count":1,"text_attachments":1,"attachment_storage":"skill_attachments","binary_attachments":0},"cluster_size":1,"skill_md_path":"plugins/shell-scripting/skills/shellcheck-configuration/SKILL.md","import_metadata":{"date":"2026-11-02","author":"@skillopedia","version":"v1","category":"testing-qa","category_label":"Testing"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"testing-qa","import_tag":"skills-sh-top20k-2026-11","description":"Master ShellCheck static analysis configuration and usage for shell script quality. Use when setting up linting infrastructure, fixing code issues, or ensuring script portability."}},"renderedAt":1793665990398}

ShellCheck Configuration and Static Analysis Comprehensive guidance for configuring and using ShellCheck to improve shell script quality, catch common pitfalls, and enforce best practices through static code analysis. When to Use This Skill - Setting up linting for shell scripts in CI/CD pipelines - Analyzing existing shell scripts for issues - Understanding ShellCheck error codes and warnings - Configuring ShellCheck for specific project requirements - Integrating ShellCheck into development workflows - Suppressing false positives and configuring rule sets - Enforcing consistent code quality…