본문으로 건너뛰기
cccskills
무료GitHub에 공개

bash-script-validator

Validate, lint, audit, or fix bash/shell/.sh scripts via ShellCheck.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(17)

  • SKILL.md7.5 KB
  • docs/awk-reference.md8.8 KB
  • docs/bash-reference.md8.2 KB
  • docs/common-mistakes.md9.0 KB
  • docs/grep-reference.md8.5 KB
  • docs/regex-reference.md8.4 KB
  • docs/sed-reference.md9.2 KB
  • docs/shell-reference.md8.7 KB
  • docs/shellcheck-reference.md7.2 KB
  • examples/bad-bash.sh983 B
  • examples/bad-shell.sh1.0 KB
  • examples/good-bash.sh1.3 KB
  • examples/good-shell.sh1.2 KB
  • scripts/run_ci_checks.sh681 B
  • scripts/shellcheck_wrapper.sh4.6 KB
  • scripts/test_validate.sh11.8 KB
  • scripts/validate.sh15.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Bash Script Validator

Overview

This skill validates Bash and POSIX shell scripts with layered checks:

  1. Syntax validation (bash -n or sh -n)
  2. ShellCheck static analysis (system binary or wrapper fallback)
  3. Custom security, portability, and optimization checks

Use the default flow below, then branch to fallbacks only when the environment is constrained.

Trigger Guidance

Use this skill when the request includes script quality, linting, syntax checking, or shell portability work.

Trigger Phrases

  • "Validate this bash script"
  • "Lint this .sh file"
  • "Find security issues in this shell script"
  • "Why does this script fail ShellCheck?"
  • "Make this script POSIX compliant"
  • "Review this shell script before CI"

Non-Trigger Examples

  • General Linux command questions with no script file
  • Kubernetes, Terraform, or pipeline validation tasks that do not involve shell scripts
  • Pure prose editing tasks

Deterministic Execution Model

Run commands from this skill directory:

cd devops-skills-plugin/skills/bash-script-validator

Step 1: Preflight

  1. Confirm target path exists and is readable.
  2. Confirm bash is available.
  3. Determine whether fixes can be applied directly (write access) or only suggested (read-only).

Step 2: Run Baseline Validation (Default Path)

bash scripts/validate.sh <script-path>

For deterministic stage behavior, set the ShellCheck provider explicitly:

# Modes: auto (default), system, wrapper, disabled
VALIDATOR_SHELLCHECK_MODE=system bash scripts/validate.sh <script-path>

Record:

  • Detected shell type
  • Exit code (0 clean, 1 warnings, 2 errors)
  • All reported issue lines and ShellCheck codes (SC####) when present

Step 3: Load Only Needed References

Progressive disclosure by issue type:

  • ShellCheck code explanations: docs/shellcheck-reference.md
  • General fix patterns and security mistakes: docs/common-mistakes.md
  • Bash-only behavior: docs/bash-reference.md
  • POSIX portability or bashism fixes: docs/shell-reference.md
  • Text-processing optimization issues: docs/grep-reference.md, docs/awk-reference.md, docs/sed-reference.md, docs/regex-reference.md (only when directly relevant)

Step 4: Provide or Apply Fixes

For each issue, include:

  1. Exact location from validator output (line number and snippet)
  2. Root cause
  3. Corrected code
  4. Why the change is safer or more portable
  5. Subsection-level citation (format below)

If the request includes patching files and write access is available, apply fixes in small batches grouped by issue type.

Step 5: Rerun Policy (Mandatory After Changes)

After each batch of edits, rerun the validator:

bash scripts/validate.sh <script-path>

Rerun loop rules:

  1. Continue until no new errors are introduced.
  2. If warnings remain by design, document why they are intentionally accepted.
  3. If constraints prevent full resolution, report unresolved items with a clear next action.
  4. Always report the latest rerun exit code and remaining issue count.

Fallback Behavior

Use these branches only when the default flow cannot run as-is.

ConstraintFallback actionReporting requirement
shellcheck missing, wrapper availableLet scripts/validate.sh use scripts/shellcheck_wrapper.sh --cache automaticallyState that wrapper mode was used
shellcheck and wrapper unavailableRun syntax + custom checks only (validator does this)Explicitly call out reduced coverage and missing ShellCheck analysis
Python unavailable for wrapperSkip wrapper path, keep syntax + custom checksState why ShellCheck could not run
Target file is read-onlyProvide precise patch suggestions without editingMark response as "advisory only"
Target file missing or unreadableStop and request a valid file pathDo not fabricate results
Binary/non-text inputStop validationReport unsupported input type

Citation Guidance for Fixes

Use subsection-level citations for every non-trivial fix.

Required citation format:

Reference: docs/<file>.md -> <Section> -> <Subsection>

Examples:

  • Reference: docs/common-mistakes.md -> 1. Unquoted Variables -> Solution
  • Reference: docs/shellcheck-reference.md -> SC2164: Use || exit After cd
  • Reference: docs/shell-reference.md -> POSIX Best Practices -> 5. Avoid Bashisms

Citation rules:

  1. Cite the most specific section that justifies the fix.
  2. For ShellCheck findings, include both the SC#### code and the matching section.
  3. If no exact subsection exists, cite the closest section and state that the fix is inferred from that guidance.

Response Template

Use this structure for deterministic output:

  • Validation Results
  • Command: bash scripts/validate.sh <script-path>
  • Detected shell: <shell>
  • Exit code: <code>
  • Summary: <errors> errors, <warnings> warnings, <info> info
  • Issue: <short label> (Line <n>)
  • Problem:
    <problematic snippet>
    
  • Fix:
    <corrected snippet>
    
  • Why: <short explanation>
  • Reference: docs/<file>.md -> <Section> -> <Subsection>
  • Rerun command: bash scripts/validate.sh <script-path>
  • Exit code after fixes: <code>
  • Remaining issues: <count or none>

Example Flows

Fully Automated Environment

# 1) Baseline validation
bash scripts/validate.sh examples/bad-bash.sh

# 2) Apply fixes to target script
# 3) Rerun validation
bash scripts/validate.sh examples/bad-bash.sh

Expected behavior: full syntax + ShellCheck + custom-check coverage, with iterative reruns until stable.

Deterministic CI Gate

# Requires a system shellcheck binary.
bash scripts/run_ci_checks.sh

This runner enforces VALIDATOR_REQUIRE_SHELLCHECK=1 and VALIDATOR_SHELLCHECK_MODE=system so CI fails if the ShellCheck stage is skipped or unavailable.

Constrained Environment (No ShellCheck Runtime)

# shellcheck unavailable and wrapper cannot run
bash scripts/validate.sh examples/bad-shell.sh

Expected behavior: syntax + custom checks still run. Report reduced coverage and list what must be revalidated once ShellCheck is available.

Validator Script Details

Scripts

  • scripts/validate.sh: primary validator entrypoint
  • scripts/shellcheck_wrapper.sh: optional ShellCheck fallback using a cached Python virtual environment

Detection and Ordering

Validation order in scripts/validate.sh:

  1. File checks (exists/readable/text)
  2. Shebang-based shell detection
  3. Syntax check
  4. ShellCheck (or fallback/skip behavior)
  5. Custom checks
  6. Summary with exit code

Exit Codes

  • 0: no issues found
  • 1: warnings found
  • 2: errors found

References

Load only what is needed:

  • docs/bash-reference.md
  • docs/shell-reference.md
  • docs/shellcheck-reference.md
  • docs/common-mistakes.md
  • docs/grep-reference.md
  • docs/awk-reference.md
  • docs/sed-reference.md
  • docs/regex-reference.md

Done Criteria

This skill update is complete when all are true:

  1. Trigger guidance is explicit (positive and non-trigger examples).
  2. Default workflow is deterministic and ordered.
  3. Fallback behavior is explicit for missing tooling and constrained environments.
  4. Fix explanations include subsection-level citations.
  5. Post-fix rerun policy is mandatory and reported with exit codes.
  6. Documentation supports both fully automated and constrained execution paths.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Generate, create, or scaffold Ansible playbooks, roles, tasks, handlers, inventory, vars.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

Validate, lint, audit, or debug Ansible playbooks, roles, inventories, FQCN, tasks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

Generate/create/scaffold azure-pipelines.yml, stages, jobs, steps, or reusable templates.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

Validate, lint, audit, or review azure-pipelines.yml — syntax, security, best practices.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

Create, generate, write, or scaffold bash/shell scripts (.sh), automation, or CLI tools.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

Create, generate, or write Dockerfiles and multi-stage Docker images. Containerize apps.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akin-ozer/cc-devops-skills3252026년 7월 27일 업데이트

akin-ozer의 스킬 모두 보기

이 스킬의 문제 신고