mcpField
B
bash-script-writing

bash-script-writing

github.com/steveclarkeDevelopment36123 installsUpdated today
Repository

About bash-script-writing

bash-script-writing is a skill that sets conventions for structuring modular Bash scripts. It is intended for script authors and covers function design, progress logging, and clear organization.

Key features

  1. 01Place main() near the top of the script
  2. 02Use clear verb-based function names
  3. 03Give each function one purpose
  4. 04Log progress and completion status
  5. 05Group sections with headers

Use cases

  1. 01Planning a new Bash script structure
  2. 02Splitting a script into focused functions
  3. 03Making script progress easier to follow

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/steveclarke/dotfiles --skill bash-script-writing

After installing, type/bash-script-writingin Claude Code to confirm it loaded.

Details

From the project README

Modular Bash Script Writing

Follow this structure when writing bash scripts.

Script Template

Place main() immediately after variables so the workflow is visible at file top.

#!/usr/bin/env bash
set -euo pipefail

################################################################################
# Script Title
################################################################################
#
# OVERVIEW
# --------
# Brief description of what this script does
#
# USAGE
# -----
#   script-name arg1 arg2
#
# CONFIGURATION
# -------------
# Environment variables or config requirements
#
################################################################################

# Colors
green='\033[0;32m'
blue='\033[0;34m'
yellow='\033[1;33m'
red='\033[0;31m'
nc='\033[0m'

# Configuration
VAR_ONE=${VAR_ONE:-default}
VAR_TWO=${VAR_TWO:?VAR_TWO is required}

################################################################################
# Main Orchestration
################################################################################

main() {
  parse_arguments "$@"
  step_one
  step_two
  log "Complete!"
}

################################################################################
# Helper Functions
################################################################################

log() { echo -e "${green}==>${nc} ${1}"; }
info() { echo -e "${blue}Info:${nc} ${1}"; }
warn() { echo -e "${yellow}Warning:${nc} ${1}"; }
error() { echo -e "${red}Error:${nc} ${1}" >&2; exit 1; }

################################################################################
# Core Functions
################################################################################

function_name() {
  log "What this function does..."
  # Implementation
  log "Complete"
}

################################################################################
# Script Execution
################################################################################

main "$@"

Function Guidelines

  • Name clearly: Verb-based names (setup_directory, validate_config)
  • One purpose: If you need "and" to describe it, split it
  • Log progress: Start with log "...", end with status
  • Keep focused: 5-20 lines per function
  • Group with section headers: Use #### dividers between logical groups

Comments

Markdown supported