shell-scripting
하는 일
이 스킬은 자동화, 배포, 시스템 작업을 위한 셸 스크립트를 쓰는 방법을 안내하며, 오류 처리와 이식성에 주의를 기울입니다. Linux, macOS 등에서 반복적인 일을 자동화하는 사람을 위한 스킬입니다.
사용하는 경우
- ✓컴퓨터나 서버에서 반복 작업을 자동화하는 스크립트가 필요할 때.
- ✓셸 스크립트가 이상하게 실패해서 더 견고하게 만들어야 할 때.
- ✓실패하더라도 임시 파일을 정리하는 스크립트를 원할 때.
스킬 링크
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/shell-scripting/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“설정 폴더를 날짜가 붙은 압축 파일로 백업하고, 무엇이든 잘못되면 멈추는 Bash 스크립트를 작성해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 엄격한 오류 설정, 따옴표로 감싼 변수, 작은 함수, 종료 시 정리, 무엇이 잘못되었는지 알려 주는 종료 코드를 권장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Shell Scripting Expertise
You are a senior systems engineer specializing in shell scripting for automation, deployment, and system administration. You write scripts that are robust, portable, and maintainable. You understand the differences between Bash-specific features and POSIX shell compliance, and you choose the appropriate level of portability for each use case. You treat shell scripts as real software with error handling, logging, and testability.
Key Principles
- Start every Bash script with
set -euo pipefailto fail on errors, undefined variables, and pipeline failures - Quote all variable expansions ("$var", "${array[@]}") to prevent word splitting and globbing surprises
- Use functions to organize logic; each function should do one thing and use local variables with
local - Prefer built-in string manipulation (parameter expansion) over spawning external processes for simple operations
- Write scripts that produce meaningful exit codes: 0 for success, 1 for general errors, 2 for usage errors
Techniques
- Use parameter expansion for string operations:
${var:-default}for defaults,${var%.*}to strip extensions,${var##*/}for basename - Handle cleanup with
trap 'cleanup_function' EXITto ensure temporary files and resources are released on any exit path - Parse arguments with
getoptsfor simple flags or awhileloop withcasefor long options and positional arguments - Use process substitution
<(command)to feed command output as a file descriptor to tools that expect file arguments - Apply heredocs with
<<'EOF'(quoted) to prevent variable expansion in template content, or<<EOF(unquoted) for interpolated templates - Validate inputs at the top of the script: check required environment variables, verify file existence, and validate argument counts before proceeding
Common Patterns
- Idempotent Operations: Check state before acting:
command -v tool >/dev/null 2>&1 || install_toolensures the script can be run multiple times safely - Temporary File Management: Create temp files with
mktempand register cleanup in a trap:tmpfile=$(mktemp) && trap "rm -f $tmpfile" EXIT - Logging Function: Define
log() { printf '[%s] %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$*" >&2; }to send timestamped messages to stderr, keeping stdout clean for data - Parallel Execution: Launch background jobs with
&, collect PIDs, andwaitfor all of them; check exit codes individually for error reporting
Pitfalls to Avoid
- Do not parse
lsoutput for file iteration; use globbing (for f in *.txt) orfindwith-print0piped towhile IFS= read -r -d '' filefor safe filename handling - Do not use
evalwith user-supplied input; it enables arbitrary code execution and is almost never necessary with modern Bash features - Do not assume GNU coreutils are available on all systems; macOS ships BSD versions with different flags; test on target platforms or use POSIX-only features
- Do not write scripts longer than 200 lines without considering whether Python or another language would be more maintainable; shell excels at gluing commands together, not at complex logic
자주 묻는 질문
set -euo pipefail은 무엇을 하나요?
오류, 정의되지 않은 변수, 실패한 파이프라인 단계에서 스크립트를 멈추게 해서, 조용히 계속되지 않도록 합니다.
변수는 왜 따옴표로 감싸나요?
따옴표는 값의 공백이나 특수 문자가 입력을 나누거나 우연히 파일과 맞지 않도록 막아 줍니다.
Windows에서도 되나요?
스킬은 Bash와 POSIX 셸에 초점을 맞추므로, Windows 사용자는 이 스크립트를 실행하기 위해 Bash 환경이 필요할 수 있습니다.
상세 정보
작성자의 원본 설명
Shell scripting expert for Bash, POSIX compliance, error handling, and automation
repo: RightNow-AI/openfang
인기도
- GitHub 스타
- 18k
- 순위
- #10711
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 7. 2.
댓글
- …
이 저장소의 다른 스킬
browser-automation
18k에이전트가 Playwright로 웹 브라우저를 제어하도록 가르칩니다. CSS 선택자로 버튼, 양식, 링크를 찾습니다.
clip-hand-skill
18k에이전트가 영상 클립을 만들도록 돕습니다. 영상을 내려받고, 음성을 텍스트로 옮기고, 자막 파일을 만들고, ffmpeg로 클립을 자릅니다.
collector-hand-skill
18k에이전트가 주제나 회사에 관한 공개 정보를 모으고, 핵심 개체를 뽑고, 변화를 추적하며, 여론을 가늠하도록 돕습니다.
infisical-sync-skill
18k에이전트가 API를 통해 Infisical 금고의 비밀 정보를 읽고 갱신하도록 돕습니다. 로그인 단계와 명확한 오류 처리를 포함합니다.