Community코딩 & 개발github.com

Bash 개발 (Jamie-BitFlight/bash-development)

사용자가 'bash 스크립트 작성', '쉘 스크립트 생성', 'bash 함수 구현', '인자 파싱', '에러 처리' 등을 요청하거나 bash 개발, 쉘 스크립팅, 스크립트 템플릿, 현대적인 bash 패턴을 언급할 때 사용하는 스킬입니다.

bash-development)란 무엇인가요?

이 스킬은 Bash 5.1+ 환경에서 안정적이고 유지보수 가능한 스크립트를 개발하기 위한 핵심 패턴과 모범 사례를 제공합니다. set -euo pipefail을 포함한 표준 헤더와 trap 기반 에러 처리, 인자 파싱 템플릿을 통해 스크립트의 기초를 탄탄히 다질 수 있습니다. 또한 확장 변수 참조, readonly 상수 사용, 네이티브 문자열 연산(대소문자 변환, 치환, 접두사/접미사 제거), 배열 및 파일 연산(mapfile, mktemp) 등의 순수 bash 기법을 다루며, 외부 명령어 대신 bash 내장 기능을 우선 사용하도록 유도합니다. 이 스킬은 Claude Code, Cursor, Codex 등 다양한 AI 에이전트에서 사용할 수 있으며, SKILL.md 문서와 함께 제공되는 참조 파일(bash_example_file.sh, bash_example_includes.bash, bash-agent-notes.md, pure-bash-bible 시리즈)을 통해 실제 코드 예제를 학습할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Jamie-BitFlight/claude_skills/tree/main/plugins/bash-development/skills/bash-development

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Bash 개발

Bash 5.1+ 스크립트 개발을 위한 핵심 패턴과 모범 사례입니다. 현대적인 bash 관용구, 에러 처리, 인자 파싱, 외부 명령어 대신 순수 bash 대안을 제공합니다.

스크립트 기초

모든 스크립트는 다음 필수 헤더로 시작합니다:

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

set 옵션 설명:

  • -e - 명령어 실패 시 즉시 종료
  • -u - 설정되지 않은 변수를 오류로 처리
  • -o pipefail - 파이프라인에서 어떤 명령어라도 실패하면 파이프라인 실패 처리

스크립트 메타데이터 패턴

SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
readonly SCRIPT_VERSION="1.0.0"
readonly SCRIPT_NAME SCRIPT_DIR

에러 처리

견고한 스크립트를 위한 trap 기반 에러 처리를 구현합니다.

코드 예제

인자 파싱

표준 인자 파싱 템플릿입니다.

코드 예제

변수 모범 사례

항상 중괄호를 사용하고 변수를 따옴표로 감쌉니다:

# 올바름
"${variable}"
"${array[@]}"

# 잘못됨
$variable
${array[*]}  # 올바른 반복을 위해 [@] 사용

상수에는 readonly 사용:

readonly CONFIG_FILE="/etc/app/config"
readonly -a VALID_OPTIONS=("opt1" "opt2" "opt3")

참고: 소스 스크립트 안에서는 readonly를 사용하지 마십시오. 다시 소싱할 때 오류가 발생합니다.

문자열 연산 (순수 Bash)

외부 도구보다 네이티브 bash 매개변수 확장을 선호하십시오:

# 공백 제거
trimmed="${string#"${string%%[![:space:]]*}"}"
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"

# 소문자/대문자 (Bash 4+)
lower="${string,,}"
upper="${string^^}"

# 부분 문자열 추출
substring="${string:0:10}"      # 처음 10자
suffix="${string: -5}"          # 마지막 5자

# 패턴 치환
replaced="${string//old/new}"   # 모두 치환
replaced="${string/old/new}"    # 첫 번째만 치환

# 접두사/접미사 제거
no_prefix="${string#prefix}"    # 최단 일치
no_prefix="${string##*/}"       # 최장 일치 (basename)
no_suffix="${string%suffix}"    # 최단 일치
no_suffix="${string%%/*}"       # 최장 일치

배열 연산

# 선언
declare -a indexed_array=()
declare -A assoc_array=()

# nullglob을 사용한 안전한 반복
shopt -s nullglob
for file in *.txt; do
    process "${file}"
done
shopt -u nullglob

# 배열 길이
length="${#array[@]}"

# 요소 추가
array+=("new_element")

# 인덱스로 반복
for i in "${!array[@]}"; do
    printf '%d: %s\n' "${i}" "${array[i]}"
done

파일 연산

# 파일을 문자열로 읽기
content="$(<"${file}")"

# 파일을 배열로 읽기 (Bash 4+)
mapfile -t lines < "${file}"

# 파일 조건 확인
[[ -f "${file}" ]]    # 일반 파일 존재
[[ -d "${dir}" ]]     # 디렉토리 존재
[[ -r "${file}" ]]    # 읽기 가능
[[ -w "${file}" ]]    # 쓰기 가능
[[ -x "${file}" ]]    # 실행 가능
[[ -s "${file}" ]]    # 비어 있지 않음

# 안전한 임시 파일 생성
temp_file=$(mktemp)
trap 'rm -f "${temp_file}"' EXIT

조건 표현식

조건문에는 [[ ]] 사용 (bash 전용, 더 강력함):

# 문자열 비교
[[ "${var}" == "value" ]]       # 동등
[[ "${var}" == pattern* ]]      # 글로브 매칭
[[ "${var}" =~ ^regex$ ]]       # 정규식 매칭

# 숫자 비교
(( num > 10 ))                   # 산술 비교
[[ "${num}" -gt 10 ]]          # 전통적인 문법

# 복합 조건
[[ -f "${file}" && -r "${file}" ]]
[[ "${opt}" == "a" || "${opt}" == "b" ]]

유틸리티 함수

코드 예제

성능 지침

  • 가능하면 외부 명령어보다 내장 명령어 사용
  • 대용량 데이터셋은 루프 대신 배치 연산 사용
  • 이식성과 제어를 위해 echo 대신 printf 사용
  • 빡빡한 루프에서 불필요한 서브쉘 피하기
  • 문자열 비교 시 [ ]보다 [[ ]] 사용

추가 자료

참조 파일

상세 패턴 및 예제는 다음을 참조하십시오:

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Jamie-BitFlight/agentskill-kaizen-meta-docs

Agentskill kaizen plugin documentation index. Load when needing to read about cross-platform notes, improvement plans, or DuckDB integration.

Jamie-BitFlight/bash-51-features

Bash 5.1 release features and improvements with practical examples. Use when working with Bash 5.1 features, epoch time variables, redirection enhancements, or when user asks about Bash 5.1 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-52-features

Bash 5.2 release features and improvements with practical examples. Use when working with Bash 5.2 features, variable handling enhancements, readline improvements, or when user asks about Bash 5.2 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-53-features

Bash 5.3 release features and improvements with practical examples. Use when working with Bash 5.3 features, new command substitution, GLOBSORT, loadable builtins, or when user asks about Bash 5.3 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-lint

This skill should be used when the user asks to "lint bash script", "run shellcheck", "format shell script", "use shfmt", "fix shellcheck errors", or mentions shell script linting, formatting, code quality, or pre-commit hooks for bash.

Jamie-BitFlight/bash-logging

This skill should be used when the user asks to "add logging to bash script", "colorize output", "implement log levels", "CI/CD sections", "terminal colors in bash", or mentions logging functions, emoji output, collapsible CI sections, or shlocksmith.

Jamie-BitFlight/bash-portability

This skill should be used when the user asks about "POSIX compatibility", "portable shell scripts", "cross-shell compatibility", "bashisms", "shebang selection", or mentions writing scripts that work on different shells (bash, sh, dash, zsh) or different systems.

Jamie-BitFlight/bash-testing

This skill should be used when the user asks to "test bash script", "write shell tests", "use shunit2", "use shellspec", "create test suite for bash", or mentions unit testing, test frameworks, mocking, or test-driven development for shell scripts.

Jamie-BitFlight/brainstorming-skill

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or when users request help with ideation, marketing, and strategic planning. Explores user intent, requirements, and design before implementation using research-validated prompt patterns.

Jamie-BitFlight/clang-format

Configure clang-format code formatting. Use when: user mentions clang-format or .clang-format, analyzing code style/patterns, creating/modifying formatting config, troubleshooting formatting, brace styles/indentation/spacing/alignment/pointer alignment, or codifying conventions.

Jamie-BitFlight/commitlint

When setting up commit message validation for a project. When project has commitlint.config.js or .commitlintrc files. When configuring CI/CD to enforce commit format. When extracting commit rules for LLM prompt generation. When debugging commit message rejection errors.

Jamie-BitFlight/conventional-commits

When writing a git commit message. When task completes and changes need committing. When project uses semantic-release, commitizen, git-cliff. When choosing between feat/fix/chore/docs types. When indicating breaking changes. When generating changelogs from commit history.

Jamie-BitFlight/dasel-reference

Use when querying, modifying, or converting JSON, YAML, TOML, XML, CSV, HCL, or INI with dasel v3. Complete reference for selectors, functions, conditionals, variables, spread operator, type casting, and format-specific patterns.

Jamie-BitFlight/data-exploration

Use when exploring unknown structured data files with dasel v3 — discover schema, list keys, find nested values, sample arrays, identify data types across JSON, YAML, TOML, XML, CSV, HCL, INI formats

Jamie-BitFlight/data-transformation

Use when modifying, converting, or transforming structured data with dasel v3 — in-place mutations, format conversion, batch operations, array manipulation, object construction, and merge patterns across JSON, YAML, TOML, XML, CSV, HCL, INI

Jamie-BitFlight/delegate

Decompose substantive work into phases, dispatch each phase to a sub-agent, and adjudicate what comes back. Use whenever a request asks for implementation, investigation, a fix, a review, or any change to files — including small ones — and whenever you are about to read source or run a diagnostic yourself instead of handing it off. Also use when a report from a sub-agent needs judging, when a phase needs re-dispatching, or when a user names one instance of a pattern. Does not apply when your own prompt begins "Your ROLE_TYPE is sub-agent." — then follow references/sub-agent-contract.md instead.

Jamie-BitFlight/enterprise-hibernate-hbm

Dasel v3 query patterns for Hibernate .hbm.xml mapping files — entity-table binding, Java property-to-column extraction, one-to-many set/list/bag relationship tracing, many-to-one foreign key discovery, batch scanning across 60+ HBM files. Use when querying Hibernate ORM class mappings, extracting schema metadata from Java persistence layer, or auditing entity-column relationships in enterprise legacy codebases.

Jamie-BitFlight/enterprise-installanywhere

Dasel v3 query patterns for InstallAnywhere .iap_xml installer definitions — use when querying action sequences, discovering variables, resolving platform conditions, navigating panels, or comparing installer variants. Files are 2.5+ MB, 65,000+ lines — too large for context reads, requires structural dasel queries.

Jamie-BitFlight/enterprise-maven-pom

Dasel v3 selector patterns for Maven POM XML files — use when querying dependency versions, filtering by groupId or scope, extracting module hierarchy from parent POMs, or detecting version conflicts across enterprise multi-module Java projects. Load this skill when working with pom.xml files using dasel.

Jamie-BitFlight/enterprise-spring-xml

Dasel v3 selectors for Spring bean factory XML — use when querying any Spring ApplicationContext XML for bean discovery, dependency wiring, JMS destination mapping, property injection extraction, or cross-bean reference tracing. Load this skill before writing dasel selectors against Spring bean XML files (applicationContext.xml, *_beans.xml, spring-*.xml).

관련 스킬