shell

shell

Shell scripting best practices for writing safe, portable, and maintainable bash/sh scripts (formerly shell-scripts). Use when writing, reviewing, or refactoring shell scripts. Triggers on shell scripts, bash, sh, POSIX, ShellCheck, error handling, quoting, variables.

5星標
0分支
更新於 1/24/2026
SKILL.md
readonlyread-only
name
shell
description

Shell scripting best practices for writing safe, portable, and maintainable bash/sh scripts (formerly shell-scripts). Use when writing, reviewing, or refactoring shell scripts. Triggers on shell scripts, bash, sh, POSIX, ShellCheck, error handling, quoting, variables.

Shell Scripts Best Practices

Comprehensive best practices guide for shell scripting, designed for AI agents and LLMs. Contains 48 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.

When to Apply

Reference these guidelines when:

  • Writing new bash or POSIX shell scripts
  • Reviewing shell scripts for security vulnerabilities
  • Debugging scripts that fail silently or behave unexpectedly
  • Porting scripts between Linux, macOS, and containers
  • Optimizing shell script performance
  • Setting up CI/CD pipelines with shell scripts

Rule Categories by Priority

Priority Category Impact Prefix Rules
1 Safety & Security CRITICAL safety- 6
2 Portability CRITICAL port- 5
3 Error Handling HIGH err- 6
4 Variables & Data HIGH var- 5
5 Quoting & Expansion MEDIUM-HIGH quote- 6
6 Functions & Structure MEDIUM func- 5
7 Testing & Conditionals MEDIUM test- 5
8 Performance LOW-MEDIUM perf- 6
9 Style & Formatting LOW style- 4

Quick Reference

1. Safety & Security (CRITICAL)

2. Portability (CRITICAL)

3. Error Handling (HIGH)

4. Variables & Data (HIGH)

5. Quoting & Expansion (MEDIUM-HIGH)

6. Functions & Structure (MEDIUM)

7. Testing & Conditionals (MEDIUM)

8. Performance (LOW-MEDIUM)

9. Style & Formatting (LOW)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

File Description
AGENTS.md Complete compiled guide with all rules
references/_sections.md Category definitions and ordering
assets/templates/_template.md Template for new rules
metadata.json Version and reference information

Key Sources

You Might Also Like

Related Skills

coding-agent

coding-agent

179Kdev-codegen

Run Codex CLI, Claude Code, OpenCode, or Pi Coding Agent via background process for programmatic control.

openclaw avataropenclaw
獲取
add-uint-support

add-uint-support

97Kdev-codegen

Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.

pytorch avatarpytorch
獲取
at-dispatch-v2

at-dispatch-v2

97Kdev-codegen

Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.

pytorch avatarpytorch
獲取
skill-writer

skill-writer

97Kdev-codegen

Guide users through creating Agent Skills for Claude Code. Use when the user wants to create, write, author, or design a new Skill, or needs help with SKILL.md files, frontmatter, or skill structure.

pytorch avatarpytorch
獲取

Implements JavaScript classes in C++ using JavaScriptCore. Use when creating new JS classes with C++ bindings, prototypes, or constructors.

oven-sh avataroven-sh
獲取

Creates JavaScript classes using Bun's Zig bindings generator (.classes.ts). Use when implementing new JS APIs in Zig with JSC integration.

oven-sh avataroven-sh
獲取