agentleFS
mylee04mylee04/code-notify/.claude/skills/shell-scripting/SKILL.md

shell-scripting

Skill288 starsChanged 9 months agoMITView on GitHub

Shell scripting best practices for cross-platform CLI tools

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All functions use local variables

    line 212
  2. Distinctive:

    All variables are quoted

    line 213

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shell Scripting Standards

When to Use

  • Writing new shell scripts
  • Refactoring existing scripts
  • Adding new functions

Script Structure

1. File Header

#!/bin/bash

# Script description
# https://github.com/mylee04/code-notify

set -e  # Exit on error

2. Constants (UPPER_CASE)

VERSION="1.2.0"
CONFIG_DIR="$HOME/.claude"
DEFAULT_SOUND="Glass"

3. Functions (snake_case)

# Description of function
# Arguments: $1 = name, $2 = optional value
function_name() {
    local name="$1"
    local value="${2:-default}"

    # Function body
}

4. Main Logic

# Main execution
main() {
    validate_args "$@"
    do_work
    cleanup
}

main "$@"

Best Practices

Variable Handling

# Good - quoted variables
echo "$message"
path="$HOME/.config"

# Bad - unquoted
echo $message
path=$HOME/.config

Conditionals

# Good - double brackets
if [[ -n "$var" ]]; then
    echo "not empty"
fi

# Bad - single brackets
if [ -n "$var" ]; then
    echo "not empty"
fi

Command Existence Check

# Good
if command -v terminal-notifier &> /dev/null; then
    terminal-notifier -message "Hello"
fi

# Bad
if which terminal-notifier; then
    terminal-notifier -message "Hello"
fi

Error Handling

# Good - explicit error handling
if ! some_command; then
    echo "Error: command failed" >&2
    exit 1
fi

# Good - trap for cleanup
cleanup() {
    rm -f "$temp_file"
}
trap cleanup EXIT

Local Variables in Functions

# Good
my_function() {
    local input="$1"
    local result
    result=$(process "$input")
    echo "$result"
}

# Bad - pollutes global scope
my_function() {
    input="$1"
    result=$(process "$input")
    echo "$result"
}

Common Patterns

OS Detection

detect_os() {
    case "$(uname -s)" in
        Darwin*)    echo "macos" ;;
        Linux*)     echo "linux" ;;
        CYGWIN*|MINGW*|MSYS*) echo "windows" ;;
        *)          echo "unknown" ;;
    esac
}

Safe File Operations

# Create directory if not exists
mkdir -p "$dir"

# Safe file reading
if [[ -f "$config_file" ]]; then
    config=$(cat "$config_file")
fi

# Atomic write
echo "$content" > "$file.tmp" && mv "$file.tmp" "$file"

JSON Handling (without jq)

# Simple grep-based check
if grep -q '"enabled":\s*true' "$file"; then
    echo "enabled"
fi

# With jq (if available)
if command -v jq &> /dev/null; then
    value=$(jq -r '.key' "$file")
fi

Testing

Test Function Output

test_detect_os() {
    result=$(detect_os)
    if [[ "$result" != "macos" ]] && [[ "$result" != "linux" ]]; then
        echo "FAIL: unexpected OS: $result"
        return 1
    fi
    echo "PASS"
}

Test Exit Codes

test_error_handling() {
    if invalid_command 2>/dev/null; then
        echo "FAIL: should have failed"
        return 1
    fi
    echo "PASS"
}

Success Metrics

  • shellcheck passes with no warnings
  • All functions use local variables
  • All variables are quoted
  • Commands existence checked before use
  • Error handling for all failure points

Download now (ZIP)

  • Other versions12 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 12

    1. DAAF-Contribution-Community/daaf★ 233same name
    2. sammcj/agentic-coding★ 164same name
    3. iuliandita/skills★ 10same name
    4. CodingKaiser/kaiser-skills★ 6same name
    5. ffsshhttiikk/opencode-agents-skills★ 2same name
    6. yuexueyu/anna-agent-skills★ 2same name
    7. albertdobmeyer/openskill-forge★ 1same name
    8. AntheaLaffy/the-missing-semester-skills★ 1same name
    9. 2867203296/hermes-agent★ 0same name
    10. Abdox-menara/guard-skills★ 0same name

    2 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use ci-cd, testing and 1 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • JohnJBorenSkill

      ci-cd

      CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

      Also in 3 projects that use this

    • NVIDIASkill

      testing

      Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.

      Also in 3 projects that use this

    • GoogleSkill

      code-review

      Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

      Also in 4 projects that use this

  • In this repositoryOne other file it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.