[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AJSR563CWRH29Q5VM5HD2Z":3,"skill-same:01M7AJSR563CWRH29Q5VM5HD2Z":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":32,"commitSha":33,"skillDirectory":5,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M7AJSR563CWRH29Q5VM5HD2Z","claude-code-bash-patterns",null,"Comprehensive knowledge for using the Bash tool in Claude Code effectively. This skill\nshould be used when orchestrating CLI tools, configuring hooks, setting up automation\nworkflows, managing git operations, handling multi-command patterns, or encountering\nBash tool errors.\n\nCovers: PreToolUse hooks, command chaining patterns, git workflow automation, CLI tool\nintegration, custom commands (.claude\u002Fcommands\u002F), security configurations, allowlisting,\nsession persistence, output handling, error prevention, and troubleshooting common issues.\n\nUse when: setting up Claude Code hooks, configuring bash permissions, creating custom\ncommands, automating git workflows, orchestrating multiple CLI tools, debugging bash\ncommand failures, implementing security guards, logging command execution, or preventing\ndangerous operations.","davidanthonyn\u002Fagent-skills","davidanthonyn","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F55152980?v=4","01M7AJ4MY8S5C2RJCGX6626J0G","01M7AJ4MZB7EC7CAP27ANCSE7N",1,"MIT","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fclaude-code-bash-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: claude-code-bash-patterns\ndescription: |\n  Comprehensive knowledge for using the Bash tool in Claude Code effectively. This skill\n  should be used when orchestrating CLI tools, configuring hooks, setting up automation\n  workflows, managing git operations, handling multi-command patterns, or encountering\n  Bash tool errors.\n\n  Covers: PreToolUse hooks, command chaining patterns, git workflow automation, CLI tool\n  integration, custom commands (.claude\u002Fcommands\u002F), security configurations, allowlisting,\n  session persistence, output handling, error prevention, and troubleshooting common issues.\n\n  Use when: setting up Claude Code hooks, configuring bash permissions, creating custom\n  commands, automating git workflows, orchestrating multiple CLI tools, debugging bash\n  command failures, implementing security guards, logging command execution, or preventing\n  dangerous operations.\nlicense: MIT\nmetadata:\n  author: Jeremy Dawes (Jezweb)\n  version: 1.0.0\n  last_updated: 2025-11-07\n  production_tested: wordpress-auditor, claude-skills, multiple client projects\n  token_savings: 55%\n  errors_prevented: 12\n  status: production_ready\n---\n\n# Claude Code Bash Patterns\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-11-07\n**Dependencies**: Claude Code CLI (latest version)\n**Official Docs**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Ftools\n\n---\n\n## Quick Start (10 Minutes)\n\n### 1. Understanding the Bash Tool\n\nThe Bash tool is Claude Code's primary interface for executing command-line operations. Unlike specialized tools (Read, Grep, Glob), the Bash tool provides direct shell access for complex workflows.\n\n**Key Characteristics**:\n- **Session Persistence**: Commands run in a persistent bash session within a conversation\n- **Environment Inheritance**: Inherits environment variables and working directory\n- **Output Limit**: Truncates output at 30,000 characters\n- **Default Timeout**: 2 minutes (configurable up to 10 minutes)\n\n**When to Use Bash Tool**:\n- ✅ Running CLI tools (git, npm, wrangler, gh, etc.)\n- ✅ Command chaining (sequential operations)\n- ✅ Process orchestration (build, test, deploy)\n- ✅ Environment setup and management\n\n**When NOT to Use Bash Tool**:\n- ❌ Reading files → Use **Read** tool instead\n- ❌ Searching file patterns → Use **Glob** tool instead\n- ❌ Searching content → Use **Grep** tool instead\n- ❌ Editing files → Use **Edit** tool instead\n\n### 2. Basic Command Patterns\n\n```bash\n# Single command\nnpm install\n\n# Sequential with && (stops on first failure)\nnpm install && npm run build\n\n# Sequential with ; (continues regardless)\nnpm install ; npm run build\n\n# Parallel execution (make multiple Bash tool calls)\n# Call 1: git status\n# Call 2: git diff\n# Call 3: git log\n```\n\n**Golden Rule**: Use `&&` when you care about failures, `;` when you don't, and parallel calls when operations are independent.\n\n### 3. Configure Your First Hook\n\nHooks let you run code before\u002Fafter tool execution. Here's a simple audit logger:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"echo \\\"[$(date -Iseconds)] $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Fbash-audit.log\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nSave this to `~\u002F.claude\u002Fsettings.json` to log every bash command with timestamp.\n\n---\n\n## The Five Core Patterns\n\n### Pattern 1: Command Chaining\n\n**When to Use**: Sequential operations where each depends on previous success\n\n**Syntax**: `command1 && command2 && command3`\n\n**Example**: Build and deploy workflow\n```bash\nnpm install && npm run build && npx wrangler deploy\n```\n\n**Why It Matters**:\n- Stops on first failure (prevents cascading errors)\n- Maintains clean error messages (know exactly what failed)\n- Saves tokens (no need to check status between commands)\n\n**Anti-Pattern**: Using `;` when you care about failures\n```bash\n# ❌ Wrong: Continues even if install fails\nnpm install ; npm run build\n\n# ✅ Correct: Stops if install fails\nnpm install && npm run build\n```\n\n**Advanced**: Conditional execution with `||`\n```bash\n# Run tests, or echo failure message\nnpm test || echo \"Tests failed, not deploying\"\n\n# Try npm ci, fall back to npm install\nnpm ci || npm install\n```\n\n### Pattern 2: Parallel Execution\n\n**When to Use**: Independent operations that can run simultaneously\n\n**How**: Make multiple Bash tool calls in a single message\n\n**Example**: Git workflow pre-commit analysis\n```\n# Claude makes 3 parallel Bash calls in one message:\nCall 1: git status\nCall 2: git diff --staged\nCall 3: git log -5 --oneline\n```\n\n**Benefits**:\n- ~40% faster than sequential (no waiting between calls)\n- Reduces context usage (all results arrive together)\n- Better user experience (appears instant)\n\n**Important**: Only parallelize truly independent operations. If Call 2 depends on Call 1's output, run sequentially.\n\n### Pattern 3: HEREDOC for Multi-Line Content\n\n**When to Use**: Git commits, file creation, complex strings with newlines\n\n**Syntax**: `cat \u003C\u003C'EOF' ... EOF`\n\n**Example**: Git commit with detailed message\n```bash\ngit commit -m \"$(cat \u003C\u003C'EOF'\nfeat(auth): Add JWT verification middleware\n\nImplement custom JWT template support for Clerk auth.\nExtracts email and metadata claims for user context.\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude \u003Cnoreply@anthropic.com>\nEOF\n)\"\n```\n\n**Why Single Quotes**: `\u003C\u003C'EOF'` prevents variable expansion in the content. Use `\u003C\u003C\"EOF\"` if you want variables to expand.\n\n**Common Mistake**: Forgetting quotes around `$()` wrapper\n```bash\n# ❌ Wrong: Newlines lost\ngit commit -m $(cat \u003C\u003C'EOF'\nLine 1\nLine 2\nEOF\n)\n\n# ✅ Correct: Preserves newlines\ngit commit -m \"$(cat \u003C\u003C'EOF'\nLine 1\nLine 2\nEOF\n)\"\n```\n\n### Pattern 4: Output Capture and Processing\n\n**When to Use**: Need to process command output before using it\n\n**Pattern**: Command substitution with `$()`\n\n**Example**: Get current branch name\n```bash\nBRANCH=$(git rev-parse --abbrev-ref HEAD)\necho \"Current branch: $BRANCH\"\n```\n\n**Example**: Conditional logic based on output\n```bash\nif git diff --quiet; then\n  echo \"No changes detected\"\nelse\n  echo \"Changes detected, running tests...\"\n  npm test\nfi\n```\n\n**Limitation**: Output truncated at 30,000 characters. For large outputs:\n```bash\n# Limit output\nnpm test 2>&1 | head -100\n\n# Or save to file\nnpm test > test-results.txt && tail -50 test-results.txt\n```\n\n### Pattern 5: Conditional Execution\n\n**When to Use**: Different actions based on conditions\n\n**Pattern**: Test commands with `&&` \u002F `||`\n\n**Example**: Run tests only if files changed\n```bash\ngit diff --quiet || npm test\n```\n\n**Example**: Different commands based on file existence\n```bash\n[ -f package-lock.json ] && npm ci || npm install\n```\n\n**Example**: Multi-condition logic\n```bash\nif [ -f pnpm-lock.yaml ]; then\n  pnpm install\nelif [ -f yarn.lock ]; then\n  yarn install\nelse\n  npm install\nfi\n```\n\n---\n\n## Hooks: Advanced Automation\n\nHooks are shell commands or Claude prompts that run before\u002Fafter tool execution. They're your security guards, cleanup crew, and automation helpers.\n\n### PreToolUse: The Security Guard\n\n**Purpose**: Runs before tool execution, can block or modify behavior\n\n**Exit Codes**:\n- `0` = Allow execution\n- `1` = Block with generic error\n- `2` = Block with custom error message (from stderr)\n\n#### Use Case 1: Block Dangerous Commands\n\n**File**: `~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py`\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\nimport json\nimport sys\nimport re\n\n# Read hook input from stdin\ndata = json.load(sys.stdin)\ncommand = data.get('tool_input', {}).get('command', '')\n\n# Dangerous patterns to block\nDANGEROUS = [\n    r'rm\\s+-rf\\s+\u002F',           # Delete root\n    r'dd\\s+if=',                # Disk operations\n    r'mkfs\\.',                  # Format filesystem\n    r':()\\{.*\\}:',              # Fork bomb\n    r'sudo\\s+rm',               # Sudo delete\n    r'git\\s+push.*--force.*main',  # Force push to main\n]\n\nfor pattern in DANGEROUS:\n    if re.search(pattern, command):\n        print(f\"BLOCKED: Dangerous command pattern '{pattern}'\", file=sys.stderr)\n        sys.exit(2)\n\n# Allow execution\nsys.exit(0)\n```\n\n**Settings Configuration**:\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"python3 ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Use Case 2: Log All Bash Commands\n\n```json\n{\n  \"matcher\": \"Bash\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"echo \\\"[$(date -Iseconds)] $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Fbash-audit.log\"\n    }\n  ]\n}\n```\n\n**Result**: Every bash command logged with timestamp to `~\u002F.claude\u002Fbash-audit.log`\n\n#### Use Case 3: Enforce Package Manager\n\nCheck for lockfile and block wrong package manager:\n\n```bash\n#!\u002Fbin\u002Fbash\n# File: ~\u002F.claude\u002Fhooks\u002Fpackage-manager-enforcer.sh\n\nCOMMAND=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.command')\n\nif [ -f pnpm-lock.yaml ] && echo \"$COMMAND\" | grep -qE '^(npm|yarn) '; then\n  echo \"ERROR: This repo uses pnpm. Please use 'pnpm' instead of 'npm' or 'yarn'.\" >&2\n  exit 2\nfi\n\nif [ -f yarn.lock ] && echo \"$COMMAND\" | grep -qE '^(npm|pnpm) '; then\n  echo \"ERROR: This repo uses yarn. Please use 'yarn' instead of 'npm' or 'pnpm'.\" >&2\n  exit 2\nfi\n\nexit 0\n```\n\n### PostToolUse: The Cleanup Crew\n\n**Purpose**: Runs after successful tool execution (exit code 0 only)\n\n**Example**: Auto-format after file edits\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path'); [ -f \\\"$FILE\\\" ] && prettier --write \\\"$FILE\\\" || true\"\n    }\n  ]\n}\n```\n\n**Example**: Run tests after code changes\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path'); if echo \\\"$FILE\\\" | grep -qE '\\\\.(ts|tsx|js|jsx)$'; then npm test -- \\\"$FILE\\\"; fi\"\n    }\n  ]\n}\n```\n\n### SessionStart: Environment Setup\n\n**Purpose**: Runs once at session start, sets up environment\n\n**Example**: Load project-specific environment\n```json\n{\n  \"hooks\": {\n    \"SessionStart\": [\n      {\n        \"matcher\": \"*\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**Environment Variables Available in Hooks**:\n- `$CLAUDE_TOOL_INPUT` - JSON string of tool call\n- `$CLAUDE_ENV_FILE` - Path to environment file\n- Standard env vars (`$HOME`, `$USER`, `$PWD`, etc.)\n\n---\n\n## Git Workflows (Production-Tested)\n\nThese patterns are used by Anthropic's engineering team for 90%+ of git interactions.\n\n### Pattern: Intelligent Git Commits\n\n**Step 1**: Gather context (parallel calls)\n```bash\n# Call 1\ngit status\n\n# Call 2\ngit diff --staged\n\n# Call 3\ngit log -5 --oneline\n```\n\n**Why Parallel**: Independent operations, faster response, better UX\n\n**Step 2**: Analyze changes\n- Review **actual code changes** (not just file names!)\n- Match commit message style from git log\n- Focus on \"why\" not \"what\"\n- Keep message concise (1-2 sentences)\n\n**Step 3**: Commit with HEREDOC\n```bash\ngit add [files] && git commit -m \"$(cat \u003C\u003C'EOF'\nfeat(auth): Add JWT verification middleware\n\nImplement custom JWT template support for Clerk auth.\nExtracts email and metadata claims for user context.\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude \u003Cnoreply@anthropic.com>\nEOF\n)\"\n```\n\n**Step 4**: Verify\n```bash\ngit status\n```\n\n**Important**: If pre-commit hook modifies files:\n1. Check authorship: `git log -1 --format='%an %ae'`\n2. Check not pushed: `git status` (should show \"ahead of origin\")\n3. If both safe: `git add . && git commit --amend --no-edit`\n4. If not safe: `git add . && git commit -m \"Apply pre-commit hook changes\"`\n\n### Pattern: Pull Request Creation\n\n**Step 1**: Understand branch state (parallel)\n```bash\n# Call 1\ngit status\n\n# Call 2\ngit diff main...HEAD\n\n# Call 3\ngit log main..HEAD --oneline\n```\n\n**Step 2**: Analyze ALL commits (not just latest!)\n- What changed since branch diverged from main?\n- What's the overall goal of this branch?\n- What needs testing?\n\n**Step 3**: Create PR with gh CLI\n```bash\ngh pr create --title \"feat: User Authentication\" --body \"$(cat \u003C\u003C'EOF'\n## Summary\n- Implement JWT verification with Clerk\n- Add login\u002Flogout endpoints\n- Update database schema for users table\n\n## Test Plan\n- [ ] Verify JWT token validation\n- [ ] Test login flow\n- [ ] Test logout flow\n- [ ] Confirm database migrations work\n\n🤖 Generated with Claude Code\nEOF\n)\"\n```\n\n**Result**: Professional PR with clear summary and test plan\n\n---\n\n## CLI Tool Integration\n\n### GitHub CLI (gh)\n\nClaude knows gh CLI by default. Common patterns:\n\n```bash\n# View PR comments\ngh api repos\u002Fowner\u002Frepo\u002Fpulls\u002F123\u002Fcomments\n\n# Check CI status\ngh run list --limit 5\n\n# Create issue\ngh issue create --title \"Bug: Description\" --body \"Details here\"\n\n# Comment on PR\ngh pr comment 123 --body \"LGTM! 🚀\"\n```\n\n### Wrangler (Cloudflare)\n\nPrefix with `npx` for local install:\n\n```bash\n# Deploy worker\nnpx wrangler deploy\n\n# Run D1 migrations\nnpx wrangler d1 migrations apply my-db --remote\n\n# Tail logs\nnpx wrangler tail\n\n# Execute D1 query\nnpx wrangler d1 execute my-db --command \"SELECT * FROM users LIMIT 5\"\n```\n\n### Custom CLI Tools\n\n**How to teach Claude about your CLI**:\n\n**Option 1**: Document in CLAUDE.md\n```markdown\n## Custom Tools\n\n**mycli**: Internal deployment tool\nUsage: `mycli deploy --env production --service api`\nHelp: `mycli --help` for full options\nConfig: `.mycli.json` in project root\n```\n\n**Option 2**: Let Claude discover\n```markdown\nWhen encountering mycli commands, run `mycli --help` first to discover available options.\n```\n\n**Option 3**: Create custom command (`.claude\u002Fcommands\u002Fdeploy.md`)\n```markdown\nDeploy using our internal mycli tool:\n\n1. Run `mycli --version` to verify installation\n2. Check current environment: `mycli env current`\n3. Deploy to staging: `mycli deploy --env staging --service api`\n4. Run smoke tests: `mycli test smoke --env staging`\n5. If tests pass, deploy to production: `mycli deploy --env production --service api`\n```\n\n---\n\n## Security Configurations\n\n### 1. Dangerous Command Guard (PreToolUse Hook)\n\nSee bundled script: `scripts\u002Fdangerous-command-guard.py`\n\n**Blocks**:\n- `rm -rf \u002F` (delete root)\n- `dd if=` (disk operations)\n- `mkfs.*` (format filesystem)\n- `:(){ :|:& };:` (fork bomb)\n- `sudo rm` (dangerous sudo deletions)\n- `git push --force main` (force push to main branch)\n\n**Installation**:\n```bash\n# Copy script\ncp scripts\u002Fdangerous-command-guard.py ~\u002F.claude\u002Fhooks\u002F\nchmod +x ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\n\n# Configure in ~\u002F.claude\u002Fsettings.json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"python3 ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### 2. Production File Protection\n\nPrevent modification of production config files:\n\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path \u002F\u002F empty'); if echo \\\"$FILE\\\" | grep -qE '(^|\\\\\u002F)(production\\\\.env|\\\\.env\\\\.production|prod\\\\.config)$'; then echo 'ERROR: Cannot modify production config files' >&2; exit 2; fi\"\n    }\n  ]\n}\n```\n\n### 3. Audit Logging\n\nLog all bash commands for compliance:\n\n```json\n{\n  \"matcher\": \"Bash\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"echo \\\"[$(date -Iseconds)] User: $USER | Command: $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Faudit.log\"\n    }\n  ]\n}\n```\n\n**View audit log**:\n```bash\ntail -50 ~\u002F.claude\u002Faudit.log\n```\n\n---\n\n## Custom Commands (.claude\u002Fcommands\u002F)\n\nCustom commands are markdown files that expand into prompts when invoked.\n\n### Creating Custom Commands\n\n**File**: `.claude\u002Fcommands\u002Fdeploy-staging.md`\n```markdown\nDeploy the current branch to staging environment:\n\n1. Verify branch is not main (exit if main)\n2. Run full test suite (npm test)\n3. Build production bundle (npm run build)\n4. Deploy with wrangler to staging (npx wrangler deploy --env staging)\n5. Run smoke tests against staging URL\n6. Share deployment URL with user\n```\n\n**Usage**:\n```\nUser: \u002Fdeploy-staging\nClaude: [Executes the workflow from the markdown file]\n```\n\n### Best Practices for Custom Commands\n\n✅ **Do**:\n- Make them atomic (one clear workflow)\n- Include verification steps\n- Document expected state\n- Add rollback instructions\n- Use imperative language\n\n❌ **Don't**:\n- Make them too complex (split into multiple commands)\n- Include interactive prompts\n- Assume state (always verify)\n\n**Example Command Library**:\n- `\u002Fdeploy-staging` - Deploy to staging\n- `\u002Fdeploy-production` - Deploy to production (with safety checks)\n- `\u002Frun-tests` - Run full test suite\n- `\u002Fcheck-types` - TypeScript type checking\n- `\u002Fformat-code` - Format all code files\n- `\u002Fcreate-migration` - Create database migration\n\n---\n\n## Critical Rules\n\n### Always Do ✅\n\n**1. Use Specialized Tools First**\n\nBash is powerful but inefficient for tasks with dedicated tools:\n\n```bash\n# ❌ Wrong: Use Bash for file reading\ncat file.txt\n\n# ✅ Correct: Use Read tool\nRead(file_path=\"file.txt\")\n```\n\n```bash\n# ❌ Wrong: Use Bash for file search\nfind . -name \"*.ts\"\n\n# ✅ Correct: Use Glob tool\nGlob(pattern=\"**\u002F*.ts\")\n```\n\n```bash\n# ❌ Wrong: Use Bash for content search\ngrep \"pattern\" file.txt\n\n# ✅ Correct: Use Grep tool\nGrep(pattern=\"pattern\", path=\"file.txt\")\n```\n\n**Why**: Specialized tools are faster, use fewer tokens, and provide better formatting.\n\n**2. Quote Paths with Spaces**\n\n```bash\n# ❌ Wrong: Breaks on spaces\ncd \u002FUsers\u002Fname\u002FMy Documents\n\n# ✅ Correct: Quoted path\ncd \"\u002FUsers\u002Fname\u002FMy Documents\"\n```\n\n**3. Use && for Dependencies**\n\n```bash\n# ❌ Wrong: Continues even if install fails\nnpm install ; npm run build\n\n# ✅ Correct: Stops on failure\nnpm install && npm run build\n```\n\n**4. Parallel for Independent Operations**\n\n```bash\n# ❌ Wrong: Sequential when could be parallel\ngit status && git diff && git log\n\n# ✅ Correct: Make 3 parallel Bash tool calls in one message\n```\n\n**5. HEREDOC for Multi-line Strings**\n\n```bash\n# ❌ Wrong: Escaping nightmare\ngit commit -m \"line1\\nline2\\nline3\"\n\n# ✅ Correct: HEREDOC\ngit commit -m \"$(cat \u003C\u003C'EOF'\nline1\nline2\nline3\nEOF\n)\"\n```\n\n**6. Always Provide Description**\n\n```bash\n# ❌ Wrong: No context for user\nBash(command=\"complex-script.sh\")\n\n# ✅ Correct: Clear purpose\nBash(\n  command=\"complex-script.sh\",\n  description=\"Run integration tests on staging database\"\n)\n```\n\n### Never Do ❌\n\n**1. Don't Use Interactive Commands**\n\nCommands that require user input will hang:\n\n```bash\n# ❌ Wrong: Will hang waiting for input\nvim file.txt\nnano file.txt\nless output.txt\nnpm install  # If package.json has prompts\n\n# ✅ Correct: Use non-interactive alternatives\n# Use Edit\u002FWrite tools for file editing\nnpm install --yes\n```\n\n**2. Don't Chain with Newlines**\n\n```bash\n# ❌ Wrong: Doesn't work as expected\ncommand1\ncommand2\n\n# ✅ Correct: Use && or ;\ncommand1 && command2\n```\n\n**3. Don't Ignore Exit Codes**\n\n```bash\n# ❌ Wrong: Success message even if command failed\nrisky-command ; echo \"Success!\"\n\n# ✅ Correct: Check exit code\nrisky-command && echo \"Success!\" || echo \"Failed!\"\n```\n\n**4. Don't Use cd Excessively**\n\nIn agent mode, working directory doesn't persist between calls:\n\n```bash\n# ❌ Wrong: cd doesn't persist\n# Call 1: cd \u002Fpath\u002Fto\u002Fproject\n# Call 2: npm test  # Runs in original directory!\n\n# ✅ Correct: Use absolute paths or --prefix\nnpm test --prefix \u002Fpath\u002Fto\u002Fproject\n\n# ✅ Or chain in single command\ncd \u002Fpath\u002Fto\u002Fproject && npm test\n```\n\n**5. Don't Skip Error Handling**\n\n```bash\n# ❌ Wrong: No error handling\n.\u002Fscript.sh\n.\u002Fcleanup.sh\n\n# ✅ Correct: Handle failures\n.\u002Fscript.sh || { echo \"Script failed\" >&2; exit 1; }\n.\u002Fcleanup.sh\n```\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **12** documented issues with sources:\n\n### Issue #1: Git Bash cygpath Command Not Found (Windows)\n\n**Error**: `bash: line 1: cygpath: command not found`\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F9883\n**Why It Happens**: Bash tool attempts to use cygpath (Cygwin-only) on MSYS\u002FGit Bash\n\n**Prevention**:\n- Use WSL instead of Git Bash on Windows\n- Configure `CLAUDE_CODE_GIT_BASH_PATH` if using Git Bash\n- Install Cygwin if cygpath is required\n\n### Issue #2: Pipe Command Failures\n\n**Error**: `echo test|grep test` returns error instead of \"test\"\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F774\n**Why It Happens**: Pipe parsing issues in certain configurations\n\n**Prevention**:\n```bash\n# ❌ Avoid direct pipes\necho test|grep test\n\n# ✅ Use explicit bash -c\nbash -c 'echo test | grep test'\n\n# ✅ Or use specialized tools (Grep tool instead)\n```\n\n### Issue #3: Command Timeout (Hanging Promises)\n\n**Error**: `A hanging Promise was canceled`\n**Source**: Bash tool default timeout is 2 minutes\n**Why It Happens**: Long-running commands without timeout configuration\n\n**Prevention**:\n```bash\n# For long operations, set timeout explicitly\nBash(\n  command=\"npm run build\",\n  timeout=600000,  # 10 minutes\n  description=\"Build production bundle (may take several minutes)\"\n)\n\n# Or run in background\nBash(\n  command=\"npm run build > build.log 2>&1 &\",\n  description=\"Start build in background\"\n)\n```\n\n### Issue #4: Output Truncation Loss\n\n**Error**: Important output missing from response\n**Source**: Bash tool truncates output at 30,000 characters\n**Why It Happens**: Large command outputs exceed limit\n\n**Prevention**:\n```bash\n# ❌ Wrong: Full output may be truncated\nnpm test\n\n# ✅ Correct: Limit output\nnpm test 2>&1 | head -100\n\n# ✅ Or save to file\nnpm test > test-results.txt && tail -50 test-results.txt\n```\n\n### Issue #5: \"No Suitable Shell Found\" (Windows)\n\n**Error**: CLI fails with \"No suitable shell found\"\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F3461\n**Why It Happens**: Shell detection issues in Git Bash environment\n\n**Prevention**:\n- Set SHELL environment variable explicitly\n- Use WSL for better compatibility\n- Install latest Claude Code CLI version\n\n### Issue #6: Bash Tool Access Loss\n\n**Error**: Claude loses ability to run Bash() tool\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F1888\n**Why It Happens**: Session state corruption, often after overnight idle\n\n**Prevention**:\n- Restart Claude Code session if Bash becomes unavailable\n- Check permissions with `\u002Fpermissions` command\n- Use `restart: true` parameter to reset bash session\n\n### Issue #7: Interactive Prompt Hangs\n\n**Error**: Command hangs indefinitely, no output\n**Why It Happens**: Command expects interactive input (password, confirmation)\n\n**Prevention**:\n```bash\n# ❌ Wrong: Will hang\nnpm install  # If package.json has interactive prompts\n\n# ✅ Correct: Non-interactive flags\nnpm install --yes\n\n# ✅ Correct: Provide input via stdin\necho \"yes\" | command-that-needs-confirmation\n```\n\n### Issue #8: Permission Denied Errors\n\n**Error**: `permission denied` or `command not found`\n**Why It Happens**: Script not executable or not in PATH\n\n**Prevention**:\n```bash\n# Make script executable first\nchmod +x script.sh && .\u002Fscript.sh\n\n# Use full path\n\u002Fusr\u002Flocal\u002Fbin\u002Fmycli deploy\n\n# Or use interpreter directly\npython3 script.py\nnode script.js\n```\n\n### Issue #9: Environment Variables Not Persisting\n\n**Error**: Variable set in one command not available in next\n**Why It Happens**: Agent threads reset environment between calls\n\n**Prevention**:\n```bash\n# ❌ Wrong: Split across calls\n# Call 1: export API_KEY=abc123\n# Call 2: curl -H \"Authorization: $API_KEY\" ...  # $API_KEY empty!\n\n# ✅ Correct: Same command\nexport API_KEY=abc123 && curl -H \"Authorization: $API_KEY\" ...\n\n# ✅ Or use SessionStart hook\n```\n\n### Issue #10: Git Commit Hook Modifications Not Detected\n\n**Error**: Pre-commit hook changes files, but commit fails\n**Why It Happens**: Hook modifies files after staging\n\n**Prevention**:\n```bash\n# After commit fails due to hook changes:\n# 1. Check if you can amend (not pushed, authored by you)\ngit log -1 --format='%an %ae'\n\n# 2. If safe, amend\ngit add . && git commit --amend --no-edit\n\n# 3. If not safe, make new commit\ngit add . && git commit -m \"Apply pre-commit hook changes\"\n```\n\n### Issue #11: Wildcard Permission Matching Not Working\n\n**Error**: `Bash(*)` or `Bash(*:*)` doesn't grant access\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F462\n**Why It Happens**: Syntax mismatch in allowlisting\n\n**Prevention**:\n```json\n\u002F\u002F ❌ Wrong\n{\"allowedTools\": [\"Bash(*)\"]}\n\n\u002F\u002F ✅ Correct\n{\"allowedTools\": [\"Bash\"]}\n\n\u002F\u002F Or specific patterns\n{\"allowedTools\": [\"Bash(git *)\", \"Bash(npm *)\"]}\n```\n\n### Issue #12: Dangerous Command Execution\n\n**Error**: Accidental `rm -rf \u002F` or force push to main\n**Why It Happens**: No guardrails on destructive operations\n\n**Prevention**: Use PreToolUse hook with dangerous command guard (see Security section)\n\n---\n\n## Using Bundled Resources\n\n### Scripts (scripts\u002F)\n\n**1. dangerous-command-guard.py**\nPurpose: PreToolUse hook to block dangerous bash patterns\nUsage: Configure in settings.json (see Security section)\n\n**2. bash-audit-logger.sh**\nPurpose: Log all bash commands with timestamps\nUsage: Configure as PreToolUse hook\n\n**3. package-manager-enforcer.sh**\nPurpose: Enforce pnpm\u002Fyarn\u002Fnpm based on lockfile\nUsage: Configure as PreToolUse hook\n\n### References (references\u002F)\n\n**1. git-workflows.md**\nDeep dive into git automation patterns, commit message formats, PR creation\n\n**2. hooks-examples.md**\nComplete hooks configuration examples for common scenarios\n\n**3. cli-tool-integration.md**\nHow to integrate custom CLI tools with Claude Code\n\n**4. security-best-practices.md**\nComprehensive security guide for bash automation\n\n**5. troubleshooting-guide.md**\nDetailed solutions for all 12 known issues\n\n### Templates (templates\u002F)\n\n**1. settings.json**\nComplete settings.json with hooks examples\n\n**2. dangerous-commands.json**\nList of dangerous patterns to block\n\n**3. custom-command-template.md**\nTemplate for creating .claude\u002Fcommands\u002F files\n\n**4. github-workflow.yml**\nGitHub Actions integration with Claude Code\n\n**5. .envrc.example**\ndirenv integration for environment management\n\n---\n\n## Dependencies\n\n**Required**:\n- Claude Code CLI (latest version)\n- bash 4.0+ (persistent session support)\n\n**Optional (for specific features)**:\n- `jq` (JSON processing in hooks) - `brew install jq` \u002F `apt install jq`\n- `gh` (GitHub CLI integration) - `brew install gh` \u002F `apt install gh`\n- Python 3.7+ (for Python-based hooks)\n- direnv (environment management) - `brew install direnv`\n\n---\n\n## Official Documentation\n\n- **Bash Tool Reference**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Ftools\n- **Claude Code Hooks**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks\n- **Claude Code Best Practices**: https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fclaude-code-best-practices\n- **Code Execution with MCP**: https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fcode-execution-with-mcp\n- **Cloudflare Code Mode**: https:\u002F\u002Fblog.cloudflare.com\u002Fcode-mode\u002F\n\n---\n\n## Production Example\n\nThis skill is based on real-world usage across:\n- **WordPress Auditor**: Git workflows, PR automation\n- **claude-skills repo**: Custom commands, hooks configuration\n- **Multiple client projects**: CLI tool orchestration\n\n**Measured Impact**:\n- Token savings: ~55% (vs manual trial-and-error)\n- Error prevention: 12 documented issues → 0 occurrences\n- Time savings: ~40% faster workflows with parallel execution\n- Security: 100% dangerous command prevention with hooks\n\n---\n\n## Complete Setup Checklist\n\n- [ ] Claude Code CLI installed and updated\n- [ ] Bash 4.0+ available (`bash --version`)\n- [ ] jq installed (for hooks): `brew install jq` or `apt install jq`\n- [ ] gh CLI installed (for git workflows): `brew install gh` or `apt install gh`\n- [ ] Settings directory created: `mkdir -p ~\u002F.claude\u002Fhooks`\n- [ ] Copied hook scripts to `~\u002F.claude\u002Fhooks\u002F`\n- [ ] Made scripts executable: `chmod +x ~\u002F.claude\u002Fhooks\u002F*.sh`\n- [ ] Configured `~\u002F.claude\u002Fsettings.json` with desired hooks\n- [ ] Tested dangerous command guard\n- [ ] Verified bash audit logging\n- [ ] Created first custom command in `.claude\u002Fcommands\u002F`\n- [ ] Tested git workflow patterns\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Ftroubleshooting-guide.md` for detailed solutions\n2. Review `references\u002Fhooks-examples.md` for configuration examples\n3. Consult official docs: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks\n4. Verify all steps in setup checklist above\n","# Claude Code Bash Patterns\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-11-07\n**Dependencies**: Claude Code CLI (latest version)\n**Official Docs**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Ftools\n\n---\n\n## Quick Start (10 Minutes)\n\n### 1. Understanding the Bash Tool\n\nThe Bash tool is Claude Code's primary interface for executing command-line operations. Unlike specialized tools (Read, Grep, Glob), the Bash tool provides direct shell access for complex workflows.\n\n**Key Characteristics**:\n- **Session Persistence**: Commands run in a persistent bash session within a conversation\n- **Environment Inheritance**: Inherits environment variables and working directory\n- **Output Limit**: Truncates output at 30,000 characters\n- **Default Timeout**: 2 minutes (configurable up to 10 minutes)\n\n**When to Use Bash Tool**:\n- ✅ Running CLI tools (git, npm, wrangler, gh, etc.)\n- ✅ Command chaining (sequential operations)\n- ✅ Process orchestration (build, test, deploy)\n- ✅ Environment setup and management\n\n**When NOT to Use Bash Tool**:\n- ❌ Reading files → Use **Read** tool instead\n- ❌ Searching file patterns → Use **Glob** tool instead\n- ❌ Searching content → Use **Grep** tool instead\n- ❌ Editing files → Use **Edit** tool instead\n\n### 2. Basic Command Patterns\n\n```bash\n# Single command\nnpm install\n\n# Sequential with && (stops on first failure)\nnpm install && npm run build\n\n# Sequential with ; (continues regardless)\nnpm install ; npm run build\n\n# Parallel execution (make multiple Bash tool calls)\n# Call 1: git status\n# Call 2: git diff\n# Call 3: git log\n```\n\n**Golden Rule**: Use `&&` when you care about failures, `;` when you don't, and parallel calls when operations are independent.\n\n### 3. Configure Your First Hook\n\nHooks let you run code before\u002Fafter tool execution. Here's a simple audit logger:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"echo \\\"[$(date -Iseconds)] $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Fbash-audit.log\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nSave this to `~\u002F.claude\u002Fsettings.json` to log every bash command with timestamp.\n\n---\n\n## The Five Core Patterns\n\n### Pattern 1: Command Chaining\n\n**When to Use**: Sequential operations where each depends on previous success\n\n**Syntax**: `command1 && command2 && command3`\n\n**Example**: Build and deploy workflow\n```bash\nnpm install && npm run build && npx wrangler deploy\n```\n\n**Why It Matters**:\n- Stops on first failure (prevents cascading errors)\n- Maintains clean error messages (know exactly what failed)\n- Saves tokens (no need to check status between commands)\n\n**Anti-Pattern**: Using `;` when you care about failures\n```bash\n# ❌ Wrong: Continues even if install fails\nnpm install ; npm run build\n\n# ✅ Correct: Stops if install fails\nnpm install && npm run build\n```\n\n**Advanced**: Conditional execution with `||`\n```bash\n# Run tests, or echo failure message\nnpm test || echo \"Tests failed, not deploying\"\n\n# Try npm ci, fall back to npm install\nnpm ci || npm install\n```\n\n### Pattern 2: Parallel Execution\n\n**When to Use**: Independent operations that can run simultaneously\n\n**How**: Make multiple Bash tool calls in a single message\n\n**Example**: Git workflow pre-commit analysis\n```\n# Claude makes 3 parallel Bash calls in one message:\nCall 1: git status\nCall 2: git diff --staged\nCall 3: git log -5 --oneline\n```\n\n**Benefits**:\n- ~40% faster than sequential (no waiting between calls)\n- Reduces context usage (all results arrive together)\n- Better user experience (appears instant)\n\n**Important**: Only parallelize truly independent operations. If Call 2 depends on Call 1's output, run sequentially.\n\n### Pattern 3: HEREDOC for Multi-Line Content\n\n**When to Use**: Git commits, file creation, complex strings with newlines\n\n**Syntax**: `cat \u003C\u003C'EOF' ... EOF`\n\n**Example**: Git commit with detailed message\n```bash\ngit commit -m \"$(cat \u003C\u003C'EOF'\nfeat(auth): Add JWT verification middleware\n\nImplement custom JWT template support for Clerk auth.\nExtracts email and metadata claims for user context.\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude \u003Cnoreply@anthropic.com>\nEOF\n)\"\n```\n\n**Why Single Quotes**: `\u003C\u003C'EOF'` prevents variable expansion in the content. Use `\u003C\u003C\"EOF\"` if you want variables to expand.\n\n**Common Mistake**: Forgetting quotes around `$()` wrapper\n```bash\n# ❌ Wrong: Newlines lost\ngit commit -m $(cat \u003C\u003C'EOF'\nLine 1\nLine 2\nEOF\n)\n\n# ✅ Correct: Preserves newlines\ngit commit -m \"$(cat \u003C\u003C'EOF'\nLine 1\nLine 2\nEOF\n)\"\n```\n\n### Pattern 4: Output Capture and Processing\n\n**When to Use**: Need to process command output before using it\n\n**Pattern**: Command substitution with `$()`\n\n**Example**: Get current branch name\n```bash\nBRANCH=$(git rev-parse --abbrev-ref HEAD)\necho \"Current branch: $BRANCH\"\n```\n\n**Example**: Conditional logic based on output\n```bash\nif git diff --quiet; then\n  echo \"No changes detected\"\nelse\n  echo \"Changes detected, running tests...\"\n  npm test\nfi\n```\n\n**Limitation**: Output truncated at 30,000 characters. For large outputs:\n```bash\n# Limit output\nnpm test 2>&1 | head -100\n\n# Or save to file\nnpm test > test-results.txt && tail -50 test-results.txt\n```\n\n### Pattern 5: Conditional Execution\n\n**When to Use**: Different actions based on conditions\n\n**Pattern**: Test commands with `&&` \u002F `||`\n\n**Example**: Run tests only if files changed\n```bash\ngit diff --quiet || npm test\n```\n\n**Example**: Different commands based on file existence\n```bash\n[ -f package-lock.json ] && npm ci || npm install\n```\n\n**Example**: Multi-condition logic\n```bash\nif [ -f pnpm-lock.yaml ]; then\n  pnpm install\nelif [ -f yarn.lock ]; then\n  yarn install\nelse\n  npm install\nfi\n```\n\n---\n\n## Hooks: Advanced Automation\n\nHooks are shell commands or Claude prompts that run before\u002Fafter tool execution. They're your security guards, cleanup crew, and automation helpers.\n\n### PreToolUse: The Security Guard\n\n**Purpose**: Runs before tool execution, can block or modify behavior\n\n**Exit Codes**:\n- `0` = Allow execution\n- `1` = Block with generic error\n- `2` = Block with custom error message (from stderr)\n\n#### Use Case 1: Block Dangerous Commands\n\n**File**: `~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py`\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\nimport json\nimport sys\nimport re\n\n# Read hook input from stdin\ndata = json.load(sys.stdin)\ncommand = data.get('tool_input', {}).get('command', '')\n\n# Dangerous patterns to block\nDANGEROUS = [\n    r'rm\\s+-rf\\s+\u002F',           # Delete root\n    r'dd\\s+if=',                # Disk operations\n    r'mkfs\\.',                  # Format filesystem\n    r':()\\{.*\\}:',              # Fork bomb\n    r'sudo\\s+rm',               # Sudo delete\n    r'git\\s+push.*--force.*main',  # Force push to main\n]\n\nfor pattern in DANGEROUS:\n    if re.search(pattern, command):\n        print(f\"BLOCKED: Dangerous command pattern '{pattern}'\", file=sys.stderr)\n        sys.exit(2)\n\n# Allow execution\nsys.exit(0)\n```\n\n**Settings Configuration**:\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"python3 ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Use Case 2: Log All Bash Commands\n\n```json\n{\n  \"matcher\": \"Bash\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"echo \\\"[$(date -Iseconds)] $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Fbash-audit.log\"\n    }\n  ]\n}\n```\n\n**Result**: Every bash command logged with timestamp to `~\u002F.claude\u002Fbash-audit.log`\n\n#### Use Case 3: Enforce Package Manager\n\nCheck for lockfile and block wrong package manager:\n\n```bash\n#!\u002Fbin\u002Fbash\n# File: ~\u002F.claude\u002Fhooks\u002Fpackage-manager-enforcer.sh\n\nCOMMAND=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.command')\n\nif [ -f pnpm-lock.yaml ] && echo \"$COMMAND\" | grep -qE '^(npm|yarn) '; then\n  echo \"ERROR: This repo uses pnpm. Please use 'pnpm' instead of 'npm' or 'yarn'.\" >&2\n  exit 2\nfi\n\nif [ -f yarn.lock ] && echo \"$COMMAND\" | grep -qE '^(npm|pnpm) '; then\n  echo \"ERROR: This repo uses yarn. Please use 'yarn' instead of 'npm' or 'pnpm'.\" >&2\n  exit 2\nfi\n\nexit 0\n```\n\n### PostToolUse: The Cleanup Crew\n\n**Purpose**: Runs after successful tool execution (exit code 0 only)\n\n**Example**: Auto-format after file edits\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path'); [ -f \\\"$FILE\\\" ] && prettier --write \\\"$FILE\\\" || true\"\n    }\n  ]\n}\n```\n\n**Example**: Run tests after code changes\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path'); if echo \\\"$FILE\\\" | grep -qE '\\\\.(ts|tsx|js|jsx)$'; then npm test -- \\\"$FILE\\\"; fi\"\n    }\n  ]\n}\n```\n\n### SessionStart: Environment Setup\n\n**Purpose**: Runs once at session start, sets up environment\n\n**Example**: Load project-specific environment\n```json\n{\n  \"hooks\": {\n    \"SessionStart\": [\n      {\n        \"matcher\": \"*\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**Environment Variables Available in Hooks**:\n- `$CLAUDE_TOOL_INPUT` - JSON string of tool call\n- `$CLAUDE_ENV_FILE` - Path to environment file\n- Standard env vars (`$HOME`, `$USER`, `$PWD`, etc.)\n\n---\n\n## Git Workflows (Production-Tested)\n\nThese patterns are used by Anthropic's engineering team for 90%+ of git interactions.\n\n### Pattern: Intelligent Git Commits\n\n**Step 1**: Gather context (parallel calls)\n```bash\n# Call 1\ngit status\n\n# Call 2\ngit diff --staged\n\n# Call 3\ngit log -5 --oneline\n```\n\n**Why Parallel**: Independent operations, faster response, better UX\n\n**Step 2**: Analyze changes\n- Review **actual code changes** (not just file names!)\n- Match commit message style from git log\n- Focus on \"why\" not \"what\"\n- Keep message concise (1-2 sentences)\n\n**Step 3**: Commit with HEREDOC\n```bash\ngit add [files] && git commit -m \"$(cat \u003C\u003C'EOF'\nfeat(auth): Add JWT verification middleware\n\nImplement custom JWT template support for Clerk auth.\nExtracts email and metadata claims for user context.\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude \u003Cnoreply@anthropic.com>\nEOF\n)\"\n```\n\n**Step 4**: Verify\n```bash\ngit status\n```\n\n**Important**: If pre-commit hook modifies files:\n1. Check authorship: `git log -1 --format='%an %ae'`\n2. Check not pushed: `git status` (should show \"ahead of origin\")\n3. If both safe: `git add . && git commit --amend --no-edit`\n4. If not safe: `git add . && git commit -m \"Apply pre-commit hook changes\"`\n\n### Pattern: Pull Request Creation\n\n**Step 1**: Understand branch state (parallel)\n```bash\n# Call 1\ngit status\n\n# Call 2\ngit diff main...HEAD\n\n# Call 3\ngit log main..HEAD --oneline\n```\n\n**Step 2**: Analyze ALL commits (not just latest!)\n- What changed since branch diverged from main?\n- What's the overall goal of this branch?\n- What needs testing?\n\n**Step 3**: Create PR with gh CLI\n```bash\ngh pr create --title \"feat: User Authentication\" --body \"$(cat \u003C\u003C'EOF'\n## Summary\n- Implement JWT verification with Clerk\n- Add login\u002Flogout endpoints\n- Update database schema for users table\n\n## Test Plan\n- [ ] Verify JWT token validation\n- [ ] Test login flow\n- [ ] Test logout flow\n- [ ] Confirm database migrations work\n\n🤖 Generated with Claude Code\nEOF\n)\"\n```\n\n**Result**: Professional PR with clear summary and test plan\n\n---\n\n## CLI Tool Integration\n\n### GitHub CLI (gh)\n\nClaude knows gh CLI by default. Common patterns:\n\n```bash\n# View PR comments\ngh api repos\u002Fowner\u002Frepo\u002Fpulls\u002F123\u002Fcomments\n\n# Check CI status\ngh run list --limit 5\n\n# Create issue\ngh issue create --title \"Bug: Description\" --body \"Details here\"\n\n# Comment on PR\ngh pr comment 123 --body \"LGTM! 🚀\"\n```\n\n### Wrangler (Cloudflare)\n\nPrefix with `npx` for local install:\n\n```bash\n# Deploy worker\nnpx wrangler deploy\n\n# Run D1 migrations\nnpx wrangler d1 migrations apply my-db --remote\n\n# Tail logs\nnpx wrangler tail\n\n# Execute D1 query\nnpx wrangler d1 execute my-db --command \"SELECT * FROM users LIMIT 5\"\n```\n\n### Custom CLI Tools\n\n**How to teach Claude about your CLI**:\n\n**Option 1**: Document in CLAUDE.md\n```markdown\n## Custom Tools\n\n**mycli**: Internal deployment tool\nUsage: `mycli deploy --env production --service api`\nHelp: `mycli --help` for full options\nConfig: `.mycli.json` in project root\n```\n\n**Option 2**: Let Claude discover\n```markdown\nWhen encountering mycli commands, run `mycli --help` first to discover available options.\n```\n\n**Option 3**: Create custom command (`.claude\u002Fcommands\u002Fdeploy.md`)\n```markdown\nDeploy using our internal mycli tool:\n\n1. Run `mycli --version` to verify installation\n2. Check current environment: `mycli env current`\n3. Deploy to staging: `mycli deploy --env staging --service api`\n4. Run smoke tests: `mycli test smoke --env staging`\n5. If tests pass, deploy to production: `mycli deploy --env production --service api`\n```\n\n---\n\n## Security Configurations\n\n### 1. Dangerous Command Guard (PreToolUse Hook)\n\nSee bundled script: `scripts\u002Fdangerous-command-guard.py`\n\n**Blocks**:\n- `rm -rf \u002F` (delete root)\n- `dd if=` (disk operations)\n- `mkfs.*` (format filesystem)\n- `:(){ :|:& };:` (fork bomb)\n- `sudo rm` (dangerous sudo deletions)\n- `git push --force main` (force push to main branch)\n\n**Installation**:\n```bash\n# Copy script\ncp scripts\u002Fdangerous-command-guard.py ~\u002F.claude\u002Fhooks\u002F\nchmod +x ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\n\n# Configure in ~\u002F.claude\u002Fsettings.json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"python3 ~\u002F.claude\u002Fhooks\u002Fdangerous-command-guard.py\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### 2. Production File Protection\n\nPrevent modification of production config files:\n\n```json\n{\n  \"matcher\": \"Write|Edit\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"FILE=$(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.file_path \u002F\u002F empty'); if echo \\\"$FILE\\\" | grep -qE '(^|\\\\\u002F)(production\\\\.env|\\\\.env\\\\.production|prod\\\\.config)$'; then echo 'ERROR: Cannot modify production config files' >&2; exit 2; fi\"\n    }\n  ]\n}\n```\n\n### 3. Audit Logging\n\nLog all bash commands for compliance:\n\n```json\n{\n  \"matcher\": \"Bash\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"echo \\\"[$(date -Iseconds)] User: $USER | Command: $(echo \\\"$CLAUDE_TOOL_INPUT\\\" | jq -r '.tool_input.command')\\\" >> ~\u002F.claude\u002Faudit.log\"\n    }\n  ]\n}\n```\n\n**View audit log**:\n```bash\ntail -50 ~\u002F.claude\u002Faudit.log\n```\n\n---\n\n## Custom Commands (.claude\u002Fcommands\u002F)\n\nCustom commands are markdown files that expand into prompts when invoked.\n\n### Creating Custom Commands\n\n**File**: `.claude\u002Fcommands\u002Fdeploy-staging.md`\n```markdown\nDeploy the current branch to staging environment:\n\n1. Verify branch is not main (exit if main)\n2. Run full test suite (npm test)\n3. Build production bundle (npm run build)\n4. Deploy with wrangler to staging (npx wrangler deploy --env staging)\n5. Run smoke tests against staging URL\n6. Share deployment URL with user\n```\n\n**Usage**:\n```\nUser: \u002Fdeploy-staging\nClaude: [Executes the workflow from the markdown file]\n```\n\n### Best Practices for Custom Commands\n\n✅ **Do**:\n- Make them atomic (one clear workflow)\n- Include verification steps\n- Document expected state\n- Add rollback instructions\n- Use imperative language\n\n❌ **Don't**:\n- Make them too complex (split into multiple commands)\n- Include interactive prompts\n- Assume state (always verify)\n\n**Example Command Library**:\n- `\u002Fdeploy-staging` - Deploy to staging\n- `\u002Fdeploy-production` - Deploy to production (with safety checks)\n- `\u002Frun-tests` - Run full test suite\n- `\u002Fcheck-types` - TypeScript type checking\n- `\u002Fformat-code` - Format all code files\n- `\u002Fcreate-migration` - Create database migration\n\n---\n\n## Critical Rules\n\n### Always Do ✅\n\n**1. Use Specialized Tools First**\n\nBash is powerful but inefficient for tasks with dedicated tools:\n\n```bash\n# ❌ Wrong: Use Bash for file reading\ncat file.txt\n\n# ✅ Correct: Use Read tool\nRead(file_path=\"file.txt\")\n```\n\n```bash\n# ❌ Wrong: Use Bash for file search\nfind . -name \"*.ts\"\n\n# ✅ Correct: Use Glob tool\nGlob(pattern=\"**\u002F*.ts\")\n```\n\n```bash\n# ❌ Wrong: Use Bash for content search\ngrep \"pattern\" file.txt\n\n# ✅ Correct: Use Grep tool\nGrep(pattern=\"pattern\", path=\"file.txt\")\n```\n\n**Why**: Specialized tools are faster, use fewer tokens, and provide better formatting.\n\n**2. Quote Paths with Spaces**\n\n```bash\n# ❌ Wrong: Breaks on spaces\ncd \u002FUsers\u002Fname\u002FMy Documents\n\n# ✅ Correct: Quoted path\ncd \"\u002FUsers\u002Fname\u002FMy Documents\"\n```\n\n**3. Use && for Dependencies**\n\n```bash\n# ❌ Wrong: Continues even if install fails\nnpm install ; npm run build\n\n# ✅ Correct: Stops on failure\nnpm install && npm run build\n```\n\n**4. Parallel for Independent Operations**\n\n```bash\n# ❌ Wrong: Sequential when could be parallel\ngit status && git diff && git log\n\n# ✅ Correct: Make 3 parallel Bash tool calls in one message\n```\n\n**5. HEREDOC for Multi-line Strings**\n\n```bash\n# ❌ Wrong: Escaping nightmare\ngit commit -m \"line1\\nline2\\nline3\"\n\n# ✅ Correct: HEREDOC\ngit commit -m \"$(cat \u003C\u003C'EOF'\nline1\nline2\nline3\nEOF\n)\"\n```\n\n**6. Always Provide Description**\n\n```bash\n# ❌ Wrong: No context for user\nBash(command=\"complex-script.sh\")\n\n# ✅ Correct: Clear purpose\nBash(\n  command=\"complex-script.sh\",\n  description=\"Run integration tests on staging database\"\n)\n```\n\n### Never Do ❌\n\n**1. Don't Use Interactive Commands**\n\nCommands that require user input will hang:\n\n```bash\n# ❌ Wrong: Will hang waiting for input\nvim file.txt\nnano file.txt\nless output.txt\nnpm install  # If package.json has prompts\n\n# ✅ Correct: Use non-interactive alternatives\n# Use Edit\u002FWrite tools for file editing\nnpm install --yes\n```\n\n**2. Don't Chain with Newlines**\n\n```bash\n# ❌ Wrong: Doesn't work as expected\ncommand1\ncommand2\n\n# ✅ Correct: Use && or ;\ncommand1 && command2\n```\n\n**3. Don't Ignore Exit Codes**\n\n```bash\n# ❌ Wrong: Success message even if command failed\nrisky-command ; echo \"Success!\"\n\n# ✅ Correct: Check exit code\nrisky-command && echo \"Success!\" || echo \"Failed!\"\n```\n\n**4. Don't Use cd Excessively**\n\nIn agent mode, working directory doesn't persist between calls:\n\n```bash\n# ❌ Wrong: cd doesn't persist\n# Call 1: cd \u002Fpath\u002Fto\u002Fproject\n# Call 2: npm test  # Runs in original directory!\n\n# ✅ Correct: Use absolute paths or --prefix\nnpm test --prefix \u002Fpath\u002Fto\u002Fproject\n\n# ✅ Or chain in single command\ncd \u002Fpath\u002Fto\u002Fproject && npm test\n```\n\n**5. Don't Skip Error Handling**\n\n```bash\n# ❌ Wrong: No error handling\n.\u002Fscript.sh\n.\u002Fcleanup.sh\n\n# ✅ Correct: Handle failures\n.\u002Fscript.sh || { echo \"Script failed\" >&2; exit 1; }\n.\u002Fcleanup.sh\n```\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **12** documented issues with sources:\n\n### Issue #1: Git Bash cygpath Command Not Found (Windows)\n\n**Error**: `bash: line 1: cygpath: command not found`\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F9883\n**Why It Happens**: Bash tool attempts to use cygpath (Cygwin-only) on MSYS\u002FGit Bash\n\n**Prevention**:\n- Use WSL instead of Git Bash on Windows\n- Configure `CLAUDE_CODE_GIT_BASH_PATH` if using Git Bash\n- Install Cygwin if cygpath is required\n\n### Issue #2: Pipe Command Failures\n\n**Error**: `echo test|grep test` returns error instead of \"test\"\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F774\n**Why It Happens**: Pipe parsing issues in certain configurations\n\n**Prevention**:\n```bash\n# ❌ Avoid direct pipes\necho test|grep test\n\n# ✅ Use explicit bash -c\nbash -c 'echo test | grep test'\n\n# ✅ Or use specialized tools (Grep tool instead)\n```\n\n### Issue #3: Command Timeout (Hanging Promises)\n\n**Error**: `A hanging Promise was canceled`\n**Source**: Bash tool default timeout is 2 minutes\n**Why It Happens**: Long-running commands without timeout configuration\n\n**Prevention**:\n```bash\n# For long operations, set timeout explicitly\nBash(\n  command=\"npm run build\",\n  timeout=600000,  # 10 minutes\n  description=\"Build production bundle (may take several minutes)\"\n)\n\n# Or run in background\nBash(\n  command=\"npm run build > build.log 2>&1 &\",\n  description=\"Start build in background\"\n)\n```\n\n### Issue #4: Output Truncation Loss\n\n**Error**: Important output missing from response\n**Source**: Bash tool truncates output at 30,000 characters\n**Why It Happens**: Large command outputs exceed limit\n\n**Prevention**:\n```bash\n# ❌ Wrong: Full output may be truncated\nnpm test\n\n# ✅ Correct: Limit output\nnpm test 2>&1 | head -100\n\n# ✅ Or save to file\nnpm test > test-results.txt && tail -50 test-results.txt\n```\n\n### Issue #5: \"No Suitable Shell Found\" (Windows)\n\n**Error**: CLI fails with \"No suitable shell found\"\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F3461\n**Why It Happens**: Shell detection issues in Git Bash environment\n\n**Prevention**:\n- Set SHELL environment variable explicitly\n- Use WSL for better compatibility\n- Install latest Claude Code CLI version\n\n### Issue #6: Bash Tool Access Loss\n\n**Error**: Claude loses ability to run Bash() tool\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F1888\n**Why It Happens**: Session state corruption, often after overnight idle\n\n**Prevention**:\n- Restart Claude Code session if Bash becomes unavailable\n- Check permissions with `\u002Fpermissions` command\n- Use `restart: true` parameter to reset bash session\n\n### Issue #7: Interactive Prompt Hangs\n\n**Error**: Command hangs indefinitely, no output\n**Why It Happens**: Command expects interactive input (password, confirmation)\n\n**Prevention**:\n```bash\n# ❌ Wrong: Will hang\nnpm install  # If package.json has interactive prompts\n\n# ✅ Correct: Non-interactive flags\nnpm install --yes\n\n# ✅ Correct: Provide input via stdin\necho \"yes\" | command-that-needs-confirmation\n```\n\n### Issue #8: Permission Denied Errors\n\n**Error**: `permission denied` or `command not found`\n**Why It Happens**: Script not executable or not in PATH\n\n**Prevention**:\n```bash\n# Make script executable first\nchmod +x script.sh && .\u002Fscript.sh\n\n# Use full path\n\u002Fusr\u002Flocal\u002Fbin\u002Fmycli deploy\n\n# Or use interpreter directly\npython3 script.py\nnode script.js\n```\n\n### Issue #9: Environment Variables Not Persisting\n\n**Error**: Variable set in one command not available in next\n**Why It Happens**: Agent threads reset environment between calls\n\n**Prevention**:\n```bash\n# ❌ Wrong: Split across calls\n# Call 1: export API_KEY=abc123\n# Call 2: curl -H \"Authorization: $API_KEY\" ...  # $API_KEY empty!\n\n# ✅ Correct: Same command\nexport API_KEY=abc123 && curl -H \"Authorization: $API_KEY\" ...\n\n# ✅ Or use SessionStart hook\n```\n\n### Issue #10: Git Commit Hook Modifications Not Detected\n\n**Error**: Pre-commit hook changes files, but commit fails\n**Why It Happens**: Hook modifies files after staging\n\n**Prevention**:\n```bash\n# After commit fails due to hook changes:\n# 1. Check if you can amend (not pushed, authored by you)\ngit log -1 --format='%an %ae'\n\n# 2. If safe, amend\ngit add . && git commit --amend --no-edit\n\n# 3. If not safe, make new commit\ngit add . && git commit -m \"Apply pre-commit hook changes\"\n```\n\n### Issue #11: Wildcard Permission Matching Not Working\n\n**Error**: `Bash(*)` or `Bash(*:*)` doesn't grant access\n**Source**: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F462\n**Why It Happens**: Syntax mismatch in allowlisting\n\n**Prevention**:\n```json\n\u002F\u002F ❌ Wrong\n{\"allowedTools\": [\"Bash(*)\"]}\n\n\u002F\u002F ✅ Correct\n{\"allowedTools\": [\"Bash\"]}\n\n\u002F\u002F Or specific patterns\n{\"allowedTools\": [\"Bash(git *)\", \"Bash(npm *)\"]}\n```\n\n### Issue #12: Dangerous Command Execution\n\n**Error**: Accidental `rm -rf \u002F` or force push to main\n**Why It Happens**: No guardrails on destructive operations\n\n**Prevention**: Use PreToolUse hook with dangerous command guard (see Security section)\n\n---\n\n## Using Bundled Resources\n\n### Scripts (scripts\u002F)\n\n**1. dangerous-command-guard.py**\nPurpose: PreToolUse hook to block dangerous bash patterns\nUsage: Configure in settings.json (see Security section)\n\n**2. bash-audit-logger.sh**\nPurpose: Log all bash commands with timestamps\nUsage: Configure as PreToolUse hook\n\n**3. package-manager-enforcer.sh**\nPurpose: Enforce pnpm\u002Fyarn\u002Fnpm based on lockfile\nUsage: Configure as PreToolUse hook\n\n### References (references\u002F)\n\n**1. git-workflows.md**\nDeep dive into git automation patterns, commit message formats, PR creation\n\n**2. hooks-examples.md**\nComplete hooks configuration examples for common scenarios\n\n**3. cli-tool-integration.md**\nHow to integrate custom CLI tools with Claude Code\n\n**4. security-best-practices.md**\nComprehensive security guide for bash automation\n\n**5. troubleshooting-guide.md**\nDetailed solutions for all 12 known issues\n\n### Templates (templates\u002F)\n\n**1. settings.json**\nComplete settings.json with hooks examples\n\n**2. dangerous-commands.json**\nList of dangerous patterns to block\n\n**3. custom-command-template.md**\nTemplate for creating .claude\u002Fcommands\u002F files\n\n**4. github-workflow.yml**\nGitHub Actions integration with Claude Code\n\n**5. .envrc.example**\ndirenv integration for environment management\n\n---\n\n## Dependencies\n\n**Required**:\n- Claude Code CLI (latest version)\n- bash 4.0+ (persistent session support)\n\n**Optional (for specific features)**:\n- `jq` (JSON processing in hooks) - `brew install jq` \u002F `apt install jq`\n- `gh` (GitHub CLI integration) - `brew install gh` \u002F `apt install gh`\n- Python 3.7+ (for Python-based hooks)\n- direnv (environment management) - `brew install direnv`\n\n---\n\n## Official Documentation\n\n- **Bash Tool Reference**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Ftools\n- **Claude Code Hooks**: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks\n- **Claude Code Best Practices**: https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fclaude-code-best-practices\n- **Code Execution with MCP**: https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fcode-execution-with-mcp\n- **Cloudflare Code Mode**: https:\u002F\u002Fblog.cloudflare.com\u002Fcode-mode\u002F\n\n---\n\n## Production Example\n\nThis skill is based on real-world usage across:\n- **WordPress Auditor**: Git workflows, PR automation\n- **claude-skills repo**: Custom commands, hooks configuration\n- **Multiple client projects**: CLI tool orchestration\n\n**Measured Impact**:\n- Token savings: ~55% (vs manual trial-and-error)\n- Error prevention: 12 documented issues → 0 occurrences\n- Time savings: ~40% faster workflows with parallel execution\n- Security: 100% dangerous command prevention with hooks\n\n---\n\n## Complete Setup Checklist\n\n- [ ] Claude Code CLI installed and updated\n- [ ] Bash 4.0+ available (`bash --version`)\n- [ ] jq installed (for hooks): `brew install jq` or `apt install jq`\n- [ ] gh CLI installed (for git workflows): `brew install gh` or `apt install gh`\n- [ ] Settings directory created: `mkdir -p ~\u002F.claude\u002Fhooks`\n- [ ] Copied hook scripts to `~\u002F.claude\u002Fhooks\u002F`\n- [ ] Made scripts executable: `chmod +x ~\u002F.claude\u002Fhooks\u002F*.sh`\n- [ ] Configured `~\u002F.claude\u002Fsettings.json` with desired hooks\n- [ ] Tested dangerous command guard\n- [ ] Verified bash audit logging\n- [ ] Created first custom command in `.claude\u002Fcommands\u002F`\n- [ ] Tested git workflow patterns\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Ftroubleshooting-guide.md` for detailed solutions\n2. Review `references\u002Fhooks-examples.md` for configuration examples\n3. Consult official docs: https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fhooks\n4. Verify all steps in setup checklist above\n",{"name":5,"license":14,"metadata":23,"description":31},{"author":24,"status":25,"version":26,"last_updated":27,"token_savings":28,"errors_prevented":29,"production_tested":30},"Jeremy Dawes (Jezweb)","production_ready","1.0.0",1762473600000,"55%",12,"wordpress-auditor, claude-skills, multiple client projects","Comprehensive knowledge for using the Bash tool in Claude Code effectively. This skill\nshould be used when orchestrating CLI tools, configuring hooks, setting up automation\nworkflows, managing git operations, handling multi-command patterns, or encountering\nBash tool errors.\n\nCovers: PreToolUse hooks, command chaining patterns, git workflow automation, CLI tool\nintegration, custom commands (.claude\u002Fcommands\u002F), security configurations, allowlisting,\nsession persistence, output handling, error prevention, and troubleshooting common issues.\n\nUse when: setting up Claude Code hooks, configuring bash permissions, creating custom\ncommands, automating git workflows, orchestrating multiple CLI tools, debugging bash\ncommand failures, implementing security guards, logging command execution, or preventing\ndangerous operations.\n","main","6b73b29e4866f997b1eb47fe8d9631396265fc24",0,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn","2026-09-09 16:06:07",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add davidanthonyn\u002Fagent-skills --skill claude-code-bash-patterns",{"tool":44,"command":45},"bunx","bunx skills add davidanthonyn\u002Fagent-skills --skill claude-code-bash-patterns",{"tool":47,"command":48},"pnpm","pnpm dlx skills add davidanthonyn\u002Fagent-skills --skill claude-code-bash-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fclaude-code-bash-patterns\u002FSKILL.md",true,[52,58,62],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"README.md","REFERENCE","参考文档",10337,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fclaude-code-bash-patterns\u002FREADME.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"SKILL.json",28717,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fclaude-code-bash-patterns\u002FSKILL.json",{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"SKILL.md.backup","OTHER","其他",28800,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fclaude-code-bash-patterns\u002FSKILL.md.backup",[69,76,84,91,98,107],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M7AQNJDXVNVMN08N5BHBGZBF","zustand-state-management","Production-tested setup for Zustand state management in React applications with TypeScript.\nThis skill provides comprehensive patterns for building scalable, type-safe global state.\n\nUse when: setting up global state in React, migrating from Redux or Context API, implementing\nstate persistence with localStorage, configuring TypeScript with Zustand, using slices pattern\nfor modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration,\nor encountering hydration errors, TypeScript inference issues, or persist middleware problems.\n\nPrevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses\nsyntax errors, persist middleware export errors, infinite render loops, and slices pattern\ntype inference failures.\n\nKeywords: zustand, state management, React state, TypeScript state, persist middleware,\ndevtools, slices pattern, global state, React hooks, create store, useBoundStore,\nStateCreator, hydration error, text content mismatch, infinite render, localStorage,\nsessionStorage, immer middleware, shallow equality, selector pattern, zustand v5","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M7AQN2DW9DTPM8BYNZSHQANC","zetic-mlange","Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin\u002FJava) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android\u002FiOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch\u002FONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M7AQMEK370FBPC75N2W8WA4W","youtube-downloader","Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3\u002FM4A\u002FFLAC, downloading entire playlists\u002Fchannels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M7AQHKQ4VQB04NH6BG4SV9Q7","wordpress-plugin-core","This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks\u002Ffilters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types\u002Ftaxonomies, building admin interfaces, or working with the WordPress database.\n\nUse when: Creating new WordPress plugins, implementing nonces\u002Fsanitization\u002Fescaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation\u002Fdeactivation issues, preventing SQL injection\u002FXSS\u002FCSRF vulnerabilities.\n\nKeywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":102,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":18},"01M7AQH4JW8F2MJFS1C43TZ2TY","webapp-testing","Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":18},"01M7AQH0PWD6Z1NN66V15DT25M","web-performance-audit","Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fweb-performance-audit\u002FSKILL.md",[],[]]