Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计提醒

bash-style-guidebash 风格指南

Agent Skill

bash-style-guide 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

264

周安装

11

GitHub Stars

5

下载量

88
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:bash-style-guide(bash 风格指南)
来源仓库:https://github.com/kentoshimizu/sw-agent-skills
仓库路径:skills/bash-style-guide
安装命令:
npx skills add https://github.com/kentoshimizu/sw-agent-skills --skill bash-style-guide
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/kentoshimizu/sw-agent-skills --skill bash-style-guide

简介

bash-style-guide 提供安全的 Bash 脚本编写指南,适用于 CI 和生产环境自动化。

  • 聚焦于调试友好、操作安全和代码可维护性,支持触发矩阵解析。
  • 当检测到变更文件时,可自动验证样式规则匹配情况。
  • 不适用于 Python 脚本或简单单行命令场景。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Bash Style Guide

Scope Boundaries

  • Use this skill when the task matches the trigger condition described in description.
  • Do not use this skill when the primary task falls outside this skill's domain.

Use this skill to write and review Bash scripts that are safe, debuggable, and operable in CI and production automation.

Trigger And Co-activation Reference

  • If available, use references/trigger-matrix.md for canonical co-activation rules.
  • If available, resolve style-guide activation from changed files with python3 scripts/resolve_style_guides.py <changed-path>....
  • If available, validate trigger matrix consistency with python3 scripts/validate_trigger_matrix_sync.py.

Quality Gate Command Reference

  • If available, use references/quality-gate-command-matrix.md for CI check-only and local autofix mapping.

Quick Start Snippets

Script skeleton with strict mode and cleanup trap

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

readonly SCRIPT_NAME="$(basename "$0")"
readonly TEMP_DIR="$(mktemp -d)"

cleanup() {
  rm -rf -- "${TEMP_DIR}"
}

on_error() {
  local line="$1"
  local exit_code="$2"
  echo "${SCRIPT_NAME}: failed at line ${line} (exit=${exit_code})" >&2
}

trap cleanup EXIT
trap 'on_error "$LINENO" "$?"' ERR

main() {
  echo "working dir: ${TEMP_DIR}"
}

main "$@"

Required environment variable check (fail fast)

: "${API_TOKEN:?API_TOKEN is required}"
: "${API_BASE_URL:?API_BASE_URL is required}"

Safe command assembly with arrays

run_curl() {
  local url="$1"
  local -a args=(
    --fail
    --silent
    --show-error
    --header "Authorization: Bearer ${API_TOKEN}"
    "${url}"
  )

  curl "${args[@]}"
}

Bounded retry with explicit backoff constants

readonly MAX_ATTEMPTS=5
readonly RETRY_DELAY_SECONDS=2

retry_command() {
  local attempt=1
  while (( attempt <= MAX_ATTEMPTS )); do
    if "$@"; then
      return 0
    fi

    if (( attempt == MAX_ATTEMPTS )); then
      echo "command failed after ${MAX_ATTEMPTS} attempts" >&2
      return 1
    fi

    sleep "${RETRY_DELAY_SECONDS}"
    ((attempt++))
  done
}

Safe line reading preserving whitespace

while IFS= read -r line; do
  printf 'line=%s\n' "${line}"
done < "${input_file}"

Structure And Readability

  1. Use #!/usr/bin/env bash for executable scripts.
  2. For executable entrypoints, use strict mode: set -euo pipefail.
  3. Keep functions focused on one responsibility and use main for orchestration.
  4. Use uppercase constants (MAX_RETRIES) and lowercase locals (retry_count).
  5. Use local inside functions to avoid state leakage.
  6. Add short intent comments only for non-obvious logic.

Data Handling And Quoting

  1. Quote expansions by default: "${var}", "${array[@]}".
  2. Use arrays for argument lists; avoid string-concatenated command assembly.
  3. Replace magic numbers with named constants including units (TIMEOUT_SECONDS).
  4. Avoid eval; treat it as a security-sensitive last resort.
  5. Fail fast for required environment variables; do not add silent defaults for required config.

Error Handling And Control Flow

  1. Return explicit non-zero codes for expected failure modes.
  2. Use trap for cleanup and actionable error reporting.
  3. Handle failure paths intentionally (if! cmd; then... fi) instead of masking.
  4. Avoid broad || true; suppress only with explicit rationale.
  5. Let failures surface when root cause should be fixed.

Security And Operational Safety

  1. Validate all external input before use.
  2. Use -- before positional paths in destructive commands (rm -- "$target").
  3. Prefer mktemp for temporary files/directories.
  4. Never print secrets or tokens in logs.
  5. Use least privilege and avoid unnecessary sudo.

Performance And Scalability

  1. Avoid subshell spawning in tight loops when builtins suffice.
  2. Prefer single-pass text processing over repeated pipelines.
  3. Batch filesystem operations where practical.
  4. Use bounded retry loops with named backoff constants.

Testing And Verification

  1. Add bats tests for critical behavior and failure paths.
  2. Cover edge cases: empty input, whitespace paths, missing env vars, timeout, retry exhaustion.
  3. Document manual verification where automation is not feasible.
  4. Check idempotency for scripts that may run repeatedly.

Minimal bats example

#!/usr/bin/env bats

@test "fails when required env var is missing" {
  run ./script.sh
  [ "$status" -ne 0 ]
  [[ "$output" == *"API_TOKEN is required"* ]]
}

CI Required Quality Gates (check-only)

  1. Run shellcheck with warnings treated as actionable.
  2. Run shfmt -d (or equivalent check mode) and require zero diff.
  3. Run test suite (bats test/ or repository-specific path).
  4. Reject changes that hide failures or rely on implicit behavior.

Optional Autofix Commands (local)

  1. Run shfmt -w.
  2. Apply safe mechanical fixes suggested by shellcheck, then rerun checks.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.57%
按下载量换算31

Claude

30.2%
按下载量换算27

Cursor

18.52%
按下载量换算16

Gemini CLI

8.49%
按下载量换算7

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills