Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #4017

bash-scripting

Skill này làm gì

Hướng dẫn này giúp bạn tạo các script tự động hóa mạnh mẽ, sẵn sàng cho môi trường thực tế. Nó chỉ cách thêm yếu tố an toàn, xử lý lỗi và kiểm thử để đảm bảo script hoạt động đúng.

Khi nào nên dùng

  • ✓Khi bạn cần tự động hóa các tác vụ lặp đi lặp lại trên máy tính.
  • ✓Khi tạo công cụ để quản lý hệ thống.
  • ✓Khi xây dựng script giúp triển khai hoặc sao lưu tệp.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/bash-scripting/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/bash-scripting/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Giúp tôi tạo một script an toàn để sao lưu các tệp quan trọng của mình.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Hướng dẫn chia thành các bước như lên kế hoạch cho script, viết mã cốt lõi, thêm xử lý lỗi và kiểm thử mọi thứ. Mỗi bước có gợi ý các công cụ và lệnh cụ thể.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Bash Scripting Workflow

Overview

Specialized workflow for creating robust, production-ready bash scripts with defensive programming patterns, comprehensive error handling, and automated testing.

When to Use This Workflow

Use this workflow when:

  • Creating automation scripts
  • Writing system administration tools
  • Building deployment scripts
  • Developing backup solutions
  • Creating CI/CD scripts

Scope and execution

Choose the phases that match the user’s task; this document is an index, not an instruction to run every listed skill. Read a selected skill before using it. Respect repository and user constraints. Cloud calls, host configuration, publishing, destructive operations and spending require the applicable authorization; a workflow checklist does not grant it.

The template is a starting point, not a completed script: it does not implement argument parsing or rollback. Validate paths, quote expansions, test in a disposable directory, and make retries bounded and safe for the specific command. Never log credentials or imply strict mode catches every failure.

Workflow Phases

Phase 1: Script Design

Skills to Invoke

  • bash-pro - Professional scripting
  • bash-defensive-patterns - Defensive patterns

Actions

  1. Define script purpose
  2. Identify inputs/outputs
  3. Plan error handling
  4. Design logging strategy
  5. Document requirements

Copy-Paste Prompts

Use @bash-pro to design production-ready bash script

Phase 2: Script Structure

Skills to Invoke

  • bash-pro - Script structure
  • bash-defensive-patterns - Safety patterns

Actions

  1. Add shebang and strict mode
  2. Create usage function
  3. Implement argument parsing
  4. Set up logging
  5. Add cleanup handlers

Copy-Paste Prompts

Use @bash-defensive-patterns to implement strict mode and error handling

Phase 3: Core Implementation

Skills to Invoke

  • bash-linux - Linux commands
  • linux-shell-scripting - Shell scripting

Actions

  1. Implement main functions
  2. Add input validation
  3. Create helper functions
  4. Handle edge cases
  5. Add progress indicators

Copy-Paste Prompts

Use @bash-linux to implement system commands

Phase 4: Error Handling

Skills to Invoke

  • bash-defensive-patterns - Error handling
  • error-handling-patterns - Error patterns

Actions

  1. Add trap handlers
  2. Implement retry logic
  3. Create error messages
  4. Set up exit codes
  5. Add rollback capability

Copy-Paste Prompts

Use @bash-defensive-patterns to add comprehensive error handling

Phase 5: Logging

Skills to Invoke

  • bash-pro - Logging patterns

Actions

  1. Create logging function
  2. Add log levels
  3. Implement timestamps
  4. Configure log rotation
  5. Add debug mode

Copy-Paste Prompts

Use @bash-pro to implement structured logging

Phase 6: Testing

Skills to Invoke

  • bats-testing-patterns - Bats testing
  • shellcheck-configuration - ShellCheck

Actions

  1. Write Bats tests
  2. Run ShellCheck
  3. Test edge cases
  4. Verify error handling
  5. Test with different inputs

Copy-Paste Prompts

Use @bats-testing-patterns to write script tests
Use @shellcheck-configuration to lint bash script

Phase 7: Documentation

Skills to Invoke

  • documentation-templates - Documentation

Actions

  1. Add script header
  2. Document functions
  3. Create usage examples
  4. List dependencies
  5. Add troubleshooting section

Copy-Paste Prompts

Use @documentation-templates to document bash script

Script Template

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

SCRIPT_NAME=$(basename -- "$0")
readonly SCRIPT_NAME
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
readonly SCRIPT_DIR

log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
error() { log "ERROR: $*" >&2; exit 1; }

usage() { cat <<EOF
Usage: $SCRIPT_NAME [OPTIONS]
Options:
    -h, --help      Show help
    -v, --verbose   Verbose output
EOF
}

main() {
    log "Script started"
    # Implementation
    log "Script completed"
}

main "$@"

Quality Gates

  • ShellCheck passes
  • Bats tests pass
  • Error handling works
  • Logging functional
  • Documentation complete

Related Workflow Bundles

  • os-scripting - OS scripting
  • linux-troubleshooting - Linux troubleshooting
  • cloud-devops - DevOps automation

Limitations

  • Use this skill only when the task clearly matches the scope described above.

…

Câu hỏi thường gặp

“Mẫu phòng thủ” (defensive patterns) là gì?

Đây là các thực hành lập trình giúp script an toàn hơn và ít gặp lỗi, chẳng hạn kiểm tra tệp có tồn tại trước khi dùng.

“Xử lý lỗi” (error handling) là gì?

Đây là cách script xử lý những vấn đề bất ngờ, như lệnh thất bại, để nó không dừng hoạt động đột ngột và báo rõ điều gì đã sai.

Tại sao cần kiểm thử script?

Kiểm thử đảm bảo script làm đúng việc trong nhiều tình huống khác nhau và cơ chế xử lý lỗi hoạt động như mong đợi trước khi bạn dùng nó cho những tác vụ quan trọng.

Chi tiết

Mô tả gốc của tác giả

Bash scripting workflow for creating production-ready shell scripts with defensive patterns, error handling, and testing.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4017
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự