应用简介
Bash脚本工作流程,用于创建具有防御性模式、错误处理和测试的生产级shell脚本。
---
name: bash-scripting
description: "Bash scripting workflow for creating production-ready shell scripts with defensive patterns, error handling, and testing."
category: granular-workflow-bundle
risk: safe
source: personal
date_added: "2026-02-27"
---
# 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
## 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
```bash
#!/usr/bin/env bash
set -euo pipefail
readonly SCRIPT_NAME=$(basename "$0")
readonly SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
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.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
发布日期
5/16/2026
提供方
SkillOPIC
来源类型
导入
sickn33
other
数据安全
使用 Skill 时,您的对话内容将被发送至 AI 模型进行处理。我们会严格保护您的隐私数据,不会将您的对话内容用于模型训练或分享给第三方。 以下为此 Skill 的数据处理说明。
此 Skill 将处理您的对话输入
您的消息将作为 Prompt 上下文发送至 AI 模型
所有通信均通过加密通道传输
对话记录仅保存在本地
您可以随时清除本地对话历史,清除后数据不可恢复
评分和评价
已验证评分
Skill 信息
了解此 Skill 的详细信息和功能特性
其他
职场发展
文件结构
SKILL.md4.1 KB
版本历史
- 公开
- 来源于用户导入
如需详细了解相关要求,请访问帮助中心,或给我们提交反馈信息