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…
Об этом скилле
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 ✅
- Use && for sequential dependencies (not semicolons)
- Quote paths with spaces (
cd "path with spaces") - Check environment before destructive ops (rm, git push --force)
- Use specialized tools first (Read, Grep, Glob before Bash)
- Set timeouts for long operations (up to 10 minutes)
- Validate inputs before passing to shell commands
- Use hooks for repeated patterns (logging, validation)
- Maintain session state (export variables once)
- Handle errors explicitly (check exit codes)
- Document custom commands in .claude/commands/
Never Do ❌
- Never use ; for dependent commands (use &&)
- Never skip quoting paths with spaces
- Never run rm -rf without confirmation
- Never expose secrets in command output
- Never ignore timeout limits (max 10 min)
- Never use bash for file operations when specialized tools exist
- Never chain with newlines (use && or ; explicitly)
- Never force-push to main without explicit user request
- Never skip hooks (--no-verify) without user request
- Never use interactive commands (git rebase -i, git add -i)
Git Workflows
Basic Commit
git add . && git commit -m "feat: add feature"
Commit with Testing
npm test && git add . && git commit -m "fix: bug fix" && git push
Pull Request
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:
#!/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
bun install && bun run build
wrangler (Cloudflare)
bunx wrangler deploy
gh (GitHub CLI)
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:
---
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:
{
"dangerousCommandsAllowList": [
"git push --force"
]
}
Secrets Management
# ✅ 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
npm test && git add . && git commit -m "message"
Use Case 2: Deploy with Validation
npm run lint && npm test && npm run build && bunx wrangler deploy
Use Case 3: Multi-Repo Operations
Установить claude-code-bash-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл claude-code-bash-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл claude-code-bash-patterns запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic