Agent skill

Claude Code Bash Patterns

by secondsky in secondsky/claude-skills

Claude Code Bash tool patterns with hooks, automation, git workflows.

MITAuto-check passedDevelopment

Install Claude Code Bash Patterns

skills CLI
$ npx skills add secondsky/claude-skills --skill claude-code-bash-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills claude-code-bash-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns .claude/skills/claude-code-bash-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
claude-code-bash-patterns
GitHub stars
227
Token cost
~2.1k tokens
SKILL.md length
606 words
Files
14 (incl. scripts, references)
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Claude Code Bash tool patterns with hooks, automation, git workflows.

  • Works in 5 steps: Sequential Operations (&&) → Parallel Operations (Multiple tool calls) → Session Persistence → …
  • PreToolUse hooks
  • SKILL.md covers Quick Start, The Five Core Patterns, Critical Rules and Git Workflows, plus 5 more sections
  • Runs Shell and Python scripts from its folder; calls git, npm and bun; needs API_KEY

What it does

Claude Code Bash Patterns is an agent skill from secondsky/claude-skills. Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 16 other files, including scripts and reference files (for example `references/cli-tool-integration.md`, `references/git-workflows.md` and `references/hooks-examples.md`).

It sits in Development, covering Git workflow. It works with Bash and Git. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • PreToolUse hooks
  • Command chaining
  • CLI orchestration
  • Custom commands

Example prompts

  • “/claude-code-bash-patterns”

Requirements

  • Python 3
  • A Bash shell
  • A credential in API_KEY

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Sequential Operations (&&)
  2. Parallel Operations (Multiple tool calls)
  3. Session Persistence
  4. Background Processes
  5. Hooks for Automation

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Shell and Python), which the agent can run.

    Shell commands in SKILL.md call:

    • git
    • npm
    • bun
    • bunx
    • curl
    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.claude.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Claude Code Bash Patterns loads about 2.1k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 66 tokens; SKILL.md has 606 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~11k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 606 words, ~2,147 tokens.

Download SKILL.mdSave it as .claude/skills/claude-code-bash-patterns/SKILL.md (or your agent's skills folder). This skill also uses 13 other files; get the full folder from GitHub.
name
claude-code-bash-patterns
description
Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.
license
MIT
metadata.version
2.0.0
metadata.last_verified
2025-11-18
metadata.production_tested
true
metadata.token_savings
55%
metadata.errors_prevented
12
metadata.templates_included
5
metadata.references_included
5

Claude Code Bash Patterns

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


Quick Start

Basic Command
bash
ls -la
Command Chaining
bash
bun install && bun run build && bun test
Hooks

Create .claude-hook-pretooluse.sh:

bash
#!/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

bash
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

bash
# 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

bash
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/
Never Do ❌
  1. Never use ; for dependent commands (use &&)
  2. Never skip quoting paths with spaces
  3. Never run rm -rf without confirmation
  4. Never expose secrets in command output
  5. Never ignore timeout limits (max 10 min)
  6. Never use bash for file operations when specialized tools exist
  7. Never chain with newlines (use && or ; explicitly)
  8. Never force-push to main without explicit user request
  9. Never skip hooks (--no-verify) without user request
  10. Never use interactive commands (git rebase -i, git add -i)

Git Workflows

Basic Commit
bash
git add . && git commit -m "feat: add feature"
Commit with Testing
bash
npm test && git add . && git commit -m "fix: bug fix" && git push
Pull Request
bash
git checkout -b feature/new && git add . && git commit -m "feat: new feature" && git push -u origin feature/new

Load references/git-workflows.md for complete workflows including:

  • Feature branch workflow
  • PR creation automation
  • Commit message conventions
  • Pre-commit validation

Hooks: Advanced Automation

PreToolUse Hook

.claude-hook-pretooluse.sh:

bash
#!/usr/bin/env bash
COMMAND="$1"

# Log all commands
echo "[$(date)] Running: $COMMAND" >> ~/claude-commands.log

# Block dangerous patterns
if [[ "$COMMAND" =~ rm\ -rf\ / ]]; then
    echo "❌ Blocked dangerous command"
    exit 1
fi
Hook Types
  • pretooluse - Before every Bash command
  • stop - Before conversation ends
  • user-prompt-submit - After user submits message

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


CLI Tool Integration

npm/bun
bash
bun install && bun run build
wrangler (Cloudflare)
bash
bunx wrangler deploy
gh (GitHub CLI)
bash
gh pr create --title "Fix bug" --body "Description"

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


Custom Commands

Create .claude/commands/deploy.md:

markdown
---
description: Deploy to production
---

Run these steps:
1. Run tests: `npm test`
2. Build: `npm run build`
3. Deploy: `wrangler deploy`

User can invoke with: /deploy

Load templates/custom-command-template.md for template.


Security

Allowlisting Tools

settings.json:

json
{
  "dangerousCommandsAllowList": [
    "git push --force"
  ]
}
Secrets Management
bash
# ✅ Good: Use environment variables
export API_KEY="$SECURE_VALUE"

# ❌ Bad: Hardcode secrets
curl -H "Authorization: Bearer sk-abc123..."

Load references/security-best-practices.md for complete security guide.


Show full SKILL.md (242 more words)Show less

Common Use Cases

Use Case 1: Test Before Commit
bash
npm test && git add . && git commit -m "message"
Use Case 2: Deploy with Validation
bash
npm run lint && npm test && npm run build && bunx wrangler deploy
Use Case 3: Multi-Repo Operations
bash
cd repo1 && git pull && cd ../repo2 && git pull
Use Case 4: Background Process
bash
npm run dev &

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


Troubleshooting

Issue: Command times out

Solution: Increase timeout or use background mode

bash
# Background mode
npm run dev &
Issue: Path with spaces fails

Solution: Quote the path

bash
cd "path with spaces/file.txt"
Issue: Hook blocks command

Solution: Check hook logic in .claude-hook-pretooluse.sh

Load references/troubleshooting-guide.md for all issues.


When to Load References

Load references/git-workflows.md when:
  • Setting up git automation
  • Creating PRs programmatically
  • Need commit message conventions
  • Want pre-commit validation patterns
Load references/hooks-examples.md when:
  • Creating custom hooks
  • Need hook templates
  • Want validation patterns
  • Implementing logging/security
Load references/cli-tool-integration.md when:
  • Orchestrating multiple CLI tools
  • Need tool-specific patterns
  • Want parallel execution examples
  • Troubleshooting tool integration
Load references/security-best-practices.md when:
  • Configuring security guards
  • Setting up allowlisting
  • Managing secrets
  • Preventing dangerous operations
Load references/troubleshooting-guide.md when:
  • Debugging command failures
  • Encountering timeouts
  • Hooks behaving unexpectedly
  • Session state issues

Using Bundled Resources

References (references/)
  • git-workflows.md - Complete git automation patterns
  • hooks-examples.md - All hook types with examples
  • cli-tool-integration.md - Tool orchestration patterns
  • security-best-practices.md - Security configuration guide
  • troubleshooting-guide.md - Common issues and solutions
Templates (templates/)
  • custom-command-template.md - Custom command template
  • settings.json - Security settings example
  • .envrc.example - Environment variables example
  • github-workflow.yml - GitHub Actions integration
  • dangerous-commands.json - Dangerous patterns list

Examples

Feature Development Workflow
bash
git checkout -b feature/oauth && \
  npm test && \
  git add . && \
  git commit -m "feat(auth): add OAuth support" && \
  git push -u origin feature/oauth
CI/CD Pipeline
bash
npm run lint && \
  npm test && \
  npm run build && \
  bunx wrangler deploy
Multi-Project Update
bash
cd project1 && bun install && cd ../project2 && bun install

Official Documentation


Questions? Issues?

  1. Check references/troubleshooting-guide.md for common issues
  2. Review references/git-workflows.md for git patterns
  3. See references/hooks-examples.md for automation
  4. Load references/security-best-practices.md for security

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 13 other files (scripts, references) in plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns of secondsky/claude-skills.

  • SKILL.md
  • references/cli-tool-integration.md
  • references/git-workflows.md
  • references/hooks-examples.md
  • references/security-best-practices.md
  • references/troubleshooting-guide.md
  • scripts/bash-audit-logger.sh
  • scripts/dangerous-command-guard.py
  • scripts/package-manager-enforcer.sh
  • templates/.envrc.example
  • templates/custom-command-template.md
  • templates/dangerous-commands.json
  • templates/github-workflow.yml
  • templates/settings.json

Open the folder on GitHubat commit 8837836

Compare with similar skills

Claude Code Bash Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Claude Code Bash Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Claude Code Bash Patterns this skillsecondsky/claude-skills227—~2.1kAutomated safety check: PassMIT
Wednesday Gitwednesday-solutions/ai-agent-skills170—~702Automated safety check: PassMIT
Speckit Git Featurekunstmusik/blue1544 repos~861Automated safety check: PassGPL-3.0
Trace And Isolaterohitg00/skillkit1.5k—~1.8kAutomated safety check: PassApache-2.0
Speckit Git Initializekunstmusik/blue1545 repos~438Automated safety check: PassGPL-3.0
Tapd Iteration InitTencentBlueKing/bk-bcs840—~1.3kAutomated safety check: PassCustom licence

Similar skills

  • Wednesday Git

    wednesday-solutions/ai-agent-skills

    Unified Git workflow. An agent skill from wednesday-solutions/ai-agent-skills.

    170 GitHub stars~702 tokensUpdated 4 mo ago
    DevelopmentAuto-check passed
  • Speckit Git Feature

    kunstmusik/blue

    Create a feature branch with sequential or timestamp numbering

    154 GitHub starsUsed in 4 repos~861 tokens
    DevelopmentAuto-check passed
  • Trace And Isolate

    rohitg00/skillkit

    Applies systematic tracing and isolation techniques to pinpoint exactly where a bug originates in code.

    1.5k GitHub stars~1.8k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed
  • Speckit Git Initialize

    kunstmusik/blue

    Initialize a Git repository with an initial commit. An agent skill from kunstmusik/blue.

    154 GitHub starsUsed in 5 repos~438 tokens
    DevelopmentAuto-check passed
  • Tapd Iteration Init

    TencentBlueKing/bk-bcs

    迭代执行流水线启动器。分三个阶段执行:信息检查(验证 git 环境、获取迭代信息、 解析迭代分支)→ 恢复检测(已有状态文件时判定恢复策略)→ 新流程初始化(创建分支、 迭代目录和 iteration-state.json)。

    840 GitHub stars~1.3k tokensUpdated 13 days ago
    DevelopmentAuto-check passed
  • Ask

    sd0xdev/sd0x-harness

    Context-aware Q&A with auto context gathering. An agent skill from sd0xdev/sd0x-harness.

    192 GitHub stars~2.1k tokensUpdated yesterday
    DevelopmentAuto-check: notes

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 9 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 9 days ago
    Auto-check passed

Works with

Categories

Questions about Claude Code Bash Patterns

What does Claude Code Bash Patterns do?

Claude Code Bash tool patterns with hooks, automation, git workflows. Claude Code Bash Patterns is an agent skill from secondsky/claude-skills. Claude Code Bash tool patterns with hooks, automation, git workflows.

When should I use Claude Code Bash Patterns?

Claude Code Bash Patterns fits situations like: preToolUse hooks; command chaining; CLI orchestration; custom commands.

How do I install Claude Code Bash Patterns in Claude Code?

Run `npx skills add secondsky/claude-skills --skill claude-code-bash-patterns -a claude-code`. Or copy the skill folder (plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns in secondsky/claude-skills) into .claude/skills/claude-code-bash-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Claude Code Bash Patterns in Codex?

Run `npx skills add secondsky/claude-skills --skill claude-code-bash-patterns -a codex`. Or copy the skill folder (plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns in secondsky/claude-skills) into .agents/skills/claude-code-bash-patterns in your project. Codex loads it when a task matches its description.

Can I use Claude Code Bash Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill claude-code-bash-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/claude-code-bash-patterns, .gemini/skills/claude-code-bash-patterns, .github/skills/claude-code-bash-patterns and .opencode/skills/claude-code-bash-patterns in your project.

What does Claude Code Bash Patterns need to run?

Going by SKILL.md and its folder, Claude Code Bash Patterns needs a shell and Python for the scripts in its folder, the command-line tools its instructions call (git, npm, bun, bunx, curl and gh) and credentials named API_KEY. Our summary lists: Python 3; A Bash shell; A credential in API_KEY.

Does Claude Code Bash Patterns access the network?

SKILL.md names 1 domain. As links in the text: docs.claude.com. This is read from the text; nothing was executed.

Is Claude Code Bash Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Claude Code Bash Patterns use?

Claude Code Bash Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Claude Code Bash Patterns use?

About 2.1k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.6k tokens, read only when the agent opens those files.

What are the alternatives to Claude Code Bash Patterns?

Skills that share tags, products or a category with Claude Code Bash Patterns: Wednesday Git (wednesday-solutions/ai-agent-skills, 170 stars), Speckit Git Feature (kunstmusik/blue, 154 stars), Trace And Isolate (rohitg00/skillkit, 1.5k stars) and Speckit Git Initialize (kunstmusik/blue, 154 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Claude Code Bash Patterns?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.