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

coding-guidance-bash编码指导 bash

Agent Skill

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

总安装

233

周安装

10

GitHub Stars

3

下载量

82
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/n-n-code/n-n-code-skills --skill coding-guidance-bash

简介

coding-guidance-bash 提供便携式 Bash 脚本编写、重构与安全审查指导,适配 POSIX 兼容环境。

  • 可与 thinking、security 等流程技能组合,增强脚本健壮性与威胁建模能力。
  • 避免使用 Bash 专属语法,必要时降级为 sh 兼容写法以确保最大可移植性。
  • 使用前请评估目标系统 shell 类型,防止因解释器差异导致命令失效或安全风险。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Bash Coding Guidance

This skill adds portable Bash implementation, refactoring, and review guidance.

Adjacent Skills

This skill provides portable Bash engineering principles. Compose with:

  • Workflow: thinking (planning), recursive-thinking (stress-testing), security (threat modeling)
  • Domain overlays: project-core-dev (repo-specific build/test commands), project-platform-diagnose (environment-sensitive diagnosis)

When Not to Lean on This Skill

  • non-shell work
  • POSIX sh portability work where Bash-only features are not allowed (adapt the guidance to the repo's POSIX-shell contract instead of importing Bash-only defaults)
  • large data processing jobs that should realistically move to Python, awk, or another language with stronger structure

Implementation Workflow

  1. Read the touched scripts, entrypoints, call sites, and nearby docs before editing.
  2. Infer the intended contract from current usage text, flags, tests, and environment assumptions. Ask only when multiple plausible script behaviors would change semantics.
  3. Keep the contract narrow: inputs, outputs, exit codes, environment dependencies, filesystem effects, and external tool requirements should be explicit.
  4. Implement with defensive mode, safe quoting, arrays for argv construction, functions for meaningful substeps, and cleanup traps for temporary state.
  5. Add or update shell tests when the repo has them; otherwise add the smallest reproducible validation path you can run directly.
  6. Run the narrowest relevant formatter, linter, and script tests the repo supports.

Refactoring Workflow

Use this instead of the default implementation workflow when the task is primarily cleanup or restructuring:

  1. Capture current behavior, flags, environment assumptions, platform dependencies, and failure modes.
  2. Break the refactor into small slices that preserve behavior.
  3. Replace copy-pasted command assembly, hidden globals, unsafe loops, and tangled control flow one step at a time.
  4. Keep tests or runnable validation passing after each slice; add characterization coverage first when behavior is unclear.
  5. Stop when the script is easier to read, safer to invoke, and easier to debug.

Review Workflow

When reviewing (not implementing), skip the implementation workflow and use this instead:

  1. Read the change in full before commenting.
  2. Identify findings, ordered by severity: Critical > Important > Suggestion.
  3. Prioritize quoting and word-splitting bugs, globbing hazards, accidental masking of failing commands, trap and cleanup bugs, unsafe temp-file handling, destructive command risks, portability mismatches, environment assumptions, and missing tests.
  4. State findings with concrete evidence and the likely consequence.

Bash Rules

First tier - causes bugs

  • Start executable Bash scripts with #!/usr/bin/env bash unless the repo has a stricter shebang convention
  • Use set -Eeuo pipefail unless the script has a documented reason to manage failures differently; scope exceptions narrowly
  • Quote expansions by default: "$var", "${arr[@]}", and "$(cmd)"
  • Use arrays for argument vectors; do not build command lines with string concatenation
  • Distinguish stdout data from stderr diagnostics so callers can compose the script safely
  • Check exit statuses deliberately; do not rely on pipelines, subshells, or command substitutions without understanding how failures propagate
  • Clean up temp files and directories with trap when the script allocates them
  • Treat $IFS, globs, current working directory, and environment variables as boundary conditions, not stable ambient assumptions

Second tier - prevents mistakes

  • Prefer functions for meaningful units of behavior; keep top-level script flow readable
  • Use local inside functions unless a variable is intentionally shared
  • Prefer [[...]] for Bash conditionals and case for multi-branch string matching
  • Prefer printf over echo when escaping, flags, or portability ambiguity matter
  • Use command substitution $() instead of backticks
  • Name flags, env vars, and functions for what they do; shell scripts become unreadable quickly when names get vague
  • Keep shellcheck findings at zero in repo-owned code unless the script has a documented exception

Defensive patterns

  • Consider shopt -s inherit_errexit when the Bash version and repo contract allow it and command-substitution failures must propagate cleanly
  • Validate required env vars explicitly with : "${VAR:?message}"
  • Detect missing external tools up front with command -v tool >/dev/null 2>&1
  • Use mktemp for temp files and directories; never hand-roll temp paths in shared locations
  • Prefer dry-run modes and idempotent behavior before destructive or expensive operations
  • Use trap for cleanup and, when helpful, targeted ERR reporting with line or function context

Command and process discipline

  • Pass user-controlled values as individual argv elements, not through eval or re-parsed strings
  • Avoid eval unless the script is explicitly a shell metaprogramming tool and the risk is justified
  • Prefer explicit path resolution and file existence checks before destructive operations
  • When calling external tools, preserve argument boundaries and treat tool exit codes as part of the contract
  • Be deliberate about cd; either scope it to a subshell or restore the prior directory clearly
  • End option parsing with -- when forwarding user arguments to external commands
  • If the script spawns background jobs, make ownership explicit: track PIDs, aggregate wait results deliberately, and forward or handle termination signals rather than abandoning children
  • Avoid casual parallel destructive work; if concurrency matters, define the locking, isolation, or idempotency rule up front
  • If concurrent invocations can interfere with each other, use an explicit lock strategy such as flock or a documented equivalent instead of hoping paths or timing stay unique

Input, output, and contract design

  • Provide --help or usage text for non-trivial scripts
  • Make required env vars, positional args, flags, and side effects explicit near the top of the file
  • Exit with non-zero status on real failure and reserve zero for success
  • Print machine-consumable output in a stable format when other tools are meant to parse it
  • Avoid silent fallbacks on missing tools or files unless the script is explicitly best-effort
  • Use stable exit-code meanings when the script is likely to be called by other automation

Safe iteration and file handling

  • Prefer while IFS= read -r line; do...; done over loops that split on whitespace implicitly
  • Use NUL-safe patterns for filenames from find, git, or similar tools: -print0, xargs -0, or read -r -d ''
  • Use readarray or mapfile when populating arrays from command output in Bash-specific scripts
  • Avoid for f in $(...) for filenames or untrusted data; it is usually a bug
  • Prefer built-ins and parameter expansion over unnecessary subprocesses when they make the script clearer and safer

Portability and platform fit

  • Use Bash-specific features only when the shebang and repo contract allow them
  • If the script must run on multiple platforms, check GNU vs. BSD tool differences before adding flags with inconsistent behavior
  • If platform behavior matters, detect it explicitly instead of assuming Linux
  • Prefer the repo's existing helper scripts and path conventions over ad hoc temp locations or duplicated wrappers
  • Move non-trivial parsing, JSON handling, or data shaping to a better-suited language when shell stops being the clearest tool

Style, testing, and tooling

  • Prefer long, readable option names for user-facing interfaces when the repo does not already prescribe a short-only style
  • Keep functions small enough to understand locally; split when one function starts owning parsing, validation, execution, and reporting all at once
  • Run shellcheck and shfmt where the repo uses them
  • Prefer Bats or the repo's existing shell-test framework for non-trivial scripts
  • Document required tools and minimum Bash features when the script depends on them

Decision Heuristics

Use these when the right choice is not obvious:

  • Language fit: if the task needs nested data structures, complex parsing, or large in-memory transforms, shell may be the wrong tool.
  • Quoting pressure: if command construction becomes hard to reason about, switch to arrays or redesign the interface before adding more flags.
  • Failure visibility: if set -e behavior is unclear in a construct, make the check explicit rather than assuming the shell will fail the right way.
  • Process ownership: if the script backgrounds work, define who waits, cleans up, and reports failures before adding more parallelism.
  • Portability pressure: if a script relies on GNU-only flags, a Bash 5.x feature, or OS-specific tools, document and validate that boundary instead of hiding it.
  • Repo conventions: if the repo has established patterns for shebangs, strict mode, shellcheck, shfmt, or helper libraries, follow them unless they create a correctness or safety problem.
  • Narrowness vs. quality: implement the narrowest change that solves the problem. When narrowness conflicts with correctness or safety, prefer correctness. When it conflicts with style alone, prefer narrowness unless the task is explicitly a cleanup.
  • Refactor boundary: outside explicit refactor work, fix at most one small adjacent issue while you are in the file.
  • Abstraction threshold: three similar command sequences or repeated flag parsing pain is a pattern; before extracting, check whether a function, a helper script, or a small move to another language is the simpler move.
  • External-tool boundary: if a script depends on jq, awk, sed, or platform-specific tooling, treat that dependency as part of the user-facing contract.

Validation

A change is done when:

  • shellcheck or the repo's equivalent linter reports no new findings
  • shell formatting is run when the repo has a formatter
  • changed --help, argument parsing, or top-level script startup paths are smoke-tested before deeper functional validation
  • existing shell tests pass
  • new or changed behavior has test coverage, or the lack of coverage is called out with a concrete reason
  • non-trivial scripts have a direct smoke path such as --help or a minimal fixture invocation
  • destructive or environment-mutating paths were verified against a safe test fixture rather than assumed correct
  • portability-sensitive changes were tested on the affected platform or the remaining platform risk was called out explicitly
  • review findings at Critical and Important severity are addressed

Examples

  • Review this Bash deploy script for quoting, traps, and rollback safety
  • Refactor this repo automation script to use arrays, safe temp files, and better argument parsing

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.42%
按下载量换算29

Claude

29.31%
按下载量换算24

Cursor

19.36%
按下载量换算16

Gemini CLI

8.66%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

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

安装前确认

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

来源信息

继续浏览同类 Skills