writing-bash-scripts

Creates and refactors Bash scripts with strict conventions using shellcheck wrapper for linting.

6|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/archibate/archibate-skills --skill writing-bash-scripts-archibate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-bash-scripts
Source: https://github.com/archibate/archibate-skills/tree/main/old-skills/redundant-skills/writing-bash-scripts
Command: npx skills add https://github.com/archibate/archibate-skills --skill writing-bash-scripts-archibate

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires shellcheck, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill eliminates fragile and inconsistent Bash scripts by providing a defensive template, clear conventions, and an automated linting workflow so scripts are reliable, maintainable, and portable.

Core Features & Use Cases

  • Provides a universal script template with env bash shebang, strict mode, structured main/trap pattern, and documented usage/version output.
  • Enforces conventions such as fct_-prefixed functions, quoted variable expansions, local scoping, and idempotent operations when applicable.
  • Includes a shellcheck wrapper to discover and fail on common issues and example scripts for creating or refactoring project scripts.
  • Use cases: creating new CLI utilities, refactoring legacy shell scripts, debugging pipeline/quoting errors, and running repository-wide lint checks.

Quick Start

Use the writing-bash-scripts skill to copy the template to a new file, implement your logic following the conventions, and run the provided lint wrapper to validate the script.

Frequently Asked Questions about writing-bash-scripts

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

FAQPage Schema
How do I create robust Bash scripts that avoid common shell pitfalls?

To create robust Bash scripts, apply a defensive template with an env bash shebang, strict mode, and quoted variable expansions. Following these conventions prevents common shell pitfalls and ensures your scripts remain reliable and portable across UNIX-like environments.

What is the best way to lint and debug shell scripts for errors?

The best way to lint shell scripts is running shellcheck via an included wrapper to discover and fail on common issues. This automated workflow identifies fragile quoting and syntax errors, helping you debug shell scripts and refactor legacy code effectively.

How do I refactor legacy Bash scripts to follow strict conventions?

To refactor legacy Bash scripts, apply a universal template enforcing fct_-prefixed functions, local scoping, and structured main/trap patterns. This eliminates inconsistent code structures and transforms fragile scripts into maintainable, convention-compliant utilities.

Does shellcheck support running bulk linting checks across a repository?

Yes, shellcheck supports running repository-wide lint checks via an included wrapper. This allows you to perform bulk linting across your project scripts, automatically discovering and failing on common shell issues to ensure consistent code quality.

Why do my Bash scripts fail when variables are unquoted?

Bash scripts fail when unquoted variable expansions cause word splitting or globbing issues. You can debug these shell errors by applying strict mode, quoting variable expansions, and running shellcheck to automatically discover and correct these common pitfalls.