shell-cli-dispatch-pattern

Implement Bash sub-command dispatchers with strict argument forwarding and lint checks.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/saintgo7/claude-skills --skill shell-cli-dispatch-pattern
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: shell-cli-dispatch-pattern
Source: https://github.com/saintgo7/claude-skills/tree/main/shell-cli-dispatch-pattern
Command: npx skills add https://github.com/saintgo7/claude-skills --skill shell-cli-dispatch-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill prevents Bash CLI bugs where sub-command argument forwarding is accidentally broken, causing user options to be silently ignored.

Core Features & Use Cases

  • Deterministic dispatcher pattern: Implements a standardized sub-command dispatcher using cmd separation with shift and strict "$@" forwarding.
  • Fail-fast and validation guardrails: Requires set -euo pipefail, enforces curl --fail-with-body -sS, and uses unknown-command handling to avoid silent failures.
  • Regression and static checks: Includes a dispatch lint script that heuristically flags missing "$@" in case branches, plus an example regression test strategy.
  • Use Case: When maintaining an admin/ops Bash CLI, ensure commands like list-users correctly honor filters such as --plan free instead of defaulting due to argument loss.

Quick Start

Ask the AI to implement a Bash admin-cli sub-command dispatcher that assigns cmd from the first argument, shifts once, forwards the remaining arguments with "$@" for every case branch, and includes a lint/regression check to ensure options are not silently ignored.

Frequently Asked Questions about shell-cli-dispatch-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why are bash sub-command arguments silently ignored in my CLI script?▼

Bash CLI sub-command arguments are silently ignored when a case-based dispatcher fails to shift the command and forward remaining options via "$@". This Skill fixes argument forwarding loss by enforcing strict shift and "$@" forwarding in every branch.

How do I forward options correctly in a bash case-based dispatcher?▼

To forward options correctly in a bash dispatcher, extract the sub-command using cmd="$1", shift once, then pass remaining arguments via "$@". This Skill implements this pattern and includes a lint script to heuristically flag missing "$@" in case branches.

What's the best way to prevent silent curl failures in bash admin scripts?▼

Prevent silent curl failures in bash admin scripts by using set -euo pipefail and curl --fail-with-body -sS. This Skill enforces these fail-fast guardrails to ensure HTTP errors surface immediately instead of causing silent data loss.

How do I add regression tests for bash CLI argument forwarding?▼

Add regression tests for bash CLI argument forwarding by running a dispatch lint script that flags missing "$@" and executing test cases that verify options like --plan free are honored. This Skill provides both lint checks and example regression test strategies.

Does this bash dispatcher pattern work without external dependencies?▼

Yes, this bash dispatcher pattern works without external dependencies. It relies entirely on native bash features like case routing, shift, and "$@" forwarding, requiring only shellcheck for static analysis and linting of the dispatch logic.