shell-scripting

shell-scripting is a skill for Claude Code, Codex from chaterm/terminal-skills. It costs 13 tokens per session (1,884 once invoked), scanned A, original, Apache-2.0.

A guide to writing Bash shell scripts, which automate command-line tasks on Linux and similar systems. It covers variables, arrays, conditions, loops, functions, and safer script structure.

In plain words
What is it for?
Use it to create scripts that set up environments, process files, repeat commands, make decisions, use arrays, and accept command-line arguments.
Why use it?
It provides common patterns for making scripts predictable and easier to debug. Strict mode and input handling can help reveal failures instead of silently continuing.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/chaterm/terminal-skills/shell-scripting
Any agent
npx skills add chaterm/terminal-skills --skill shell-scripting
Clone the repo
git clone --depth 1 https://github.com/chaterm/terminal-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for shell-scripting

README.md
[![agentmods](https://agentmods.dev/badge/skills/chaterm/terminal-skills/shell-scripting.svg)](https://agentmods.dev/skills/chaterm/terminal-skills/shell-scripting)
Your own site
<a href="https://agentmods.dev/skills/chaterm/terminal-skills/shell-scripting"><img src="https://agentmods.dev/badge/skills/chaterm/terminal-skills/shell-scripting.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,884 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00013 $0.01884
Opus 5 $0.00006 $0.00942
Sonnet 5 $0.00003 $0.00377
Haiku 4.5 $0.00001 $0.00188

Measured 5d ago against content hash 2875d42af1cf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

shell-scripting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

linux/shell-scripting/SKILL.md · 361 lines

How it starts

The opening of the file, as written. The whole thing — 361 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Shell 脚本编写

概述

Bash 脚本编写、调试、最佳实践等技能。

基础语法

脚本结构

#!/bin/bash
# 脚本描述
# Author: name
# Date: 2024-01-01

set -euo pipefail                   # 严格模式

# 变量定义
VAR="value"
readonly CONST="constant"

# 主逻辑
main() {
    echo "Hello, World!"
}

main "$@"

变量

# 定义变量
name="value"
name='literal value'                # 不解析变量

# 使用变量
echo $name
echo ${name}
echo "${name}_suffix"

# 默认值
${var:-default}                     # 未设置时使用默认值
${var:=default}                     # 未设置时赋值并使用
${var:+value}                       # 已设置时使用 value
${var:?error message}               # 未设置时报错

# 字符串操作
${#var}                             # 长度
${var:0:5}                          # 子串
${var#pattern}                      # 删除前缀
${var%pattern}                      # 删除后缀
${var/old/new}                      # 替换

数组

# 定义数组
arr=(a b c d)
arr[0]="first"

# 访问数组
${arr[0]}                           # 第一个元素
${arr[@]}                           # 所有元素
${#arr[@]}                          # 数组长度
${!arr[@]}                          # 所有索引

# 遍历数组
for item in "${arr[@]}"; do
    echo "$item"
done

流程控制

条件判断

# if 语句
if [[ condition ]]; then
    commands
elif [[ condition ]]; then
    commands
else
    commands
fi

# 条件表达式
[[ -f file ]]                       # 文件存在
[[ -d dir ]]                        # 目录存在
[[ -z "$var" ]]                     # 变量为空
[[ -n "$var" ]]                     # 变量非空
[[ "$a" == "$b" ]]                  # 字符串相等
[[ "$a" != "$b" ]]                  # 字符串不等
[[ $a -eq $b ]]                     # 数字相等
[[ $a -lt $b ]]                     # 小于
[[ $a -gt $b ]]                     # 大于

# 逻辑运算
[[ cond1 && cond2 ]]                # 与
[[ cond1 || cond2 ]]                # 或
[[ ! cond ]]                        # 非

循环

# for 循环
for i in 1 2 3 4 5; do
    echo $i
done

for i in {1..10}; do
    echo $i
done

for ((i=0; i<10; i++)); do
    echo $i
done

for file in *.txt; do
    echo "$file"
done

# while 循环
while [[ condition ]]; do
    commands
done

# 读取文件
while IFS= read -r line; do
    echo "$line"
done < file.txt

# until 循环
until [[ condition ]]; do
    commands
done

Read the full file on GitHub · 361 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 361 lines · 13 tokens per session scan A 2875d42af1cf

Subscribe to this mod's changes

shell-scripting is a skill published in the GitHub repository chaterm/terminal-skills (58 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 13 tokens to every session and 1,884 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

shell-scripting

Use this skill when writing bash or zsh scripts, parsing arguments, handling errors, or automating CLI workflows. Triggers on bash scripting, shell scripts, argument parsing, process substitution, here documents, signal trapping, exit codes, and any task requiring portable shell script development.

alibaba/anolisa · 60 tokens

bash-scripting-safe

Write safe, robust Bash scripts — set -euo pipefail, quoting, word splitting, error handling, idempotency, and common data-loss gotchas.

vikasudasi/skill-vault · 38 tokens

rust-unit-tests

Write, improve, and run Rust unit tests in the warp Rust codebase.

warpdotdev/warp · 20 tokens

warpctrl

Control and inspect the currently running local Warp application with the warpctrl CLI. Use this skill whenever the user asks the agent to manipulate Warp's own windows, tabs, panes, sessions, input buffer, themes, or UI surfaces; open a file in Warp; inspect local Warp state; or explain how to invoke Warp Control…

warpdotdev/warp · 69 tokens

change-keybinding

Customize Warp keyboard shortcuts (keybindings, keymappings) by editing the user's keybindings.yaml file. Use when the user asks to remap a key combination, rebind an action, change a shortcut, or remove a default keybinding (e.g. "change ctrl+space to ctrl+s", "rebind the command palette to cmd+p", "remove the…

warpdotdev/warp · 82 tokens

create-tab-config

Create new Warp tab config TOML files from natural-language requests. Use when the user wants a new tab config, a new tab layout, or asks for a slash command to generate a tab config.

warpdotdev/warp · 44 tokens