[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FEHSRAGK9G6DQ75YRY1398":3,"skill-same:01M6FEHSRAGK9G6DQ75YRY1398":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M6FEHSRAGK9G6DQ75YRY1398","shell",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fpproenca\u002Fdot-skills\u002Fshell\u002FSKILL.md",[],[5],"2026-11-10 10:12:30",false,"# Shell Scripts Best Practices (Community)\n\nComprehensive best practices guide for shell scripting, designed for AI agents and LLMs. Contains 49 rules across 9 categories, prioritized by impact from critical (safety, portability) to incremental (style). Each rule includes detailed explanations, real-world examples comparing incorrect vs. correct implementations, and specific impact metrics.\n\n## When to Apply\n\nReference these guidelines when:\n- Writing new bash or POSIX shell scripts\n- Reviewing shell scripts for security vulnerabilities\n- Debugging scripts that fail silently or behave unexpectedly\n- Porting scripts between Linux, macOS, and containers\n- Optimizing shell script performance\n- Setting up CI\u002FCD pipelines with shell scripts\n\n## Rule Categories by Priority\n\n| Priority | Category | Impact | Prefix | Rules |\n|----------|----------|--------|--------|-------|\n| 1 | Safety & Security | CRITICAL | `safety-` | 6 |\n| 2 | Portability | CRITICAL | `port-` | 5 |\n| 3 | Error Handling | HIGH | `err-` | 8 |\n| 4 | Variables & Data | HIGH | `var-` | 5 |\n| 5 | Quoting & Expansion | MEDIUM-HIGH | `quote-` | 6 |\n| 6 | Functions & Structure | MEDIUM | `func-` | 5 |\n| 7 | Testing & Conditionals | MEDIUM | `test-` | 5 |\n| 8 | Performance | LOW-MEDIUM | `perf-` | 6 |\n| 9 | Style & Formatting | LOW | `style-` | 3 |\n\n## Quick Reference\n\n### 1. Safety & Security (CRITICAL)\n\n- [`safety-command-injection`](references\u002Fsafety-command-injection.md) - Prevent command injection from user input\n- [`safety-eval-avoidance`](references\u002Fsafety-eval-avoidance.md) - Avoid eval for dynamic commands\n- [`safety-absolute-paths`](references\u002Fsafety-absolute-paths.md) - Use absolute paths for external commands\n- [`safety-temp-files`](references\u002Fsafety-temp-files.md) - Create secure temporary files\n- [`safety-suid-forbidden`](references\u002Fsafety-suid-forbidden.md) - Never use SUID\u002FSGID on shell scripts\n- [`safety-argument-injection`](references\u002Fsafety-argument-injection.md) - Prevent argument injection with double dash\n\n### 2. Portability (CRITICAL)\n\n- [`port-shebang-selection`](references\u002Fport-shebang-selection.md) - Choose shebang based on portability needs\n- [`port-avoid-bashisms`](references\u002Fport-avoid-bashisms.md) - Avoid bashisms in POSIX scripts\n- [`port-printf-over-echo`](references\u002Fport-printf-over-echo.md) - Use printf instead of echo for portability\n- [`port-export-syntax`](references\u002Fport-export-syntax.md) - Use portable export syntax\n- [`port-test-portability`](references\u002Fport-test-portability.md) - Use portable test constructs\n\n### 3. Error Handling (HIGH)\n\n- [`err-strict-mode`](references\u002Ferr-strict-mode.md) - Use strict mode for error detection\n- [`err-exit-codes`](references\u002Ferr-exit-codes.md) - Use meaningful exit codes\n- [`err-trap-cleanup`](references\u002Ferr-trap-cleanup.md) - Use trap for cleanup on exit\n- [`err-stderr-messages`](references\u002Ferr-stderr-messages.md) - Send error messages to stderr\n- [`err-pipefail`](references\u002Ferr-pipefail.md) - Use pipefail to catch pipeline errors\n- [`err-check-commands`](references\u002Ferr-check-commands.md) - Check command success explicitly\n- [`err-shellcheck`](references\u002Ferr-shellcheck.md) - Use ShellCheck for static analysis\n- [`err-debug-tracing`](references\u002Ferr-debug-tracing.md) - Use debug tracing with set -x and PS4\n\n### 4. Variables & Data (HIGH)\n\n- [`var-use-arrays`](references\u002Fvar-use-arrays.md) - Use arrays for lists instead of strings\n- [`var-local-scope`](references\u002Fvar-local-scope.md) - Use local for function variables\n- [`var-naming-conventions`](references\u002Fvar-naming-conventions.md) - Follow variable naming conventions\n- [`var-readonly-constants`](references\u002Fvar-readonly-constants.md) - Use readonly for constants\n- [`var-default-values`](references\u002Fvar-default-values.md) - Use parameter expansion for defaults\n\n### 5. Quoting & Expansion (MEDIUM-HIGH)\n\n- [`quote-always-quote-variables`](references\u002Fquote-always-quote-variables.md) - Always quote variable expansions\n- [`quote-dollar-at`](references\u002Fquote-dollar-at.md) - Use \"$@\" for argument passing\n- [`quote-command-substitution`](references\u002Fquote-command-substitution.md) - Quote command substitutions\n- [`quote-brace-expansion`](references\u002Fquote-brace-expansion.md) - Use braces for variable clarity\n- [`quote-here-documents`](references\u002Fquote-here-documents.md) - Use here documents for multi-line strings\n- [`quote-glob-safety`](references\u002Fquote-glob-safety.md) - Control glob expansion explicitly\n\n### 6. Functions & Structure (MEDIUM)\n\n- [`func-main-pattern`](references\u002Ffunc-main-pattern.md) - Use main() function pattern\n- [`func-single-purpose`](references\u002Ffunc-single-purpose.md) - Write single-purpose functions\n- [`func-return-values`](references\u002Ffunc-return-values.md) - Use return values correctly\n- [`func-documentation`](references\u002Ffunc-documentation.md) - Document functions with header comments\n- [`func-avoid-aliases`](references\u002Ffunc-avoid-aliases.md) - Prefer functions over aliases\n\n### 7. Testing & Conditionals (MEDIUM)\n\n- [`test-double-brackets`](references\u002Ftest-double-brackets.md) - Use [[ ]] for tests in bash\n- [`test-arithmetic`](references\u002Ftest-arithmetic.md) - Use (( )) for arithmetic comparisons\n- [`test-explicit-empty`](references\u002Ftest-explicit-empty.md) - Use explicit empty\u002Fnon-empty string tests\n- [`test-file-operators`](references\u002Ftest-file-operators.md) - Use correct file test operators\n- [`test-case-patterns`](references\u002Ftest-case-patterns.md) - Use case for pattern matching\n\n### 8. Performance (LOW-MEDIUM)\n\n- [`perf-builtins-over-external`](references\u002Fperf-builtins-over-external.md) - Use builtins over external commands\n- [`perf-avoid-subshells`](references\u002Fperf-avoid-subshells.md) - Avoid unnecessary subshells\n- [`perf-process-substitution`](references\u002Fperf-process-substitution.md) - Use process substitution for temp files\n- [`perf-read-files`](references\u002Fperf-read-files.md) - Read files efficiently\n- [`perf-parameter-expansion`](references\u002Fperf-parameter-expansion.md) - Use parameter expansion for string operations\n- [`perf-batch-operations`](references\u002Fperf-batch-operations.md) - Batch operations instead of loops\n\n### 9. Style & Formatting (LOW)\n\n- [`style-indentation`](references\u002Fstyle-indentation.md) - Use consistent indentation\n- [`style-file-structure`](references\u002Fstyle-file-structure.md) - Follow consistent file structure\n- [`style-comments`](references\u002Fstyle-comments.md) - Write useful comments\n\n\n## How to Use\n\nRead individual reference files for detailed explanations and code examples:\n\n- [Section definitions](references\u002F_sections.md) - Category structure and impact levels\n- [Rule template](assets\u002Ftemplates\u002F_template.md) - Template for adding new rules\n\n## Reference Files\n\n| File | Description |\n|------|-------------|\n| [AGENTS.md](AGENTS.md) | Complete compiled guide with all rules |\n| [references\u002F_sections.md](references\u002F_sections.md) | Category definitions and ordering |\n| [assets\u002Ftemplates\u002F_template.md](assets\u002Ftemplates\u002F_template.md) | Template for new rules |\n| [metadata.json](metadata.json) | Version and reference information |\n\n## Key Sources\n\n- [Google Shell Style Guide](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fshellguide.html)\n- [ShellCheck](https:\u002F\u002Fwww.shellcheck.net\u002F)\n- [Greg's Wiki (wooledge.org)](https:\u002F\u002Fmywiki.wooledge.org\u002F)\n- [POSIX Shell Specification](https:\u002F\u002Fpubs.opengroup.org\u002Fonlinepubs\u002F9699919799\u002Futilities\u002FV3_chap02.html)\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fpproenca\u002Fdot-skills\u002Fshell",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill shell",{"tool":37,"command":38},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill shell",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill shell","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fpproenca\u002Fdot-skills\u002Fshell\u002FSKILL.md",true,[],[46,60,70,79,85,92],{"skillNo":47,"name":48,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":56,"publishedAt":18},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[51],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[57,58,59],"model","model hierarchy","model hierarchy skill",{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":66,"publishedAt":18},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[65],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[67,68,69],"MCP","zoom","zoom mcp",{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[76,77,78,68],"sdk","zoom apps sdk","apps",{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[81],{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":91,"publishedAt":18},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[90],{"categoryNo":52,"categoryName":53,"taxonomyType":54,"taxonomyTypeDesc":55},[87],{"skillNo":93,"name":94,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[94]]