bash-defensive-patterns – skill Viết lách & Nội dung cho agent AI
Thành thạo kỹ thuật lập trình Bash phòng thủ cho script production. Dùng khi viết shell script chắc chắn, pipeline CI/CD hoặc tiện ích hệ thống cần khả năng chịu lỗi và an toàn.
Cài skill bash-defensive-patterns bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/bash-defensive-patterns-03ed7.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /bash-defensive-patterns – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/bash-defensive-patterns-03ed7.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $bash-defensive-patterns – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/bash-defensive-patterns-03ed7.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /bash-defensive-patterns – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/bash-defensive-patterns-03ed7.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /bash-defensive-patterns – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Bash Defensive Patterns
Comprehensive guidance for writing production-ready Bash scripts using defensive programming techniques, error handling, and safety best practices to prevent common pitfalls and ensure reliability.
When to Use This Skill
- Writing production automation scripts
- Building CI/CD pipeline scripts
- Creating system administration utilities
- Developing error-resilient deployment automation
- Writing scripts that must handle edge cases safely
- Building maintainable shell script libraries
- Implementing comprehensive logging and monitoring
- Creating scripts that must work across different platforms
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices Summary
1. Always use strict mode - set -Eeuo pipefail
2. Quote all variables - "$variable" prevents word splitting
3. Use [[]] conditionals - More robust than [ ]
4. Implement error trapping - Catch and handle errors gracefully
5. Validate all inputs - Check file existence, permissions, formats
6. Use functions for reusability - Prefix with meaningful names
7. Implement structured logging - Include timestamps and levels
8. Support dry-run mode - Allow users to preview changes
9. Handle temporary files safely - Use mktemp, cleanup with trap
10. Design for idempotency - Scripts should be safe to rerun
11. Document requirements - List dependencies and minimum versions
12. Test error paths - Ensure error handling works correctly
13. Use command -v - Safer than which for checking executables
14. Prefer printf over echo - More predictable across systems
Skill liên quan
- ai-act-readiness – /compliance-os:ai-act-readiness [system] — Bộ 6 câu hỏi chất vấn bắt buộc về EU AI Act…
- internal-comms – Bộ tài nguyên giúp tôi soạn mọi loại truyền thông nội bộ theo định dạng công ty tôi ưa…
- ai-blog-intro-writer – AI Blog Intro Writer. Dùng khi làm việc với chủ đề và góc tiếp cận bài viết, hoặc bản…
- ai-content-detector – AI Content Detector. Dùng khi làm việc với văn bản cần rà soát.
- ai-content-improver – AI Content Improver. Dùng khi làm việc với bản nháp văn bản.
- baoyu-article-illustrator – Minh họa bài viết: loại × phong cách × bảng màu nhất quán.
- ai-content-outline-generator – Trình tạo dàn ý nội dung AI. Dùng khi làm việc với chủ đề hoặc câu hỏi của người đọc.
- ai-faq-creator – Trình tạo FAQ AI. Dùng khi làm việc với nội dung nguồn hoặc chủ đề.