Claude Code Bash Patterns logo

Claude Code Bash Patterns

Community
secondsky
claude-code-bash-patterns

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.

Overview

Publishersecondsky
Repositoryclaude-skills
Skill nameclaude-code-bash-patterns
Stars
219
Forks
31
Bundled files
12
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 12 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by secondsky on GitHub. Read the source before you install it.

Installation

Install the Claude Code Bash Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/secondsky/claude-skills.git /tmp/claude-skills
mkdir -p .claude/skills
cp -r /tmp/claude-skills/plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns .claude/skills/claude-code-bash-patterns
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Claude Code Bash Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Claude Code Bash Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Claude Code Bash Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.


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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Claude Code Bash Patterns AI skill do?

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.

Why use Claude Code Bash Patterns on TypingMind?

Because you install it once and use it with any model. Claude Code Bash Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Claude Code Bash Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/secondsky/claude-skills/tree/main/plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Claude Code Bash Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Claude Code Bash Patterns?

As many as you like. As long as a model supports skills, you can use Claude Code Bash Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Claude Code Bash Patterns AI skill free?

Yes. It is published on GitHub by secondsky under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇