Community生产力与协作github.com

sickn33/bash-scripting

用于创建生产级 Shell 脚本的 Bash 脚本编写工作流,包含防御性模式、错误处理和测试。

bash-scripting 是什么?

该技能通过提供结构化的工作流,帮助开发者编写可靠、可维护的生产级 Bash 脚本。它整合了防御性编程模式、健壮的错误处理以及测试策略,确保脚本在各种环境下都能稳定运行。支持所有常见的 Unix/Linux 平台。其核心机制包括:在脚本开头启用 `set -euo pipefail` 来严格捕获错误,使用 trap 命令处理意外退出,以及通过 ShellCheck 等工具进行静态分析。技能还提供了编写单元测试的指导,建议使用 bats 等测试框架,从而提升脚本质量并减少生产环境中的故障。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/bash-scripting

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

bash-scripting 是做什么的?

用于创建生产级 Shell 脚本的 Bash 脚本编写工作流,包含防御性模式、错误处理和测试。

主要特性

  • 防御性编程:启用严格模式(set -euo pipefail)以自动捕获未定义变量、管道错误等。
  • 错误处理:使用 trap 命令捕获脚本退出信号,执行清理或调试操作。
  • 静态分析:集成 ShellCheck 对脚本进行 lint 检查,发现常见问题。
  • 测试框架:推荐使用 bats 进行单元测试,确保脚本功能正确。
  • 文档生成:支持从脚本注释自动生成使用说明。

使用方法

  1. 在脚本顶部添加以下严格模式设置:
    set -euo pipefail
    
  2. 定义错误处理函数:
    trap 'echo "错误发生在第 $LINENO 行"; exit 1' ERR
    
  3. 使用 ShellCheck 检查语法:
    shellcheck your_script.sh
    
  4. 编写 bats 测试用例:
    #!/usr/bin/env bats
    @test "测试脚本成功执行" {
        run ./your_script.sh
        [ "$status" -eq 0 ]
    }
    

最佳实践

  • 始终使用 set -euo pipefail 来避免静默错误。
  • 为每个函数编写明确的输入验证。
  • 使用 bash -n script.sh 进行语法检查。
  • 使用 bash -x script.sh 调试脚本执行过程。

平台支持

  • Linux (所有发行版)
  • macOS
  • WSL (Windows Subsystem for Linux)

依赖

  • Bash 4.0+
  • ShellCheck (可选但推荐)
  • bats (用于测试)

贡献

欢迎提交问题和拉取请求。请确保遵守防御性编程原则,并为新功能添加测试。

Individual skills in this repo

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

sickn33/3d-web-experience

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

sickn33/agent-memory-mcp

A hybrid memory system that provides persistent, searchable knowledge management for AI agents (Architecture, Patterns, Decisions).

sickn33/agent-memory-systems

Memory is the cornerstone of intelligent agents. Without it, every interaction starts from zero. This skill covers the architecture of agent memory: short-term (context window), long-term (vector stores), and the cognitive architectures that organize them.

sickn33/ai-agents-architect

Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration.

sickn33/api-documentation-generator

Generate comprehensive, developer-friendly API documentation from code, including endpoints, parameters, examples, and best practices

sickn33/api-patterns

API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination.

sickn33/api-security-best-practices

Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities

sickn33/app-store-optimization

Complete App Store Optimization (ASO) toolkit for researching, optimizing, and tracking mobile app performance on Apple App Store and Google Play Store

sickn33/architecture

Architectural decision-making framework. Requirements analysis, trade-off evaluation, ADR documentation. Use when making architecture decisions or analyzing system design.

sickn33/audio-transcriber

Transform audio recordings into professional Markdown documentation with intelligent summaries using LLM integration

sickn33/aws-serverless

Specialized skill for building production-ready serverless applications on AWS. Covers Lambda functions, API Gateway, DynamoDB, SQS/SNS event-driven patterns, SAM/CDK deployment, and cold start optimization.

sickn33/backend-architect

Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems.

sickn33/backend-dev-guidelines

You are a senior backend engineer operating production-grade services under strict architectural and reliability constraints. Use when routes, controllers, services, repositories, express middleware, or prisma database access.

sickn33/bash-linux

Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.

sickn33/brainstorming

Use before creative or constructive work (features, architecture, behavior). Transforms vague ideas into validated designs through disciplined reasoning and collaboration.

sickn33/browser-automation

Browser automation powers web testing, scraping, and AI agent interactions. The difference between a flaky script and a reliable system comes down to understanding selectors, waiting strategies, and anti-detection patterns.

sickn33/browser-extension-builder

Expert in building browser extensions that solve real problems - Chrome, Firefox, and cross-browser extensions. Covers extension architecture, manifest v3, content scripts, popup UIs, monetization strategies, and Chrome Web Store publishing.

sickn33/bullmq-specialist

BullMQ expert for Redis-backed job queues, background processing, and reliable async execution in Node.js/TypeScript applications.

sickn33/bun-development

Fast, modern JavaScript/TypeScript development with the Bun runtime, inspired by [oven-sh/bun](https://github.com/oven-sh/bun).

sickn33/cc-skill-security-review

This skill ensures all code follows security best practices and identifies potential vulnerabilities. Use when implementing authentication or authorization, handling user input or file uploads, or creating new API endpoints.

相关技能