claude-code-bash-patterns

claude-code-bash-patterns is a skill for Claude Code 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 Code

Written for Claude Code: PreToolUse hook event. Also seen: reads .claude/ paths; positional $N argument; mentions Claude Code.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is cd repo1 && git pull && cd ../repo2 && git pull.

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

not rated 231repo +2 today B scan Socket: passSnyk: passSkillSpector: warn 52 tokens original MIT

Good fit Use it to chain commands, run independent commands in parallel, keep state between commands, run long-lived processes, and configure PreToolUse hooks.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills
agentmods
npx agentmods add skills/secondsky/claude-skills/claude-code-bash-patterns

Made for: Claude Code.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for claude-code-bash-patterns

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk pass 15 Feb 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 57
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • medium Excessive Agency · line 128
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.1 $0.00052 $0.02175
Opus 5.5 $0.00021 $0.00870
Sonnet 5.5 $0.00010 $0.00435
Haiku 4.5 $0.00005 $0.00217

Measured 1mo ago against content hash 1c1be2d7633e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo ago.

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. 1mo ago 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 (231 stars, last pushed today), licensed MIT. It adds 52 tokens to every session and 2,175 once invoked, about $0.0002 per session on Opus 5.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.

Related

Other skills, from other repositories

review

Review a change with what this repository knows about it — who depends on the file, which tests cover it, what broke here before, and what the repo has written down. Use before approving a diff, opening a PR, or when asked to review.

ArcticFox2029/chamnan · 51 tokens

milestone

Record a change that reshaped the repository — what moved, why it was worth doing, and which areas it touched. Use after a migration, a rewrite, or a decision that changed how part of the system works.

ArcticFox2029/chamnan · 44 tokens

promote

Turn a scratch script into a permanent tool this repo keeps. Use when a check, report, or analysis has proved worth running more than once.

ArcticFox2029/chamnan · 29 tokens

catchup

Answer "where did I stop?" for this project. Gives three short groups, done, open and next, taken from the last chat, the recorded to-dos, the last handoff note and git. Use when the user comes back to a project, starts a new chat, or asks where they left off. It writes nothing.

Avijit07x/claude-db · 71 tokens

commit-push-pr

Use when asked to commit and push a feature branch, with or without a pull request. Its no-PR mode publishes without a PR. Not for a PR body alone: use create-pull-request.

OutlineDriven/odin-claude-plugin · 46 tokens

commit

Use when asked to commit changes, create a typed branch, format history for a changelog, or rewrite messages of HEAD or an unpushed range. Not for pushing or a PR: use commit-push-pr.

OutlineDriven/odin-claude-plugin · 46 tokens