Loading...
Loading...
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.
npx skill4agent add secondsky/claude-skills claude-code-bash-patternsls -labun install && bun run build && bun test.claude-hook-pretooluse.sh#!/usr/bin/env bash
# PreToolUse hook - runs before every Bash command
echo "Running: $1"references/hooks-examples.mdgit add . && git commit -m "message" && git pushMessage with multiple Bash tool calls in parallelreferences/cli-tool-integration.md# Set environment variable
export API_KEY="sk-..."
# Use in later commands (same session)
curl -H "Authorization: Bearer $API_KEY" api.example.comnpm run dev &
# Get PID with $!references/hooks-examples.mdcd "path with spaces"git add . && git commit -m "feat: add feature"npm test && git add . && git commit -m "fix: bug fix" && git pushgit checkout -b feature/new && git add . && git commit -m "feat: new feature" && git push -u origin feature/newreferences/git-workflows.md.claude-hook-pretooluse.sh#!/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
fireferences/hooks-examples.mdbun install && bun run buildbunx wrangler deploygh pr create --title "Fix bug" --body "Description"references/cli-tool-integration.md.claude/commands/deploy.md---
description: Deploy to production
---
Run these steps:
1. Run tests: `npm test`
2. Build: `npm run build`
3. Deploy: `wrangler deploy`/deploytemplates/custom-command-template.mdsettings.json{
"dangerousCommandsAllowList": [
"git push --force"
]
}# ✅ Good: Use environment variables
export API_KEY="$SECURE_VALUE"
# ❌ Bad: Hardcode secrets
curl -H "Authorization: Bearer sk-abc123..."references/security-best-practices.mdnpm test && git add . && git commit -m "message"npm run lint && npm test && npm run build && bunx wrangler deploycd repo1 && git pull && cd ../repo2 && git pullnpm run dev &references/cli-tool-integration.md# Background mode
npm run dev &cd "path with spaces/file.txt".claude-hook-pretooluse.shreferences/troubleshooting-guide.mdreferences/git-workflows.mdreferences/hooks-examples.mdreferences/cli-tool-integration.mdreferences/security-best-practices.mdreferences/troubleshooting-guide.mdgit checkout -b feature/oauth && \
npm test && \
git add . && \
git commit -m "feat(auth): add OAuth support" && \
git push -u origin feature/oauthnpm run lint && \
npm test && \
npm run build && \
bunx wrangler deploycd project1 && bun install && cd ../project2 && bun installreferences/troubleshooting-guide.mdreferences/git-workflows.mdreferences/hooks-examples.mdreferences/security-best-practices.md