shellcheck-configuration
配置 ShellCheck 以實現可靠的 Shell 靜態分析
Shell 指令碼問題隱藏到正式環境才浮現,拖慢程式碼審查。本技能說明 ShellCheck 的設定、規則配置和整合工作流程,協助您在合併前發現問題。
Télécharger le ZIP du skill
Importer dans Claude
Allez dans Paramètres → Capacités → Skills → Importer un skill
Activez et commencez à utiliser
Tester
Utilisation de "shellcheck-configuration". I need help understanding SC2086 and how to fix it
Résultat attendu:
- SC2086 是未引用變數展開警告
- 透過引用變數或使用陣列語法來修正
- 範例:將 'for i in $list' 改為 'for i in "$list"' 或 'for i in "${list[@]}"'
Utilisation de "shellcheck-configuration". Create a .shellcheckrc for a Bash project
Résultat attendu:
- 設定 shell=bash 進行 Bash 方言分析
- 啟用可選檢查,例如 require-variable-braces
- 停用 SC1091 針對可能不存在的已載入檔案
- 為每個停用的代碼加上註解,說明停用原因
Audit de sécurité
SûrPure documentation skill containing only markdown guidance for ShellCheck, a legitimate open-source static analysis tool. All static findings are false positives. References like SC2009, SC2086 are ShellCheck error codes (not C2 keywords), sha256sum is appropriate for caching (not weak crypto), and shell examples are documentation (not malicious patterns).
Facteurs de risque
🌐 Accès réseau (5)
⚙️ Commandes externes (72)
📁 Accès au système de fichiers (5)
Score de qualité
Ce que vous pouvez construire
新增 CI shell 靜態分析
在 CI Pipeline 中設定 ShellCheck,使用一致的標誌和失敗規則。
修正常見警告
了解關鍵的 ShellCheck 代碼,並應用更安全的引用和流程模式。
標準化靜態分析規則
定義共用的 .shellcheckrc 設定和已記錄的隱藏原則。
Essayez ces prompts
說明如何安裝 ShellCheck 並對單一指令碼執行它。包括在 Ubuntu 上安裝的範例命令,以及對 Bash 檔案執行檢查的範例。
為 Bash 指令碼起草一個 .shellcheckrc,啟用一些檢查並停用兩個代碼。說明每個設定。
提供一個最小的 GitHub Actions 步驟,安裝 ShellCheck 並對所有 .sh 檔案執行檢查,在出現警告時失敗。
展示如何在 Shell 指令碼中隱藏 SC1091 和 SC2119,並記錄每個隱藏為何是安全的。
Bonnes pratiques
- 在靜態分析前明確設定目標 Shell,以符合您的部署環境
- 為每個隱藏的代碼加上註解,說明理由
- 在 pre-commit 勾子和 CI 中執行 ShellCheck,以實現早期本地和遠端偵測
Éviter
- 廣泛停用警告,而不對每個代碼提供具體理由
- 將 Bash 指令碼當作 POSIX sh 靜態分析,而不了解相容性需求
- 忽略 CI 中的 ShellCheck 失敗或覆蓋退出碼而不進行審查
Foire aux questions
這與 Bash 和 POSIX sh 相容嗎?
此技能的限制是什麼?
它可以與 CI 系統整合嗎?
它會存取我的檔案或憑證嗎?
如果 ShellCheck 報告太多警告怎麼辦?
它與一般靜態分析工具相比如何?
Détails du développeur
Auteur
wshobsonLicence
MIT
Dépôt
https://github.com/wshobson/agents/tree/main/plugins/shell-scripting/skills/shellcheck-configurationRéf
main
Structure de fichiers
📄 SKILL.md