claude-code-bash-patterns

claude-code-bash-patterns is a skill for Claude Code, Codex from secondsky/claude-skills. It costs 52 tokens per session (2,175 once invoked), scanned B, original, MIT.

A collection of patterns for using Bash commands in Claude Code, including command chains, hooks, automation, and persistent sessions. Bash is a command-line shell used to run developer tools and scripts.

In plain words
What is it for?
Use it to chain commands, run independent commands in parallel, keep state between commands, run long-lived processes, and configure PreToolUse hooks.
Why use it?
It helps avoid common command failures, permission problems, and unsafe or incorrectly configured hooks.

Skill for Claude CodeCodex

Part of the claude-code-bash-patterns plugin — 1 skill shipped together

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/secondsky/claude-skills/claude-code-bash-patterns
Any agent
npx skills add secondsky/claude-skills --skill claude-code-bash-patterns
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code, Codex.

Or install claude-code-bash-patterns, the plugin that ships this one along with the rest of its 1 skill.

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 claude-code-bash-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/secondsky/claude-skills/claude-code-bash-patterns.svg)](https://agentmods.dev/skills/secondsky/claude-skills/claude-code-bash-patterns)
Your own site
<a href="https://agentmods.dev/skills/secondsky/claude-skills/claude-code-bash-patterns"><img src="https://agentmods.dev/badge/skills/secondsky/claude-skills/claude-code-bash-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,175 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 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.00052 $0.02175
Opus 5 $0.00026 $0.01087
Sonnet 5 $0.00010 $0.00435
Haiku 4.5 $0.00005 $0.00217

Measured yesterday against content hash 1c1be2d7633e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

claude-code-bash-patterns scanned grade B with 2 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 yesterday.

The scan reads SKILL.md. This mod also ships 3 executable files (scripts/bash-audit-logger.sh, scripts/dangerous-command-guard.py, scripts/package-manager-enforcer.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Recursive force deletemediumDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

3. **Never run rm -rf without confirmation**

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -H "Authorization: Bearer $API_KEY" api.example.com
plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns/SKILL.md · 424 lines

How it starts

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

Claude Code Bash Patterns

Status: Production Ready ✅ | Last Verified: 2025-11-18


Quick Start

Basic Command

ls -la

Command Chaining

bun install && bun run build && bun test

Hooks

Create .claude-hook-pretooluse.sh:

#!/usr/bin/env bash
# PreToolUse hook - runs before every Bash command

echo "Running: $1"

Load references/hooks-examples.md for complete hook patterns.


The Five Core Patterns

1. Sequential Operations (&&)

Use when: Each command depends on previous success

git add . && git commit -m "message" && git push

Why: Stops chain if any command fails


2. Parallel Operations (Multiple tool calls)

Use when: Commands are independent

Message with multiple Bash tool calls in parallel

Load references/cli-tool-integration.md for parallel patterns.


3. Session Persistence

Use when: Need to maintain state across commands

# Set environment variable
export API_KEY="sk-..."

# Use in later commands (same session)
curl -H "Authorization: Bearer $API_KEY" api.example.com

4. Background Processes

Use when: Long-running tasks

npm run dev &
# Get PID with $!

5. Hooks for Automation

Use when: Need pre/post command logic

Load references/hooks-examples.md for all hook types.


Critical Rules

Always Do ✅

  1. Use && for sequential dependencies (not semicolons)
  2. Quote paths with spaces (cd "path with spaces")
  3. Check environment before destructive ops (rm, git push --force)
  4. Use specialized tools first (Read, Grep, Glob before Bash)
  5. Set timeouts for long operations (up to 10 minutes)
  6. Validate inputs before passing to shell commands
  7. Use hooks for repeated patterns (logging, validation)
  8. Maintain session state (export variables once)
  9. Handle errors explicitly (check exit codes)
  10. Document custom commands in .claude/commands/

Read the full file on GitHub · 424 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. yesterday First seen · 424 lines · 52 tokens per session scan B 1c1be2d7633e

Subscribe to this mod's changes

claude-code-bash-patterns is a skill published in the GitHub repository secondsky/claude-skills (214 stars, last pushed 2d ago), licensed MIT. It adds 52 tokens to every session and 2,175 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it B with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.