secondsky avatar

Claude Code Bash Patterns

A systematic reference for orchestrating bash commands in Claude Code through hooks, command chaining, and session persistence. You're getting patterns for the five core scenarios (sequential with &&, parallel tool calls, stateful sessions, background processes, and PreToolUse hooks), plus git workflow automation and CLI tool integration. The 55% token savings comes from teaching you when to chain commands versus fire parallel tool calls, and the hooks let you inject logging or security checks before every bash execution. Load this when you're setting up automated workflows, need to understand why your commands are timing out, or want to stop re-explaining that git operations should chain with && instead of semicolons.

skills.sh installs
408
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill claude-code-bash-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Frontend Development, Security, Git & Pull Requests, Automation & Workflows, CLI & Terminal
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1secondsky avatarclaude-hook-writersecondsky/claude-skillsExpert guidance for writing secure, reliable, and performant Claude Code hooks - validates design decisions, enforces best practices, and prevents common pitfal408skills.sh installs
2mindfold-ai avatartrellis-metamindfold-ai/trellisUnderstand and customize the local Trellis architecture inside a user project. Use when modifying .trellis plus platform hooks, settings, agents, skills, comman405skills.sh installs
3aidenwu0209 avatarpaddleocr-doc-parsingaidenwu0209/paddleocr-skillsUse this skill to extract structured Markdown/JSON from PDFs and document images—tables with cell-level precision, formulas as LaTeX, figures, seals, charts, he404skills.sh installs
4fredm00n avatarframer-code-components-overridesfredm00n/framerlabsCreate Framer Code Components and Code Overrides. Use when building custom React components for Framer, writing Code Overrides (HOCs) to modify canvas elements,404skills.sh installs
5joneqian avatartdesign-miniprogramjoneqian/claude-skills-suiteTDesign Mini Program UI component library by Tencent. Use for building WeChat mini apps with TDesign components, design system, and best practices.403skills.sh installs
6tartinerlabs avatarsetuptartinerlabs/skillsUse when setting up a project, adding linting, formatting, git hooks, or type checking. Detects the language and installs that ecosystem's lint/format/hooks too400skills.sh installs