shellcheck-configuration
它能做什么
这篇指南教你如何使用 ShellCheck 查找脚本中的错误,提升脚本代码的质量。它能帮助你确保脚本在不同环境中都能运行良好。
适用场景
- ✓当你搭建自动检查脚本的工具时。
- ✓当你想修复现有脚本中的问题时。
- ✓当你想理解 ShellCheck 给出的警告和错误时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/shell-scripting/skills/shellcheck-configuration/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样设置 ShellCheck,才能在提交脚本之前自动检查它们?”
每周 5 个新技能,1 分钟读完。
工作原理
ShellCheck 不会运行你的脚本,而是直接分析脚本代码,查找那些常常会引发问题的写法。它会提醒你这些问题,方便你及时修改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
ShellCheck Configuration and Static Analysis
Comprehensive guidance for configuring and using ShellCheck to improve shell script quality, catch common pitfalls, and enforce best practices through static code analysis.
When to Use This Skill
- Setting up linting for shell scripts in CI/CD pipelines
- Analyzing existing shell scripts for issues
- Understanding ShellCheck error codes and warnings
- Configuring ShellCheck for specific project requirements
- Integrating ShellCheck into development workflows
- Suppressing false positives and configuring rule sets
- Enforcing consistent code quality standards
- Migrating scripts to meet quality gates
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
- Run ShellCheck in CI/CD - Catch issues before merging
- Configure for your target shell - Don't analyze bash as sh
- Document exclusions - Explain why violations are suppressed
- Address violations - Don't just disable warnings
- Enable strict mode - Use
--enable=allwith careful exclusions - Update regularly - Keep ShellCheck current for new checks
- Use pre-commit hooks - Catch issues locally before pushing
- Integrate with editors - Get real-time feedback during development
常见问题
什么是“代码检查”(linting)?
代码检查是指在运行程序之前,分析代码以找出风格问题、潜在 bug 和其他隐患的过程。
为什么要为我使用的具体 Shell 配置 ShellCheck?
不同的 Shell(比如 bash 或 sh)规则略有不同。正确配置后,ShellCheck 就会按照你实际使用的 Shell 规则来检查脚本。
“屏蔽误报”是什么意思?
有时候 ShellCheck 会对某些实际上并不构成问题的写法发出警告。“屏蔽”就是告诉 ShellCheck 忽略这条特定警告,不过最好同时写明你这样做的原因。
详情
作者的原始描述
Master ShellCheck static analysis configuration and usage for shell script quality. Use when setting up linting infrastructure, fixing code issues, or ensuring script portability.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6785
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …