plugins/languages/bash/skills/tooling/SKILL.md
Bash tooling chain: ShellCheck (SC codes & suppressions), shfmt (formatting style), bash-language-server LSP, bashdb / bash -x tracing, pre-commit hooks, editor integration, and shell linting in CI. Use when setting up project quality gates, configuring editors, or upgrading existing scripts to meet modern standards. Triggers on "shellcheck 配置", "shfmt 格式", "bash LSP", "shell 预提交", ".shellcheckrc", "shell 编辑器".
npx skillsauth add lazygophers/ccplugin bash-toolingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| 工具 | 角色 | 安装 |
|------|------|------|
| shellcheck | 静态检查 | brew install shellcheck / apt install shellcheck |
| shfmt | 格式化 | brew install shfmt / go install mvdan.cc/sh/v3/cmd/shfmt@latest |
| bash-language-server | LSP | npm i -g bash-language-server |
| bats-core | 测试 | brew install bats-core |
| kcov | 覆盖率 | brew install kcov / apt install kcov |
| bashdb | 交互调试 | brew install bashdb |
.shellcheckrc(项目根)# 启用所有可选检查
enable=all
# 关闭:本项目允许
disable=SC2086 # 字段分割(在确实需要展开时手动 disable)
# 默认 shell
shell=bash
# 允许 source 跟随
external-sources=true
# shellcheck shell=bash
# shellcheck source=lib/util.sh
. "$(dirname "$0")/lib/util.sh"
# 单行抑制(附理由)
# shellcheck disable=SC2086 # intentional word splitting
cmd $args
| SC | 含义 | 修法 |
|----|------|------|
| SC2086 | 未引号变量 | "${var}" |
| SC2155 | declare + 赋值掩盖退出码 | 分两行 |
| SC2164 | cd 未检查失败 | cd foo \|\| exit |
| SC2317 | 不可达代码(trap 误判) | 加注释或 disable |
| SC1091 | source 文件未找到 | 加 # shellcheck source=path |
| SC2046 | $(cmd) 未引号 | "$(cmd)" |
| SC2207 | 数组从命令读取 | 用 mapfile -t |
| SC2250 | ${var} 推荐 | 始终用大括号 |
shfmt -i 4 -ci -bn -sr -d script.sh
| 选项 | 含义 |
|------|------|
| -i 4 | 缩进 4 空格 |
| -ci | switch case 缩进 |
| -bn | 二元运算换行前置 |
| -sr | redirect 操作符后留空格 |
| -d | 显示 diff(不修改) |
| -w | 原地写入 |
.editorconfig[*.{sh,bash,bats}]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
~/.config/<editor>/lsp.json(VSCode / Neovim / Helix):
VSCode 装 mads-hartmann.bash-ide-vscode;Neovim 用 nvim-lspconfig 注册 bashls。
# 内置 trace
bash -x script.sh # 全程展开
PS4='+ ${BASH_SOURCE}:${LINENO}: ' # 更友好的 trace 前缀
set -x # 脚本内开启
set +x # 关闭
# bashdb 交互
bashdb script.sh
# (bashdb) break 42
# (bashdb) run
# (bashdb) step / next / print var
# VS Code Bash Debug 扩展(基于 bashdb)
.pre-commit-config.yaml:
repos:
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
args: ["-x"]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt
args: ["-i", "4", "-ci", "-w"]
- repo: https://github.com/bats-core/bats-core
rev: v1.11.0
hooks:
- id: bats
files: \.bats$
# .github/workflows/shell.yml
name: shell-quality
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@master
with:
severity: warning
check_together: 'yes'
- name: shfmt check
uses: mfinelli/setup-shfmt@v3
- run: shfmt -d -i 4 -ci .
project/
├── .shellcheckrc
├── .editorconfig
├── .pre-commit-config.yaml
├── .github/workflows/shell.yml
├── bin/ # 可执行脚本
├── lib/ # 被 source 的库 (.sh)
├── tests/ # bats 测试
└── Makefile
Makefile 入口:
.PHONY: lint fmt test cov
lint:
shellcheck bin/* lib/*.sh
fmt:
shfmt -i 4 -ci -w bin/ lib/
test:
bats --recursive tests/
cov:
kcov --include-pattern=.sh coverage bats tests/
.shellcheckrc 已配置(shell + 例外)shfmt -d 零 diffshellcheck 零警告(warning 级以上)tools
UI/UX 与布局设计——做界面布局/结构/导航/组件/交互的设计决策。触发:做UI/UX/布局/排版/导航/组件/交互/栅格/响应式/图表选型/字体配对。按媒介路由 HTML/Web、原生 App(iOS/Android/桌面)、CLI、TUI。需后端动态系统不适用;配色/主题/色板走姊妹 skill design-color。
tools
主题与配色设计——做颜色搭配/调色板/主题/品牌色阶/暗模式的设计决策。触发:选配色/调色/主题/色板/品牌色/暗模式/对比度/色盲/UI风格。按媒介路由 HTML/Web(CSS变量)、原生App(平台token)、CLI(ANSI)、TUI(真彩/256/16降级)。保证可访问性(对比度/色盲安全)。需后端动态系统不适用;UI/UX 布局/组件/交互走姊妹 skill design-uiux。
tools
跨任意组件(plugin/skill/agent/command)的验证驱动优化循环纪律 skill。当用户要优化某个已有组件却无明确方向、或要防止改了反而更差(自评乐观偏差 / 多维同改归因失效 / 为凑分加废话膨胀)、或要把一套通用「评分→单变量改→改后验证严格更好才留否则回滚→触顶停」的纪律套到任意组件上时使用。管优化过程本身的纪律(validation gate / ratchet / 独立验证 / 触顶停),不评单组件深度(交 skill-dev),不查插件接线(交 plugin-dev)。仅手动 /optimize-any 触发。
data-ai
两层规则记忆 (基于 .skein/spec)。planning 时 recall 召回相关规则、task finish 后 sediment 沉淀学习 + prune 自动精简过期/重复/断链规则。core 常驻硬规 + recall 按需召回, 经判定门自动写盘 (不逐次问用户)。产出 .skein/spec 下 core/recall 规则文件 + index。另支持空仓 bootstrap 播种规则基线、记忆大面积失效 (大重构/换栈) 时 reconstruct 可逆归档后按项目类型分型重建、maintain 手动体检 (超预算/stale/断链/重复/废弃, --apply 自动修复)、auto-fix (Stop hook 写 .pending-fix 标记 → main 派 skein-specer bg 跑 maintain --apply 全自动修, 断链只报告)。