Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

bash-script-generatorbash 脚本生成器

Agent Skill

bash-script-generator 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

315

周安装

13

GitHub Stars

3

下载量

103
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:bash-script-generator(bash 脚本生成器)
来源仓库:https://github.com/asteroid-belt-llc/skills
仓库路径:skills/bash-script-generator
安装命令:
npx skills add https://github.com/asteroid-belt-llc/skills --skill bash-script-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/asteroid-belt-llc/skills --skill bash-script-generator

简介

用于生成兼容 Bash 3.2 的脚本骨架,包含依赖检查和 safe defaults 设置。

  • 适用于快速构建可移植的 shell 脚本,支持参数校验、外部程序依赖管理和 shfmt 格式化。
  • 使用时需提供脚本目标、参数和环境变量要求,返回可直接使用的结构化代码。
  • 安装方式为 GitHub,支持 Codex、Claude、Cursor 和 Gemini CLI,需确保 macOS/Linux 环境可用。
  • bash-script-generator 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Structured Bash Script Generator

What You'll Do

  • 📥 Gather the script's goal, required positional/flag arguments, environment variables, and external program dependencies
  • 🧱 Produce a Bash 3.2-compatible script skeleton with a check_requirements function that validates inputs and dependencies kindly
  • 🛡️ Ensure the script sets safe defaults (set -euo pipefail), quotes expansions, and keeps logic portable to macOS/Linux Bash 3.2
  • ✨ Format the script with shfmt when available and return a polished result ready for immediate use

When to Use This Skill

Use this skill whenever the user asks for a new bash script or a major refactor of an existing script and they expect:

  • Guardrails around required arguments, environment variables, or external tools
  • Friendly, actionable error messages when prerequisites are missing
  • Compatibility with older Bash versions (macOS default 3.2)

Do not use this skill for:

  • POSIX sh-only scripts (no Bash-specific features allowed)
  • Small one-liners or trivial command snippets (respond inline instead)
  • Advanced Bash (>3.2) needs such as associative arrays or coproc

Phase 1 · Clarify the Script Brief

  1. Confirm the script's purpose, expected inputs, outputs, and typical usage examples.
  2. Identify all positional arguments and flags that must be provided. Capture human-friendly labels for each so the usage text and errors are clear.
  3. List required environment variables (names + meaning) and external commands (e.g., curl, jq). Note install hints when useful.
  4. Ask about optional inputs or defaults that should be applied when values are omitted.
  5. Determine whether the script writes files, consumes stdin/stdout, or needs cleanup logic.
Deliverable: A short table (in notes or your head) of arguments, env vars, and commands you will feed into check_requirements and usage messaging.

Phase 2 · Plan the Script Structure

Lay out the sections before writing code:

  1. Header & Safety

- #!/usr/bin/env bash - set -euo pipefail - IFS=$'\n\t' only if tighter word splitting is needed.

  1. Metadata Comments (optional)

- Summarize script purpose and prerequisites in commented lines for discoverability.

  1. Usage Helper

- A usage() function that prints how to run the script, expected args, environment variables, and examples.

  1. Requirement Configuration

- Define REQUIRED_ARGS, REQUIRED_ENV_VARS, and REQUIRED_PROGRAMS as indexed arrays (compatible with Bash 3.2). When nothing is required, keep the arrays empty but present. - Optionally define associative-looking notes via comments or simple case statements; do not use declare -A (requires Bash ≥4).

  1. check_requirements Function (see Phase 3 for exact pattern)

- Accepts parsed arguments (or a struct) and validates all prerequisites. - Emits kind, actionable errors to STDERR and returns non-zero on failure.

  1. Argument Parsing

- Prefer getopts for short flags. For long options, parse manually with a while loop; avoid getopt if portability is uncertain. - Populate variables for downstream logic (use ${VAR:-} to coexist with set -u).

  1. Main Logic

- Encapsulate primary workflow in main() and finish with main "$@".


Phase 3 · Compose the Script

Follow this recipe while writing the actual script content.

Required Guardrail: check_requirements

check_requirements() {
  local -r provided_arg_count=$1
  local missing=0

  if [ ${#REQUIRED_ARGS[@]} -gt 0 ] && [ "$provided_arg_count" -lt ${#REQUIRED_ARGS[@]} ]; then
    printf 'Error: Expected %s arguments (%s) but received %s.\n' \
      ${#REQUIRED_ARGS[@]} "${REQUIRED_ARGS[*]}" "$provided_arg_count" >&2
    missing=1
  fi

  local env_var
  for env_var in "${REQUIRED_ENV_VARS[@]}"; do
    if [ -z "${!env_var:-}" ]; then
      printf 'Error: Missing required environment variable %s. Please set it before rerunning.\n' "$env_var" >&2
      missing=1
    fi
  done

  local program
  for program in "${REQUIRED_PROGRAMS[@]}"; do
    if ! command -v "$program" >/dev/null 2>&1; then
      printf 'Error: Required program %s is not installed or not on PATH. Please install it first.\n' "$program" >&2
      missing=1
    fi
  done

  if [ "$missing" -ne 0 ]; then
    printf '\n' >&2
    usage >&2
    return 1
  fi
}

Implementation notes:

  • Always invoke check_requirements right after argument parsing, e.g. check_requirements "$#".
  • If the script allows optional trailing arguments, keep REQUIRED_ARGS limited to the mandatory ones and validate optional parameters separately after check_requirements "$#" succeeds.
  • Keep error language supportive (“Please install…”) rather than punitive.
  • Route any diagnostics to STDERR (>&2) and exit gracefully with return 1 so the caller can exit 1 or handle it.
  • Only call usage from error paths (like failed requirement checks) so successful runs stay quiet unless the user explicitly asks for help.

Bash 3.2 Compatibility Guardrails

  • Use indexed arrays only; no associative arrays or namerefs (local -n).
  • Avoid [[string =~ regex]] with capture groups that rely on Bash ≥3.2. Basic regex is fine, but keep patterns simple.
  • Do not rely on mapfile, readarray, coproc, printf -v, or process substitution that requires /dev/fd (often missing on macOS).
  • Prefer $(command) subshells over backticks and quote every expansion.
  • Use printf instead of echo -e for reliable escape handling.

Usage Function Pattern

usage() {
  cat <<'EOF'
Usage: my_script.sh <source> <destination> [--dry-run]

Required arguments:
  source        Path to the input file (must exist)
  destination   Output directory (will be created if missing)

Environment variables:
  API_TOKEN     Token used to authenticate API requests

External tools:
  curl, jq

Examples:
  my_script.sh ./input.csv ./out --dry-run
EOF
}

Tailor the body to the specific script; keep instructions kind and explicit.

Script Assembly Checklist

  1. Write header, safety settings, and optional metadata comments.
  2. Define requirement arrays (even if empty) and defaults for optional values.
  3. Implement usage() and check_requirements() exactly once.
  4. Parse arguments safely (getopts or manual loop) and convert into named variables.
  5. Call check_requirements immediately after parsing. If it fails, exit with exit 1.
  6. Implement main() with clear, modular helpers; rely on functions instead of sprawling inline code.
  7. End with main "$@" and ensure the script returns appropriate exit codes.

Phase 4 · Validate, Format, and Hand Off

  1. Self-check

- Does the script run without arguments and show usage? - Do missing env vars and programs produce the friendly errors described earlier? - Do all branches respect set -euo pipefail (guard nullable variables with ${VAR:-})?

  1. Formatting via shfmt

- Detect availability: if command -v shfmt >/dev/null 2>&1; then... fi - Run shfmt -i 2 -bn -ci -sr -w <path-to-script> after writing the file. - Mention in your response whether formatting ran or was skipped (and why).

  1. Final Response Checklist

- Provide the complete script in a fenced code block (label it bash). - Summarize how requirements are enforced. - If manual formatting was necessary (no shfmt), note it explicitly. - Suggest any quick validation commands (dry runs, linting) if relevant.


Reference Template

Use this skeleton as a starting point and adapt each section based on the user's requirements:

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

# Script: <name>
# Purpose: <one-line description>
# Requirements: <short summary of args/env/programs>

REQUIRED_ARGS=("arg1" "arg2")
REQUIRED_ENV_VARS=("ENV_VAR")
REQUIRED_PROGRAMS=("curl" "jq")

usage() {
  cat <<'EOF'
Usage: <script-name> <arg1> <arg2>

Required arguments:
  arg1   <describe>
  arg2   <describe>

Environment variables:
  ENV_VAR   <describe>

External tools:
  curl, jq
EOF
}

check_requirements() {
  local -r provided_arg_count=$1
  local missing=0

  if [ ${#REQUIRED_ARGS[@]} -gt 0 ] && [ "$provided_arg_count" -lt ${#REQUIRED_ARGS[@]} ]; then
    printf 'Error: Expected %s arguments (%s) but received %s.\n' \
      ${#REQUIRED_ARGS[@]} "${REQUIRED_ARGS[*]}" "$provided_arg_count" >&2
    missing=1
  fi

  local env_var
  for env_var in "${REQUIRED_ENV_VARS[@]}"; do
    if [ -z "${!env_var:-}" ]; then
      printf 'Error: Missing required environment variable %s. Please set it before rerunning.\n' "$env_var" >&2
      missing=1
    fi
  done

  local program
  for program in "${REQUIRED_PROGRAMS[@]}"; do
    if ! command -v "$program" >/dev/null 2>&1; then
      printf 'Error: Required program %s is not installed or not on PATH. Please install it first.\n' "$program" >&2
      missing=1
    fi
  done

  if [ "$missing" -ne 0 ]; then
    printf '\n' >&2
    usage >&2
    return 1
  fi
}

parse_args() {
  # TODO: replace with real parsing
  SOURCE=${1:-}
  DEST=${2:-}
}

main() {
  parse_args "$@"
  check_requirements "$#" || exit 1

  # TODO: script logic goes here
  printf 'Running with source=%s dest=%s\n' "$SOURCE" "$DEST"
}

main "$@"

Update placeholders, replace TODO sections, and adjust arrays when a requirement does not apply (leave the array empty—do not delete it).


Quality Checklist Before Finishing

  • Script declares all requirement arrays and the check_requirements function
  • Error messages are friendly, specific, and routed to STDERR
  • Script avoids Bash ≥4 features and has been reviewed for 3.2 compatibility
  • usage() accurately reflects arguments, env vars, and dependencies
  • Formatting completed with shfmt (or explicitly noted why it was skipped)
  • Final response contains both summary guidance and the full script for copy/paste

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

Claude Code

28.36%
按下载量换算29

windsurf

24.38%
按下载量换算25

OpenCode

17.9%
按下载量换算18

Codex

12.83%
按下载量换算13

Gemini CLI

8.51%
按下载量换算9

Cursor

4.08%
按下载量换算4

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills