Documentation/Jutsu/Shellcheck
🎯

Shellcheck

v1.3.1

Validation and quality enforcement for Bash and shell scripts using ShellCheck.

Installation

Install han binary (required for hooks to work):

curl -fsSL https://han.guru/install.sh | bash

Then install this plugin:

han plugin install jutsu-shellcheck

Overview

Validation and quality enforcement for Bash and shell scripts using ShellCheck.

What This Jutsu Provides

Validation Hooks

  • ShellCheck Validation: Runs ShellCheck on all .sh files to catch common bugs, pitfalls, and style issues
  • Validates scripts on session stop and when agents complete work
  • Only runs when shell files have changed (with --cache flag)

Skills

This jutsu provides the following skills:

  • shell-scripting-fundamentals: Core patterns for variables, conditionals, loops, and functions
  • shell-error-handling: Traps, exit codes, cleanup routines, and debugging techniques
  • shell-portability: Writing scripts that work across Linux, macOS, and different shells

Installation

Install via the Han marketplace:

han plugin install jutsu-shellcheck

Or install manually:

claude plugin marketplace add thebushidocollective/han
claude plugin install jutsu-shellcheck@han

Usage

Once installed, this jutsu automatically validates your shell scripts:

  • When you finish a conversation with Claude Code
  • When Claude Code agents complete their work
  • Before commits (when combined with git hooks)

Manual Validation

Run ShellCheck manually on your scripts:

shellcheck -x script.sh
shellcheck -x **/*.sh

Configuring ShellCheck

Create a .shellcheckrc file in your project root:

# Disable specific checks
disable=SC2034,SC2086

# Set default shell
shell=bash

# Enable external sources
external-sources=true

Requirements

  • ShellCheck installed and available in PATH
  • Bash 4.0+ (for the validation hooks)

Installing ShellCheck

macOS:

brew install shellcheck

Ubuntu/Debian:

apt-get install shellcheck

Fedora:

dnf install ShellCheck

From source:

cabal update
cabal install ShellCheck

Common ShellCheck Codes

CodeDescription
SC2086Double quote to prevent globbing and word splitting
SC2046Quote this to prevent word splitting
SC2034Variable appears unused
SC2155Declare and assign separately to avoid masking return values
SC2164Use cd ... || exit in case cd fails
SC2006Use $(...) instead of legacy backticks

Overriding Hooks

Create a han-config.yml in directories where you want to customize behavior:

jutsu-shellcheck:
  shellcheck:
    enabled: false  # Disable shellcheck for this directory

Or override the command:

jutsu-shellcheck:
  shellcheck:
    command: "shellcheck -e SC2034 *.sh"  # Ignore unused variable warnings

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT License - See LICENSE for details.

Skills

Hooks

⚠

Token Usage Notice

Hooks run automatically during Claude Code sessions and their output is sent to the model for processing. This may increase token usage and associated costs. Consider disabling hooks you don't need via han-config.yml.

🛑

Stop

Runs when the main Claude Code agent has finished responding. Can verify task completion, check quality gates, or ensure documentation requirements are met before the session ends.

han hook run jutsu-shellcheck shellcheck
🛑

SubagentStop

Runs when a Claude Code subagent (Task tool call) has finished responding. Can validate subagent outputs, enforce quality standards, or trigger additional workflows after delegated tasks complete.

han hook run jutsu-shellcheck shellcheck
⏱ 2m