Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
chore: Delete claude-code-bash-patterns skill
Jez79b443c3e7dd
diff --git a/SESSION.md b/SESSION.mdindex c06d516c..2facb299 100644--- a/SESSION.md+++ b/SESSION.md@@ -1551,6 +1551,50 @@ Build with Claude Messages API using structured outputs (v0.69.0+, Nov 2025) for---+## Claude-Code-Bash-Patterns Skill - DELETED ❌++**Analysis Date**: 2025-11-23+**Decision**: DELETED (not worth maintaining)+**Reason**: Redundant with official Claude Code documentation++### Research Findings ✅++**Claude Code Bash Tool & Hooks Updates (Nov 2025):**++1. **No Substantial Nov 2025 Updates:**+ - Changelog only extends to early 2025+ - No significant Bash tool improvements in Nov 2025+ - Minor: Auto-backgrounding with `BASH_DEFAULT_TIMEOUT_MS`+ - Minor: `tool_use_id` field added to hooks++2. **Hooks System Known Bugs:**+ - PreToolUse/PostToolUse hooks not firing reliably (GitHub #6305, #6403, #3148)+ - Makes ~40% of skill content unreliable++3. **Breaking Changes Suggest Simplification:**+ - Sandbox feature removed from Bash tool+ - Output styles deprecated → use CLAUDE.md instead+ - Bash tool clarified as "for terminal operations only"++4. **Official Docs Comprehensive:**+ - https://docs.claude.com/en/docs/claude-code/tools (Bash tool)+ - https://docs.claude.com/en/docs/claude-code/hooks-guide (Hooks system)+ - All patterns already well-documented++### Why Deleted:++1. **Official docs excellent** - Claude Code docs cover Bash tool + hooks comprehensively+2. **Hooks buggy** - Multiple reports of PreToolUse/PostToolUse not working+3. **Minimal knowledge gaps** - No substantial Nov 2025 updates worth preserving+4. **Redundant with LLM training** - Standard bash patterns (&&, ||, HEREDOC) already known+5. **Niche value** - 12 "known issues" mostly Windows-specific edge cases+6. **Author skill** - Created by user, not production-validated patterns++**Lines Removed**: 1,186 lines (~3,950 tokens)+**Impact**: Cleaner skill library, reduced maintenance burden++---+## Phase 2 Summary So Far**Skills Completed:**@@ -1602,6 +1646,8 @@ Build with Claude Messages API using structured outputs (v0.69.0+, Nov 2025) for18. ✅ Trimmed claude-api (530 lines, 56.5% reduction, v0.69.0 structured outputs + model deprecations + Haiku 4.5 added)19. ✅ Audited clerk-auth (research phase + trim)20. ✅ Trimmed clerk-auth (420 lines, 47% reduction, API v2025-11-10 breaking changes + PKCE + Client Trust defense added)+21. ✅ Evaluated claude-code-bash-patterns (research phase)+22. ✅ DELETED claude-code-bash-patterns (1,186 lines removed - redundant with official docs, hooks buggy, minimal knowledge gaps)**Next Session:**1. Continue A-Z systematic audit (next: cloudflare-agents)diff --git a/skills/claude-code-bash-patterns/.claude-plugin/plugin.json b/skills/claude-code-bash-patterns/.claude-plugin/plugin.jsondeleted file mode 100644index e9ee3342..00000000--- a/skills/claude-code-bash-patterns/.claude-plugin/plugin.json+++ /dev/null@@ -1,12 +0,0 @@-{- "name": "claude-code-bash-patterns",- "description": "Master Claude Code Bash tool with PreToolUse hooks, command chaining, git automation, custom commands. Use when: configuring hooks, orchestrating CLI tools, managing multi-command workflows, or troubleshooting cygpath command not found, pipe command failed, permission errors.",- "version": "1.0.0",- "author": {- "name": "Jeremy Dawes",- "email": "[email protected]"- },- "license": "MIT",- "repository": "https://github.com/jezweb/claude-skills",- "keywords": []-}diff --git a/skills/claude-code-bash-patterns/README.md b/skills/claude-code-bash-patterns/README.mddeleted file mode 100644index 284c366a..00000000--- a/skills/claude-code-bash-patterns/README.md+++ /dev/null@@ -1,314 +0,0 @@-# claude-code-bash-patterns--**Status**: Production Ready ✅-**Last Updated**: 2025-11-07-**Production Tested**: wordpress-auditor, claude-skills, multiple client projects-------## Auto-Trigger Keywords--### Primary Keywords-- claude code bash-- bash tool-- CLI automation-- PreToolUse hooks-- PostToolUse hooks-- command chaining-- git automation-- gh CLI-- custom commands-- .claude/commands-- settings.json-- hook configuration-- tool allowlisting-- bash permissions-- session persistence-- command logging--### CLI Tool Keywords-- wrangler CLI-- npm automation-- pnpm scripts-- git workflows-- github CLI-- docker commands-- kubectl automation-- terraform CLI-- aws CLI--### Error-Based Keywords (Auto-Trigger)-- "cygpath command not found"-- "pipe command failed"-- "no suitable shell found"-- "command timeout"-- "permission denied bash"-- "hanging promise canceled"-- "bash tool access loss"-- "output truncated"-- "interactive prompt hangs"-- "environment variable not persisting"-- "pre-commit hook"-- "wildcard permission"--### Security Keywords-- dangerous commands-- security guards-- audit logging-- command blocking-- bash security--### Pattern Keywords-- sequential commands-- parallel execution-- conditional execution-- HEREDOC format-- output capture-- command substitution-- error handling-------## What This Skill Does--Comprehensive knowledge for using Claude Code's Bash tool effectively, including CLI orchestration, hooks automation, security configurations, and error prevention. This is a meta-skill that teaches how to work with command-line tools in Claude Code.--### Core Capabilities--✅ **CLI Tool Orchestration**: Sequential, parallel, and conditional command patterns-✅ **Git Workflow Automation**: Intelligent commits, PR creation, branch management-✅ **Hooks Configuration**: PreToolUse, PostToolUse, SessionStart automation-✅ **Security Guards**: Dangerous command blocking, audit logging, allowlisting-✅ **Custom Commands**: Create reusable workflows in .claude/commands/-✅ **Multi-CLI Integration**: gh, wrangler, npm, docker, terraform, etc.-✅ **Error Prevention**: 12 documented issues with sources-✅ **Session Management**: Environment persistence, output handling-------## Known Issues This Skill Prevents--| Issue | Why It Happens | Source | How Skill Fixes It |-|-------|---------------|---------|-------------------|-| **cygpath command not found** | MSYS/Git Bash lacks Cygwin tools | [Issue #9883](https://github.com/anthropics/claude-code/issues/9883) | Use WSL or configure CLAUDE_CODE_GIT_BASH_PATH |-| **Pipe command failures** | Pipe parsing issues | [Issue #774](https://github.com/anthropics/claude-code/issues/774) | Use `bash -c` wrapper or specialized tools |-| **Command timeout** | Long operations without timeout config | Bash tool docs | Set explicit timeout parameter (up to 10 min) |-| **Output truncation** | Output exceeds 30k char limit | Bash tool docs | Limit with `head` or save to file |-| **"No suitable shell"** | Windows shell detection | [Issue #3461](https://github.com/anthropics/claude-code/issues/3461) | Set SHELL env var, use WSL |-| **Bash access loss** | Session state corruption | [Issue #1888](https://github.com/anthropics/claude-code/issues/1888) | Restart session or use `restart: true` |-| **Interactive prompt hangs** | Command expects input | Bash tool docs | Use `--yes` flags or provide stdin |-| **Permission denied** | Script not executable | Common pattern | `chmod +x` before execution |-| **Env vars not persisting** | Agent thread CWD reset | Claude Code system | Chain commands or use SessionStart hook |-| **Pre-commit hook issues** | Hook modifies staged files | Git workflow pattern | Check authorship, amend or new commit |-| **Wildcard allowlist fails** | Syntax mismatch | [Issue #462](https://github.com/anthropics/claude-code/issues/462) | Use correct pattern syntax |-| **Dangerous commands** | No guardrails | Security best practice | Implement PreToolUse guard hook |-------## When to Use This Skill--### ✅ Use When:-- Setting up Claude Code hooks-- Automating git workflows (commits, PRs)-- Orchestrating multiple CLI tools-- Implementing security guards-- Creating custom commands-- Debugging bash command failures-- Configuring bash permissions-- Logging command execution-- Preventing dangerous operations-- Integrating custom CLI tools-- Working with wrangler, gh, npm, docker, etc.-- Encountering any error listed above--### ❌ Don't Use When:-- Simple file reading → Use **Read** tool instead-- File pattern matching → Use **Glob** tool instead-- Content searching → Use **Grep** tool instead-- Basic text editing → Use **Edit** tool instead-------## Quick Usage Example--### 1. Configure Dangerous Command Guard--```bash-# Install hook script-mkdir -p ~/.claude/hooks-# (Copy dangerous-command-guard.py from this skill's scripts/ directory)-chmod +x ~/.claude/hooks/dangerous-command-guard.py--# Configure in ~/.claude/settings.json-cat > ~/.claude/settings.json <<'EOF'-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]- }- ]- }-}-EOF-```--### 2. Create Custom Deploy Command--```bash-# Create custom command-cat > .claude/commands/deploy.md <<'EOF'-Run full deployment workflow:--1. Run tests (npm test)-2. Build production (npm run build)-3. Deploy to Cloudflare (npx wrangler deploy)-4. Verify deployment health check-EOF-```--### 3. Use It--```-User: /deploy-Claude: [Executes the workflow automatically]-```--**Result**: Automated, secure CLI workflows with 100% error prevention--**Full instructions**: See [SKILL.md](SKILL.md)-------## Token Efficiency Metrics--| Approach | Tokens Used | Errors Encountered | Time to Setup |-|----------|------------|-------------------|---------------|-| **Manual Setup** | ~8,500 | 2-3 | ~15 min |-| **With This Skill** | ~3,800 | 0 ✅ | ~5 min |-| **Savings** | **~55%** ⬇️ | **100%** ✅ | **~67%** ⬇️ |--**Evidence**:-- Manual approach: Trial-and-error with bash commands, debugging pipes, figuring out hooks syntax-- With skill: Load metadata + reference patterns + apply directly-- Measured across multiple production projects-------## Package Versions (Verified 2025-11-07)--| Package/Tool | Version | Status |-|-------------|---------|--------|-| Claude Code CLI | Latest (2025-11-07) | ✅ Current |-| bash | 4.0+ | ✅ Required |-| jq | 1.6+ | ✅ Recommended |-| gh CLI | 2.0+ | ✅ Optional |-| Python | 3.7+ | ✅ For hooks |-| Git | 2.0+ | ✅ For workflows |-------## Dependencies--**Prerequisites**:-- Claude Code CLI (latest version)-- bash 4.0+ (persistent session support)--**Integrates With**:-- git workflows (built-in)-- gh CLI (GitHub automation)-- wrangler (Cloudflare deployments)-- npm/pnpm/yarn (package management)-- docker, kubectl, terraform (infrastructure)-- Any custom CLI tool--**Optional**:-- `jq` for JSON processing in hooks-- `gh` for GitHub automation-- Python 3.7+ for Python-based hooks-- `direnv` for environment management-------## File Structure--```-claude-code-bash-patterns/-├── SKILL.md # Complete documentation (~4,500 words)-├── README.md # This file-├── scripts/ # Hook scripts (executable)-│ ├── dangerous-command-guard.py # Block unsafe commands-│ ├── bash-audit-logger.sh # Log all bash commands-│ └── package-manager-enforcer.sh # Enforce lockfile consistency-├── references/ # Deep-dive guides-│ ├── git-workflows.md # Git automation patterns-│ ├── hooks-examples.md # Complete hooks configurations-│ ├── cli-tool-integration.md # Custom tool integration-│ ├── security-best-practices.md # Security hardening-│ └── troubleshooting-guide.md # Detailed issue solutions-└── templates/ # Configuration templates- ├── settings.json # Complete settings example- ├── dangerous-commands.json # Command block patterns- ├── custom-command-template.md # .claude/commands/ template- ├── github-workflow.yml # CI/CD integration- └── .envrc.example # Environment setup-```-------## Official Documentation--- **Bash Tool Reference**: https://docs.claude.com/en/docs/claude-code/tools-- **Claude Code Hooks**: https://docs.claude.com/en/docs/claude-code/hooks-- **Best Practices**: https://www.anthropic.com/engineering/claude-code-best-practices-- **Code Execution with MCP**: https://www.anthropic.com/engineering/code-execution-with-mcp-- **Cloudflare Code Mode**: https://blog.cloudflare.com/code-mode/-------## Related Skills--- **project-planning** - Use for structuring development workflows-- **cloudflare-worker-base** - Integrates wrangler CLI patterns-- **typescript-mcp** - CLI tool creation patterns-- **elevenlabs-agents** - ElevenLabs CLI patterns-------## The Five Core Patterns (Quick Reference)--1. **Command Chaining**: `cmd1 && cmd2 && cmd3` (stops on failure)-2. **Parallel Execution**: Make multiple Bash calls in one message (40% faster)-3. **HEREDOC**: `cat <<'EOF' ... EOF` for multi-line content (git commits, PRs)-4. **Output Capture**: `VAR=$(command)` for processing output-5. **Conditional Execution**: `cmd1 || cmd2` for fallback logic-------## Production Validation--**Real-World Usage**:-- ✅ WordPress Auditor project (git workflows, hooks, security)-- ✅ claude-skills repository (custom commands, automation)-- ✅ Multiple client projects (CLI orchestration, deployments)--**Measured Impact**:-- Token savings: **55%** (8,500 → 3,800 tokens)-- Error prevention: **100%** (12 issues → 0 occurrences)-- Time savings: **67%** (15 min → 5 min)-- Security: **100%** dangerous command prevention--**Evidence**:-- Anthropic's engineering team uses these patterns for 90%+ of git interactions-- Code-first approach documented in official blog posts-- All errors sourced from GitHub issues or official documentation-------**Ready to use!** See [SKILL.md](SKILL.md) for complete setup and examples.diff --git a/skills/claude-code-bash-patterns/SKILL.md b/skills/claude-code-bash-patterns/SKILL.mddeleted file mode 100644index 1519f337..00000000--- a/skills/claude-code-bash-patterns/SKILL.md+++ /dev/null@@ -1,1185 +0,0 @@-----name: claude-code-bash-patterns-description: |- Master Claude Code Bash tool with PreToolUse hooks, command chaining, git automation, custom commands. Use when: configuring hooks, orchestrating CLI tools, managing multi-command workflows, or troubleshooting "cygpath command not found", "pipe command failed", permission errors.-license: MIT-metadata:- author: Jeremy Dawes (Jezweb)- version: 1.0.0- last_updated: 2025-11-07- production_tested: wordpress-auditor, claude-skills, multiple client projects- token_savings: 55%- errors_prevented: 12- status: production_ready- keywords:- - claude code bash- - bash tool- - PreToolUse hooks- - command chaining- - git automation- - CLI orchestration- - .claude/commands- - security allowlisting- - session persistence- - bash patterns- - wrangler CLI- - npm automation- - pnpm scripts- - cygpath command not found- - pipe command failed- - no suitable shell found------# Claude Code Bash Patterns--**Status**: Production Ready ✅-**Last Updated**: 2025-11-07-**Dependencies**: Claude Code CLI (latest version)-**Official Docs**: https://docs.claude.com/en/docs/claude-code/tools-------## Quick Start (10 Minutes)--### 1. Understanding the Bash Tool--The 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.--**Key Characteristics**:-- **Session Persistence**: Commands run in a persistent bash session within a conversation-- **Environment Inheritance**: Inherits environment variables and working directory-- **Output Limit**: Truncates output at 30,000 characters-- **Default Timeout**: 2 minutes (configurable up to 10 minutes)--**When to Use Bash Tool**:-- ✅ Running CLI tools (git, npm, wrangler, gh, etc.)-- ✅ Command chaining (sequential operations)-- ✅ Process orchestration (build, test, deploy)-- ✅ Environment setup and management--**When NOT to Use Bash Tool**:-- ❌ Reading files → Use **Read** tool instead-- ❌ Searching file patterns → Use **Glob** tool instead-- ❌ Searching content → Use **Grep** tool instead-- ❌ Editing files → Use **Edit** tool instead--### 2. Basic Command Patterns--```bash-# Single command-npm install--# Sequential with && (stops on first failure)-npm install && npm run build--# Sequential with ; (continues regardless)-npm install ; npm run build--# Parallel execution (make multiple Bash tool calls)-# Call 1: git status-# Call 2: git diff-# Call 3: git log-```--**Golden Rule**: Use `&&` when you care about failures, `;` when you don't, and parallel calls when operations are independent.--### 3. Configure Your First Hook--Hooks let you run code before/after tool execution. Here's a simple audit logger:--```json-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "echo \"[$(date -Iseconds)] $(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.command')\" >> ~/.claude/bash-audit.log"- }- ]- }- ]- }-}-```--Save this to `~/.claude/settings.json` to log every bash command with timestamp.-------## The Five Core Patterns--### Pattern 1: Command Chaining--**When to Use**: Sequential operations where each depends on previous success--**Syntax**: `command1 && command2 && command3`--**Example**: Build and deploy workflow-```bash-npm install && npm run build && npx wrangler deploy-```--**Why It Matters**:-- Stops on first failure (prevents cascading errors)-- Maintains clean error messages (know exactly what failed)-- Saves tokens (no need to check status between commands)--**Anti-Pattern**: Using `;` when you care about failures-```bash-# ❌ Wrong: Continues even if install fails-npm install ; npm run build--# ✅ Correct: Stops if install fails-npm install && npm run build-```--**Advanced**: Conditional execution with `||`-```bash-# Run tests, or echo failure message-npm test || echo "Tests failed, not deploying"--# Try npm ci, fall back to npm install-npm ci || npm install-```--### Pattern 2: Parallel Execution--**When to Use**: Independent operations that can run simultaneously--**How**: Make multiple Bash tool calls in a single message--**Example**: Git workflow pre-commit analysis-```-# Claude makes 3 parallel Bash calls in one message:-Call 1: git status-Call 2: git diff --staged-Call 3: git log -5 --oneline-```--**Benefits**:-- ~40% faster than sequential (no waiting between calls)-- Reduces context usage (all results arrive together)-- Better user experience (appears instant)--**Important**: Only parallelize truly independent operations. If Call 2 depends on Call 1's output, run sequentially.--### Pattern 3: HEREDOC for Multi-Line Content--**When to Use**: Git commits, file creation, complex strings with newlines--**Syntax**: `cat <<'EOF' ... EOF`--**Example**: Git commit with detailed message-```bash-git commit -m "$(cat <<'EOF'-feat(auth): Add JWT verification middleware--Implement custom JWT template support for Clerk auth.-Extracts email and metadata claims for user context.--🤖 Generated with Claude Code--Co-Authored-By: Claude <[email protected]>-EOF-)"-```--**Why Single Quotes**: `<<'EOF'` prevents variable expansion in the content. Use `<<"EOF"` if you want variables to expand.--**Common Mistake**: Forgetting quotes around `$()` wrapper-```bash-# ❌ Wrong: Newlines lost-git commit -m $(cat <<'EOF'-Line 1-Line 2-EOF-)--# ✅ Correct: Preserves newlines-git commit -m "$(cat <<'EOF'-Line 1-Line 2-EOF-)"-```--### Pattern 4: Output Capture and Processing--**When to Use**: Need to process command output before using it--**Pattern**: Command substitution with `$()`--**Example**: Get current branch name-```bash-BRANCH=$(git rev-parse --abbrev-ref HEAD)-echo "Current branch: $BRANCH"-```--**Example**: Conditional logic based on output-```bash-if git diff --quiet; then- echo "No changes detected"-else- echo "Changes detected, running tests..."- npm test-fi-```--**Limitation**: Output truncated at 30,000 characters. For large outputs:-```bash-# Limit output-npm test 2>&1 | head -100--# Or save to file-npm test > test-results.txt && tail -50 test-results.txt-```--### Pattern 5: Conditional Execution--**When to Use**: Different actions based on conditions--**Pattern**: Test commands with `&&` / `||`--**Example**: Run tests only if files changed-```bash-git diff --quiet || npm test-```--**Example**: Different commands based on file existence-```bash-[ -f package-lock.json ] && npm ci || npm install-```--**Example**: Multi-condition logic-```bash-if [ -f pnpm-lock.yaml ]; then- pnpm install-elif [ -f yarn.lock ]; then- yarn install-else- npm install-fi-```-------## Hooks: Advanced Automation--Hooks are shell commands or Claude prompts that run before/after tool execution. They're your security guards, cleanup crew, and automation helpers.--### PreToolUse: The Security Guard--**Purpose**: Runs before tool execution, can block or modify behavior--**Exit Codes**:-- `0` = Allow execution-- `1` = Block with generic error-- `2` = Block with custom error message (from stderr)--#### Use Case 1: Block Dangerous Commands--**File**: `~/.claude/hooks/dangerous-command-guard.py`-```python-#!/usr/bin/env python3-import json-import sys-import re--# Read hook input from stdin-data = json.load(sys.stdin)-command = data.get('tool_input', {}).get('command', '')--# Dangerous patterns to block-DANGEROUS = [- r'rm\s+-rf\s+/', # Delete root- r'dd\s+if=', # Disk operations- r'mkfs\.', # Format filesystem- r':()\{.*\}:', # Fork bomb- r'sudo\s+rm', # Sudo delete- r'git\s+push.*--force.*main', # Force push to main-]--for pattern in DANGEROUS:- if re.search(pattern, command):- print(f"BLOCKED: Dangerous command pattern '{pattern}'", file=sys.stderr)- sys.exit(2)--# Allow execution-sys.exit(0)-```--**Settings Configuration**:-```json-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]- }- ]- }-}-```--#### Use Case 2: Log All Bash Commands--```json-{- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "echo \"[$(date -Iseconds)] $(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.command')\" >> ~/.claude/bash-audit.log"- }- ]-}-```--**Result**: Every bash command logged with timestamp to `~/.claude/bash-audit.log`--#### Use Case 3: Enforce Package Manager--Check for lockfile and block wrong package manager:--```bash-#!/bin/bash-# File: ~/.claude/hooks/package-manager-enforcer.sh--COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_input.command')--if [ -f pnpm-lock.yaml ] && echo "$COMMAND" | grep -qE '^(npm|yarn) '; then- echo "ERROR: This repo uses pnpm. Please use 'pnpm' instead of 'npm' or 'yarn'." >&2- exit 2-fi--if [ -f yarn.lock ] && echo "$COMMAND" | grep -qE '^(npm|pnpm) '; then- echo "ERROR: This repo uses yarn. Please use 'yarn' instead of 'npm' or 'pnpm'." >&2- exit 2-fi--exit 0-```--### PostToolUse: The Cleanup Crew--**Purpose**: Runs after successful tool execution (exit code 0 only)--**Example**: Auto-format after file edits-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); [ -f \"$FILE\" ] && prettier --write \"$FILE\" || true"- }- ]-}-```--**Example**: Run tests after code changes-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "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"- }- ]-}-```--### SessionStart: Environment Setup--**Purpose**: Runs once at session start, sets up environment--**Example**: Load project-specific environment-```json-{- "hooks": {- "SessionStart": [- {- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE"- }- ]- }- ]- }-}-```--**Environment Variables Available in Hooks**:-- `$CLAUDE_TOOL_INPUT` - JSON string of tool call-- `$CLAUDE_ENV_FILE` - Path to environment file-- Standard env vars (`$HOME`, `$USER`, `$PWD`, etc.)-------## Git Workflows (Production-Tested)--These patterns are used by Anthropic's engineering team for 90%+ of git interactions.--### Pattern: Intelligent Git Commits--**Step 1**: Gather context (parallel calls)-```bash-# Call 1-git status--# Call 2-git diff --staged--# Call 3-git log -5 --oneline-```--**Why Parallel**: Independent operations, faster response, better UX--**Step 2**: Analyze changes-- Review **actual code changes** (not just file names!)-- Match commit message style from git log-- Focus on "why" not "what"-- Keep message concise (1-2 sentences)--**Step 3**: Commit with HEREDOC-```bash-git add [files] && git commit -m "$(cat <<'EOF'-feat(auth): Add JWT verification middleware--Implement custom JWT template support for Clerk auth.-Extracts email and metadata claims for user context.--🤖 Generated with Claude Code--Co-Authored-By: Claude <[email protected]>-EOF-)"-```--**Step 4**: Verify-```bash-git status-```--**Important**: If pre-commit hook modifies files:-1. Check authorship: `git log -1 --format='%an %ae'`-2. Check not pushed: `git status` (should show "ahead of origin")-3. If both safe: `git add . && git commit --amend --no-edit`-4. If not safe: `git add . && git commit -m "Apply pre-commit hook changes"`--### Pattern: Pull Request Creation--**Step 1**: Understand branch state (parallel)-```bash-# Call 1-git status--# Call 2-git diff main...HEAD--# Call 3-git log main..HEAD --oneline-```--**Step 2**: Analyze ALL commits (not just latest!)-- What changed since branch diverged from main?-- What's the overall goal of this branch?-- What needs testing?--**Step 3**: Create PR with gh CLI-```bash-gh pr create --title "feat: User Authentication" --body "$(cat <<'EOF'-## Summary-- Implement JWT verification with Clerk-- Add login/logout endpoints-- Update database schema for users table--## Test Plan-- [ ] Verify JWT token validation-- [ ] Test login flow-- [ ] Test logout flow-- [ ] Confirm database migrations work--🤖 Generated with Claude Code-EOF-)"-```--**Result**: Professional PR with clear summary and test plan-------## CLI Tool Integration--### GitHub CLI (gh)--Claude knows gh CLI by default. Common patterns:--```bash-# View PR comments-gh api repos/owner/repo/pulls/123/comments--# Check CI status-gh run list --limit 5--# Create issue-gh issue create --title "Bug: Description" --body "Details here"--# Comment on PR-gh pr comment 123 --body "LGTM! 🚀"-```--### Wrangler (Cloudflare)--Prefix with `npx` for local install:--```bash-# Deploy worker-npx wrangler deploy--# Run D1 migrations-npx wrangler d1 migrations apply my-db --remote--# Tail logs-npx wrangler tail--# Execute D1 query-npx wrangler d1 execute my-db --command "SELECT * FROM users LIMIT 5"-```--### Custom CLI Tools--**How to teach Claude about your CLI**:--**Option 1**: Document in CLAUDE.md-```markdown-## Custom Tools--**mycli**: Internal deployment tool-Usage: `mycli deploy --env production --service api`-Help: `mycli --help` for full options-Config: `.mycli.json` in project root-```--**Option 2**: Let Claude discover-```markdown-When encountering mycli commands, run `mycli --help` first to discover available options.-```--**Option 3**: Create custom command (`.claude/commands/deploy.md`)-```markdown-Deploy using our internal mycli tool:--1. Run `mycli --version` to verify installation-2. Check current environment: `mycli env current`-3. Deploy to staging: `mycli deploy --env staging --service api`-4. Run smoke tests: `mycli test smoke --env staging`-5. If tests pass, deploy to production: `mycli deploy --env production --service api`-```-------## Security Configurations--### 1. Dangerous Command Guard (PreToolUse Hook)--See bundled script: `scripts/dangerous-command-guard.py`--**Blocks**:-- `rm -rf /` (delete root)-- `dd if=` (disk operations)-- `mkfs.*` (format filesystem)-- `:(){ :|:& };:` (fork bomb)-- `sudo rm` (dangerous sudo deletions)-- `git push --force main` (force push to main branch)--**Installation**:-```bash-# Copy script-cp scripts/dangerous-command-guard.py ~/.claude/hooks/-chmod +x ~/.claude/hooks/dangerous-command-guard.py--# Configure in ~/.claude/settings.json-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]- }- ]- }-}-```--### 2. Production File Protection--Prevent modification of production config files:--```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path // empty'); if echo \"$FILE\" | grep -qE '(^|\\/)(production\\.env|\\.env\\.production|prod\\.config)$'; then echo 'ERROR: Cannot modify production config files' >&2; exit 2; fi"- }- ]-}-```--### 3. Audit Logging--Log all bash commands for compliance:--```json-{- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "echo \"[$(date -Iseconds)] User: $USER | Command: $(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.command')\" >> ~/.claude/audit.log"- }- ]-}-```--**View audit log**:-```bash-tail -50 ~/.claude/audit.log-```-------## Custom Commands (.claude/commands/)--Custom commands are markdown files that expand into prompts when invoked.--### Creating Custom Commands--**File**: `.claude/commands/deploy-staging.md`-```markdown-Deploy the current branch to staging environment:--1. Verify branch is not main (exit if main)-2. Run full test suite (npm test)-3. Build production bundle (npm run build)-4. Deploy with wrangler to staging (npx wrangler deploy --env staging)-5. Run smoke tests against staging URL-6. Share deployment URL with user-```--**Usage**:-```-User: /deploy-staging-Claude: [Executes the workflow from the markdown file]-```--### Best Practices for Custom Commands--✅ **Do**:-- Make them atomic (one clear workflow)-- Include verification steps-- Document expected state-- Add rollback instructions-- Use imperative language--❌ **Don't**:-- Make them too complex (split into multiple commands)-- Include interactive prompts-- Assume state (always verify)--**Example Command Library**:-- `/deploy-staging` - Deploy to staging-- `/deploy-production` - Deploy to production (with safety checks)-- `/run-tests` - Run full test suite-- `/check-types` - TypeScript type checking-- `/format-code` - Format all code files-- `/create-migration` - Create database migration-------## Critical Rules--### Always Do ✅--**1. Use Specialized Tools First**--Bash is powerful but inefficient for tasks with dedicated tools:--```bash-# ❌ Wrong: Use Bash for file reading-cat file.txt--# ✅ Correct: Use Read tool-Read(file_path="file.txt")-```--```bash-# ❌ Wrong: Use Bash for file search-find . -name "*.ts"--# ✅ Correct: Use Glob tool-Glob(pattern="**/*.ts")-```--```bash-# ❌ Wrong: Use Bash for content search-grep "pattern" file.txt--# ✅ Correct: Use Grep tool-Grep(pattern="pattern", path="file.txt")-```--**Why**: Specialized tools are faster, use fewer tokens, and provide better formatting.--**2. Quote Paths with Spaces**--```bash-# ❌ Wrong: Breaks on spaces-cd /Users/name/My Documents--# ✅ Correct: Quoted path-cd "/Users/name/My Documents"-```--**3. Use && for Dependencies**--```bash-# ❌ Wrong: Continues even if install fails-npm install ; npm run build--# ✅ Correct: Stops on failure-npm install && npm run build-```--**4. Parallel for Independent Operations**--```bash-# ❌ Wrong: Sequential when could be parallel-git status && git diff && git log--# ✅ Correct: Make 3 parallel Bash tool calls in one message-```--**5. HEREDOC for Multi-line Strings**--```bash-# ❌ Wrong: Escaping nightmare-git commit -m "line1\nline2\nline3"--# ✅ Correct: HEREDOC-git commit -m "$(cat <<'EOF'-line1-line2-line3-EOF-)"-```--**6. Always Provide Description**--```bash-# ❌ Wrong: No context for user-Bash(command="complex-script.sh")--# ✅ Correct: Clear purpose-Bash(- command="complex-script.sh",- description="Run integration tests on staging database"-)-```--### Never Do ❌--**1. Don't Use Interactive Commands**--Commands that require user input will hang:--```bash-# ❌ Wrong: Will hang waiting for input-vim file.txt-nano file.txt-less output.txt-npm install # If package.json has prompts--# ✅ Correct: Use non-interactive alternatives-# Use Edit/Write tools for file editing-npm install --yes-```--**2. Don't Chain with Newlines**--```bash-# ❌ Wrong: Doesn't work as expected-command1-command2--# ✅ Correct: Use && or ;-command1 && command2-```--**3. Don't Ignore Exit Codes**--```bash-# ❌ Wrong: Success message even if command failed-risky-command ; echo "Success!"--# ✅ Correct: Check exit code-risky-command && echo "Success!" || echo "Failed!"-```--**4. Don't Use cd Excessively**--In agent mode, working directory doesn't persist between calls:--```bash-# ❌ Wrong: cd doesn't persist-# Call 1: cd /path/to/project-# Call 2: npm test # Runs in original directory!--# ✅ Correct: Use absolute paths or --prefix-npm test --prefix /path/to/project--# ✅ Or chain in single command-cd /path/to/project && npm test-```--**5. Don't Skip Error Handling**--```bash-# ❌ Wrong: No error handling-./script.sh-./cleanup.sh--# ✅ Correct: Handle failures-./script.sh || { echo "Script failed" >&2; exit 1; }-./cleanup.sh-```-------## Known Issues Prevention--This skill prevents **12** documented issues with sources:--### Issue #1: Git Bash cygpath Command Not Found (Windows)--**Error**: `bash: line 1: cygpath: command not found`-**Source**: https://github.com/anthropics/claude-code/issues/9883-**Why It Happens**: Bash tool attempts to use cygpath (Cygwin-only) on MSYS/Git Bash--**Prevention**:-- Use WSL instead of Git Bash on Windows-- Configure `CLAUDE_CODE_GIT_BASH_PATH` if using Git Bash-- Install Cygwin if cygpath is required--### Issue #2: Pipe Command Failures--**Error**: `echo test|grep test` returns error instead of "test"-**Source**: https://github.com/anthropics/claude-code/issues/774-**Why It Happens**: Pipe parsing issues in certain configurations--**Prevention**:-```bash-# ❌ Avoid direct pipes-echo test|grep test--# ✅ Use explicit bash -c-bash -c 'echo test | grep test'--# ✅ Or use specialized tools (Grep tool instead)-```--### Issue #3: Command Timeout (Hanging Promises)--**Error**: `A hanging Promise was canceled`-**Source**: Bash tool default timeout is 2 minutes-**Why It Happens**: Long-running commands without timeout configuration--**Prevention**:-```bash-# For long operations, set timeout explicitly-Bash(- command="npm run build",- timeout=600000, # 10 minutes- description="Build production bundle (may take several minutes)"-)--# Or run in background-Bash(- command="npm run build > build.log 2>&1 &",- description="Start build in background"-)-```--### Issue #4: Output Truncation Loss--**Error**: Important output missing from response-**Source**: Bash tool truncates output at 30,000 characters-**Why It Happens**: Large command outputs exceed limit--**Prevention**:-```bash-# ❌ Wrong: Full output may be truncated-npm test--# ✅ Correct: Limit output-npm test 2>&1 | head -100--# ✅ Or save to file-npm test > test-results.txt && tail -50 test-results.txt-```--### Issue #5: "No Suitable Shell Found" (Windows)--**Error**: CLI fails with "No suitable shell found"-**Source**: https://github.com/anthropics/claude-code/issues/3461-**Why It Happens**: Shell detection issues in Git Bash environment--**Prevention**:-- Set SHELL environment variable explicitly-- Use WSL for better compatibility-- Install latest Claude Code CLI version--### Issue #6: Bash Tool Access Loss--**Error**: Claude loses ability to run Bash() tool-**Source**: https://github.com/anthropics/claude-code/issues/1888-**Why It Happens**: Session state corruption, often after overnight idle--**Prevention**:-- Restart Claude Code session if Bash becomes unavailable-- Check permissions with `/permissions` command-- Use `restart: true` parameter to reset bash session--### Issue #7: Interactive Prompt Hangs--**Error**: Command hangs indefinitely, no output-**Why It Happens**: Command expects interactive input (password, confirmation)--**Prevention**:-```bash-# ❌ Wrong: Will hang-npm install # If package.json has interactive prompts--# ✅ Correct: Non-interactive flags-npm install --yes--# ✅ Correct: Provide input via stdin-echo "yes" | command-that-needs-confirmation-```--### Issue #8: Permission Denied Errors--**Error**: `permission denied` or `command not found`-**Why It Happens**: Script not executable or not in PATH--**Prevention**:-```bash-# Make script executable first-chmod +x script.sh && ./script.sh--# Use full path-/usr/local/bin/mycli deploy--# Or use interpreter directly-python3 script.py-node script.js-```--### Issue #9: Environment Variables Not Persisting--**Error**: Variable set in one command not available in next-**Why It Happens**: Agent threads reset environment between calls--**Prevention**:-```bash-# ❌ Wrong: Split across calls-# Call 1: export API_KEY=abc123-# Call 2: curl -H "Authorization: $API_KEY" ... # $API_KEY empty!--# ✅ Correct: Same command-export API_KEY=abc123 && curl -H "Authorization: $API_KEY" ...--# ✅ Or use SessionStart hook-```--### Issue #10: Git Commit Hook Modifications Not Detected--**Error**: Pre-commit hook changes files, but commit fails-**Why It Happens**: Hook modifies files after staging--**Prevention**:-```bash-# After commit fails due to hook changes:-# 1. Check if you can amend (not pushed, authored by you)-git log -1 --format='%an %ae'--# 2. If safe, amend-git add . && git commit --amend --no-edit--# 3. If not safe, make new commit-git add . && git commit -m "Apply pre-commit hook changes"-```--### Issue #11: Wildcard Permission Matching Not Working--**Error**: `Bash(*)` or `Bash(*:*)` doesn't grant access-**Source**: https://github.com/anthropics/claude-code/issues/462-**Why It Happens**: Syntax mismatch in allowlisting--**Prevention**:-```json-// ❌ Wrong-{"allowedTools": ["Bash(*)"]}--// ✅ Correct-{"allowedTools": ["Bash"]}--// Or specific patterns-{"allowedTools": ["Bash(git *)", "Bash(npm *)"]}-```--### Issue #12: Dangerous Command Execution--**Error**: Accidental `rm -rf /` or force push to main-**Why It Happens**: No guardrails on destructive operations--**Prevention**: Use PreToolUse hook with dangerous command guard (see Security section)-------## Using Bundled Resources--### Scripts (scripts/)--**1. dangerous-command-guard.py**-Purpose: PreToolUse hook to block dangerous bash patterns-Usage: Configure in settings.json (see Security section)--**2. bash-audit-logger.sh**-Purpose: Log all bash commands with timestamps-Usage: Configure as PreToolUse hook--**3. package-manager-enforcer.sh**-Purpose: Enforce pnpm/yarn/npm based on lockfile-Usage: Configure as PreToolUse hook--### References (references/)--**1. git-workflows.md**-Deep dive into git automation patterns, commit message formats, PR creation--**2. hooks-examples.md**-Complete hooks configuration examples for common scenarios--**3. cli-tool-integration.md**-How to integrate custom CLI tools with Claude Code--**4. security-best-practices.md**-Comprehensive security guide for bash automation--**5. troubleshooting-guide.md**-Detailed solutions for all 12 known issues--### Templates (templates/)--**1. settings.json**-Complete settings.json with hooks examples--**2. dangerous-commands.json**-List of dangerous patterns to block--**3. custom-command-template.md**-Template for creating .claude/commands/ files--**4. github-workflow.yml**-GitHub Actions integration with Claude Code--**5. .envrc.example**-direnv integration for environment management-------## Dependencies--**Required**:-- Claude Code CLI (latest version)-- bash 4.0+ (persistent session support)--**Optional (for specific features)**:-- `jq` (JSON processing in hooks) - `brew install jq` / `apt install jq`-- `gh` (GitHub CLI integration) - `brew install gh` / `apt install gh`-- Python 3.7+ (for Python-based hooks)-- direnv (environment management) - `brew install direnv`-------## Official Documentation--- **Bash Tool Reference**: https://docs.claude.com/en/docs/claude-code/tools-- **Claude Code Hooks**: https://docs.claude.com/en/docs/claude-code/hooks-- **Claude Code Best Practices**: https://www.anthropic.com/engineering/claude-code-best-practices-- **Code Execution with MCP**: https://www.anthropic.com/engineering/code-execution-with-mcp-- **Cloudflare Code Mode**: https://blog.cloudflare.com/code-mode/-------## Production Example--This skill is based on real-world usage across:-- **WordPress Auditor**: Git workflows, PR automation-- **claude-skills repo**: Custom commands, hooks configuration-- **Multiple client projects**: CLI tool orchestration--**Measured Impact**:-- Token savings: ~55% (vs manual trial-and-error)-- Error prevention: 12 documented issues → 0 occurrences-- Time savings: ~40% faster workflows with parallel execution-- Security: 100% dangerous command prevention with hooks-------## Complete Setup Checklist--- [ ] Claude Code CLI installed and updated-- [ ] Bash 4.0+ available (`bash --version`)-- [ ] jq installed (for hooks): `brew install jq` or `apt install jq`-- [ ] gh CLI installed (for git workflows): `brew install gh` or `apt install gh`-- [ ] Settings directory created: `mkdir -p ~/.claude/hooks`-- [ ] Copied hook scripts to `~/.claude/hooks/`-- [ ] Made scripts executable: `chmod +x ~/.claude/hooks/*.sh`-- [ ] Configured `~/.claude/settings.json` with desired hooks-- [ ] Tested dangerous command guard-- [ ] Verified bash audit logging-- [ ] Created first custom command in `.claude/commands/`-- [ ] Tested git workflow patterns-------**Questions? Issues?**--1. Check `references/troubleshooting-guide.md` for detailed solutions-2. Review `references/hooks-examples.md` for configuration examples-3. Consult official docs: https://docs.claude.com/en/docs/claude-code/hooks-4. Verify all steps in setup checklist abovediff --git a/skills/claude-code-bash-patterns/references/cli-tool-integration.md b/skills/claude-code-bash-patterns/references/cli-tool-integration.mddeleted file mode 100644index 2ff626e2..00000000--- a/skills/claude-code-bash-patterns/references/cli-tool-integration.md+++ /dev/null@@ -1,258 +0,0 @@-# CLI Tool Integration with Claude Code--How to integrate custom CLI tools with Claude Code.-------## Quick Guide--### Step 1: Document in CLAUDE.md--```markdown-## Custom Tools--**mycli**: Internal deployment tool-- Installation: `npm install -g @company/mycli`-- Authentication: `mycli login`-- Usage: `mycli deploy --env <environment> --service <name>`-- Help: `mycli --help`-- Config: `.mycli.json` in project root-```--### Step 2: Create Custom Commands--**File**: `.claude/commands/deploy-with-mycli.md`--```markdown-Deploy using mycli tool:--1. Verify mycli installed (`which mycli`)-2. Check authentication (`mycli whoami`)-3. Deploy to staging (`mycli deploy --env staging --service api`)-4. Run health check-5. If healthy, report success-```--### Step 3: Let Claude Discover--Claude will:-1. See tool mentioned in CLAUDE.md-2. Run `mycli --help` to learn options-3. Use tool based on discovered capabilities-------## Integration Patterns--### Pattern 1: Well-Known Tools (Auto-Discovered)--Claude knows these by default:-- git, gh (GitHub CLI)-- npm, pnpm, yarn-- docker, kubectl-- terraform, ansible-- aws, gcloud, azure--**No configuration needed!**--### Pattern 2: Tools with Good Help Text--If tool has `--help`, Claude can discover:--```bash-# Claude will run this automatically-mycli --help-```--**Requirement**: Help text must include:-- Available commands-- Common options-- Usage examples--### Pattern 3: Tools Requiring Documentation--For complex tools, document in CLAUDE.md:--```markdown-## mcp-cli Tool--**Installation**:-```bash-npx @modelcontextprotocol/create-server my-server-```--**Common Commands**:-- `mcp-cli init` - Initialize project-- `mcp-cli dev` - Start dev server-- `mcp-cli build` - Build for production-- `mcp-cli deploy --provider cloudflare` - Deploy--**Configuration**: Edit `mcp.config.json`--**Authentication**: Set `MCP_API_KEY` environment variable-```-------## Examples--### Example 1: Wrangler (Cloudflare)--**CLAUDE.md**:-```markdown-## Wrangler CLI--Always prefix with `npx` for local install:-- `npx wrangler dev` - Start local dev server-- `npx wrangler deploy` - Deploy to Cloudflare-- `npx wrangler d1 execute <db> --command "SQL"` - Run D1 query-- `npx wrangler tail` - Stream logs--Configuration in `wrangler.jsonc`-```--**Usage**:-```bash-npx wrangler d1 execute my-db --command "SELECT * FROM users LIMIT 5"-```--### Example 2: ElevenLabs CLI--**CLAUDE.md**:-```markdown-## ElevenLabs CLI--**Installation**: `npm install -g @11labs/elevenlabs`--**Authentication**:-```bash-elevenlabs auth login-# Stores API key in ~/.agents/api_keys.json-```--**Commands**:-- `elevenlabs agents push --env dev` - Deploy to dev-- `elevenlabs agents logs --tail` - Stream logs-- `elevenlabs agents list` - List deployed agents--**Multi-environment**: dev, staging, production-```--**Usage**:-```bash-elevenlabs agents push --env staging-```--### Example 3: Custom Internal Tool--**CLAUDE.md**:-```markdown-## deploy-bot (Internal Tool)--**What It Does**: Automated deployment with approvals--**Installation**: `npm install -g @company/deploy-bot`--**Setup**:-```bash-deploy-bot init-# Creates .deploy-bot.yml config-```--**Commands**:-- `deploy-bot check` - Pre-deployment validation-- `deploy-bot deploy --env <env>` - Deploy with approval workflow-- `deploy-bot rollback` - Rollback last deployment-- `deploy-bot status` - Show deployment status--**Workflow**:-1. Run `deploy-bot check` to validate-2. Run `deploy-bot deploy --env staging`-3. Tool requests approval (manual step)-4. After approval, deploys automatically-5. Runs health checks-6. If healthy, marks as successful--**Configuration**: `.deploy-bot.yml`-```yaml-environments:- staging:- url: https://staging.example.com- approvers: [user1, user2]- production:- url: https://example.com- approvers: [admin1, admin2]- require_tests: true-```-```-------## Best Practices--### ✅ Do:-- Document installation steps-- Show authentication process-- Include common commands-- Provide usage examples-- Explain configuration files-- Note environment variables--### ❌ Don't:-- Assume tool is installed-- Skip authentication steps-- Use undocumented flags-- Ignore error messages-------## Troubleshooting--### Tool Not Found--**Problem**: `command not found: mycli`--**Solution**:-```bash-# Check if installed-which mycli--# Install if missing-npm install -g mycli--# Verify installation-mycli --version-```--### Authentication Issues--**Problem**: `Authentication failed`--**Solution**:-```bash-# Re-authenticate-mycli login--# Or set API key-export MYCLI_API_KEY="your-key"-```--### Version Mismatch--**Problem**: `This command requires version 2.0+`--**Solution**:-```bash-# Check current version-mycli --version--# Update-npm update -g mycli--# Verify update-mycli --version-```-------**Production Validated**: Patterns used with wrangler, gh, elevenlabs, and custom tools.diff --git a/skills/claude-code-bash-patterns/references/git-workflows.md b/skills/claude-code-bash-patterns/references/git-workflows.mddeleted file mode 100644index ddb2875d..00000000--- a/skills/claude-code-bash-patterns/references/git-workflows.md+++ /dev/null@@ -1,557 +0,0 @@-# Git Workflows with Claude Code--Production-tested patterns for git automation using Claude Code's Bash tool.-------## Table of Contents--1. [Intelligent Git Commits](#intelligent-git-commits)-2. [Pull Request Automation](#pull-request-automation)-3. [Branch Management](#branch-management)-4. [Pre-Commit Hook Handling](#pre-commit-hook-handling)-5. [Common Patterns](#common-patterns)-------## Intelligent Git Commits--### The Three-Step Pattern--**Step 1: Gather Context (Parallel)**--Make 3 parallel Bash calls:-```bash-# Call 1-git status--# Call 2-git diff --staged--# Call 3-git log -5 --oneline-```--**Why Parallel**: Independent operations, 40% faster than sequential.--**Step 2: Analyze Changes**--✅ **Do**:-- Review actual code changes (not just filenames)-- Match commit message style from `git log`-- Focus on "why" not "what"-- Keep message concise (1-2 sentences)-- Follow conventional commits format if project uses it--❌ **Don't**:-- Only look at file names-- Use vague messages ("update code", "fix bug")-- Write commit message before seeing changes--**Step 3: Commit with HEREDOC**--```bash-git add [files] && git commit -m "$(cat <<'EOF'-feat(auth): Add JWT verification middleware--Implement custom JWT template support for Clerk auth.-Extracts email and metadata claims for user context.--🤖 Generated with Claude Code--Co-Authored-By: Claude <[email protected]>-EOF-)"-```--**Step 4: Verify**--```bash-git status-```--### Conventional Commits Format--```-<type>(<scope>): <subject>--<body>--<footer>-```--**Types**:-- `feat`: New feature-- `fix`: Bug fix-- `docs`: Documentation-- `style`: Formatting (no code change)-- `refactor`: Code restructuring-- `perf`: Performance improvement-- `test`: Adding tests-- `chore`: Maintenance--**Example**:-```-feat(api): Add user authentication endpoint--Implement JWT-based authentication with refresh tokens.-Integrates with Clerk for user management.--Closes #123-```-------## Pull Request Automation--### The Four-Step Pattern--**Step 1: Understand Branch State (Parallel)**--```bash-# Call 1-git status--# Call 2-git diff main...HEAD--# Call 3-git log main..HEAD --oneline-```--**Key**: Use `main...HEAD` (three dots) to see changes since branch diverged.--**Step 2: Analyze ALL Commits**--❌ **Wrong**: Only look at latest commit-✅ **Correct**: Review entire branch history--Questions to answer:-- What changed since branch diverged from main?-- What's the overall goal?-- What needs testing?-- Are there breaking changes?--**Step 3: Create PR with gh CLI**--```bash-gh pr create --title "feat: User Authentication" --body "$(cat <<'EOF'-## Summary-- Implement JWT verification with Clerk-- Add login/logout endpoints-- Update database schema for users table--## Changes-- New `auth/` directory with middleware-- Database migration for users table-- Integration tests for auth flow--## Test Plan-- [ ] Verify JWT token validation-- [ ] Test login flow (valid credentials)-- [ ] Test login flow (invalid credentials)-- [ ] Test logout flow-- [ ] Confirm database migrations work-- [ ] Check error handling for expired tokens--## Breaking Changes-None--## Deployment Notes-Requires environment variables:-- `CLERK_SECRET_KEY`-- `CLERK_PUBLISHABLE_KEY`--🤖 Generated with Claude Code-EOF-)"-```--**Step 4: Verify PR Created**--```bash-gh pr view --web-```--### PR Templates--Keep templates in `.github/pull_request_template.md`:--```markdown-## Summary-<!-- Brief description of changes -->--## Changes-<!-- Bulleted list of specific changes -->--## Test Plan-<!-- Checkboxes for testing steps -->--## Breaking Changes-<!-- None or description -->--## Deployment Notes-<!-- Any special deployment requirements -->-```-------## Branch Management--### Creating Feature Branches--```bash-# Create and checkout-git checkout -b feature/user-auth--# Or separate commands-git branch feature/user-auth && git checkout feature/user-auth-```--**Naming Conventions**:-- `feature/description` - New features-- `fix/description` - Bug fixes-- `refactor/description` - Code refactoring-- `docs/description` - Documentation-- `chore/description` - Maintenance--### Syncing with Main--```bash-# Update main first-git checkout main && git pull origin main--# Switch back and rebase-git checkout feature/user-auth && git rebase main-```--**Important**: Never use interactive rebase (`-i`) in Claude Code (requires interactive input).--### Cleaning Up Branches--```bash-# Delete local branch (after merged)-git branch -d feature/user-auth--# Delete remote branch-git push origin --delete feature/user-auth--# Prune deleted remote branches-git fetch --prune-```-------## Pre-Commit Hook Handling--### The Problem--Pre-commit hooks (like prettier, eslint) modify files after staging, causing commits to fail.--### The Solution--**Step 1: Attempt Commit**--```bash-git add . && git commit -m "Your message"-```--**Step 2: If Fails Due to Hook Changes**--Check if safe to amend:--```bash-# Check authorship-git log -1 --format='%an %ae'--# Check not pushed-git status # Should show "ahead of origin"-```--**Step 3: Amend or New Commit**--```bash-# If safe (authored by you, not pushed)-git add . && git commit --amend --no-edit--# If not safe (authored by someone else or already pushed)-git add . && git commit -m "Apply pre-commit hook changes"-```--### Important Rules--❌ **Never amend**:-- Commits authored by others-- Commits already pushed to remote-- Commits on main/master branch--✅ **Safe to amend**:-- Your own commits-- Not yet pushed-- On feature branch-------## Common Patterns--### Squash Commits Before Merge--```bash-# Interactive rebase (manual, not in Claude Code)-# Use GitHub's "Squash and merge" button instead--# Or via gh CLI-gh pr merge 123 --squash --delete-branch-```--### Cherry-Pick Commits--```bash-# Get commit hash-git log --oneline--# Cherry-pick to current branch-git cherry-pick abc1234-```--### Stash Changes--```bash-# Stash uncommitted changes-git stash--# List stashes-git stash list--# Apply stash-git stash apply--# Apply and remove from stash list-git stash pop-```--### View File History--```bash-# See commits that modified file-git log --follow -- path/to/file.ts--# See changes to file-git log -p -- path/to/file.ts-```--### Undo Last Commit (Keep Changes)--```bash-git reset --soft HEAD~1-```--### Undo Last Commit (Discard Changes)--```bash-# ⚠️ Dangerous: Cannot be undone-git reset --hard HEAD~1-```--### View Specific Commit--```bash-git show abc1234-```--### Compare Branches--```bash-# See commits in feature not in main-git log main..feature/user-auth--# See file differences-git diff main...feature/user-auth-```-------## GitHub CLI (gh) Integration--### Installation--```bash-brew install gh-# or-apt install gh-```--### Authentication--```bash-gh auth login-```--### Common Commands--```bash-# Create PR-gh pr create --title "Title" --body "Body"--# List PRs-gh pr list--# View PR-gh pr view 123--# Merge PR-gh pr merge 123 --squash--# Comment on PR-gh pr comment 123 --body "LGTM! 🚀"--# Create issue-gh issue create --title "Bug" --body "Description"--# View CI status-gh run list --limit 5--# View API-gh api repos/owner/repo/pulls/123/comments-```-------## Production Examples--### Example 1: Feature Development Workflow--```bash-# 1. Create feature branch-git checkout -b feature/add-search--# 2. Make changes, commit regularly-git add . && git commit -m "feat(search): Add search endpoint"--# 3. Keep in sync with main-git fetch origin main && git rebase origin/main--# 4. Push to remote-git push -u origin feature/add-search--# 5. Create PR-gh pr create --title "feat: Add search functionality" --body "..."--# 6. After approval, merge-gh pr merge --squash --delete-branch-```--### Example 2: Hotfix Workflow--```bash-# 1. Branch from main-git checkout main && git pull && git checkout -b hotfix/critical-bug--# 2. Fix and commit-git add . && git commit -m "fix: Resolve critical auth bug"--# 3. Push and create PR-git push -u origin hotfix/critical-bug-gh pr create --title "fix: Critical auth bug" --body "..." --label "urgent"--# 4. Fast-track merge-gh pr merge --squash --delete-branch --admin-```--### Example 3: Release Workflow--```bash-# 1. Ensure on main-git checkout main && git pull--# 2. Create tag-TAG="v$(date +%Y.%m.%d)"-git tag -a "$TAG" -m "Release $TAG"--# 3. Push tag-git push origin "$TAG"--# 4. Create GitHub release-gh release create "$TAG" --title "Release $TAG" --notes "..."-```-------## Troubleshooting--### Problem: Merge Conflicts--**Detection**:-```bash-git status # Shows "both modified" files-```--**Resolution**:-```bash-# 1. Open conflicted files (use Edit tool)-# 2. Resolve conflicts manually-# 3. Stage resolved files-git add path/to/file.ts--# 4. Continue rebase/merge-git rebase --continue-# or-git merge --continue-```--### Problem: Accidentally Committed to Wrong Branch--**Solution**:-```bash-# 1. Note commit hash-git log -1--# 2. Reset branch-git reset --hard HEAD~1--# 3. Switch to correct branch-git checkout correct-branch--# 4. Cherry-pick commit-git cherry-pick <hash>-```--### Problem: Need to Undo Push--**Solution** (if no one else pulled):-```bash-# ⚠️ Dangerous: Rewrites history-git reset --hard HEAD~1-git push --force-```--**Better Solution** (if others may have pulled):-```bash-# Creates new commit that undoes changes-git revert HEAD-git push-```-------## Best Practices Summary--✅ **Always Do**:-- Commit atomically (one logical change per commit)-- Write clear commit messages-- Pull before pushing-- Review changes before committing-- Use conventional commits format-- Keep commits focused--❌ **Never Do**:-- Commit directly to main (use PRs)-- Force push to shared branches-- Amend commits after pushing-- Commit secrets or credentials-- Use `git add .` without reviewing-- Write vague commit messages-------**Production Validated**: These patterns are used daily in real-world projects with Claude Code.diff --git a/skills/claude-code-bash-patterns/references/hooks-examples.md b/skills/claude-code-bash-patterns/references/hooks-examples.mddeleted file mode 100644index a4a216b4..00000000--- a/skills/claude-code-bash-patterns/references/hooks-examples.md+++ /dev/null@@ -1,323 +0,0 @@-# Hooks Configuration Examples--Real-world hook configurations for Claude Code.-------## Complete Configuration Example--**File**: `~/.claude/settings.json`--```json-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- },- {- "type": "command",- "command": "~/.claude/hooks/bash-audit-logger.sh"- }- ]- },- {- "matcher": "Bash(git commit*)",- "hooks": [- {- "type": "prompt",- "prompt": "Review this git commit command: {tool_input.command}\n\nDoes the commit message follow conventional commits format and clearly explain WHY the change was made? If not, suggest improvements."- }- ]- },- {- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path // empty'); if echo \"$FILE\" | grep -qE '\\.(env|secret|key)$'; then echo 'ERROR: Cannot modify secret files' >&2; exit 2; fi"- }- ]- }- ],- "PostToolUse": [- {- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); [ -f \"$FILE\" ] && prettier --write \"$FILE\" > /dev/null 2>&1 || true"- }- ]- },- {- "matcher": "Bash(npm install*|pnpm install*|yarn install*)",- "hooks": [- {- "type": "command",- "command": "echo '✅ Dependencies installed. Running audit...' && npm audit || true"- }- ]- }- ],- "SessionStart": [- {- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE; echo '✅ Session started'"- }- ]- }- ]- },- "allowedTools": [- "Read",- "Write",- "Edit",- "Bash(git *)",- "Bash(npm *)",- "Bash(npx *)"- ]-}-```-------## Hook Types--### 1. PreToolUse - Security Guards--**Block Dangerous Commands**:-```json-{- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]-}-```--**Enforce Package Manager**:-```json-{- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "~/.claude/hooks/package-manager-enforcer.sh"- }- ]-}-```--**Prevent Production File Edits**:-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); if echo \"$FILE\" | grep -qE 'production|prod\\.'; then echo 'ERROR: Cannot modify production files' >&2; exit 2; fi"- }- ]-}-```--### 2. PostToolUse - Cleanup & Automation--**Auto-Format Code**:-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); prettier --write \"$FILE\" 2>/dev/null || true"- }- ]-}-```--**Run Tests After Code Changes**:-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); if echo \"$FILE\" | grep -qE '\\.(ts|js)$'; then npm test -- \"$FILE\" || true; fi"- }- ]-}-```--**Audit After Install**:-```json-{- "matcher": "Bash(npm install*|pnpm add*|yarn add*)",- "hooks": [- {- "type": "command",- "command": "npm audit --audit-level=high || echo 'Security vulnerabilities found'"- }- ]-}-```--### 3. SessionStart - Environment Setup--**Load Project Environment**:-```json-{- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE"- }- ]-}-```--**Verify Tools Installed**:-```json-{- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "which jq gh prettier > /dev/null || echo '⚠️ Missing tools: Install jq, gh, prettier'"- }- ]-}-```-------## Advanced Patterns--### Prompt-Based Hooks (LLM-Powered)--**Smart Commit Message Review**:-```json-{- "matcher": "Bash(git commit*)",- "hooks": [- {- "type": "prompt",- "prompt": "Review this commit:\n\nCommand: {tool_input.command}\n\nCheck:\n1. Follows conventional commits?\n2. Explains WHY (not just WHAT)?\n3. Avoids vague phrases?\n\nIf issues found, block and suggest improvements. Otherwise, allow."- }- ]-}-```--**Code Quality Check**:-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "prompt",- "prompt": "Review the file being modified:\n\nFile: {tool_input.file_path}\n\nCheck for:\n1. Security vulnerabilities\n2. Performance issues\n3. Best practice violations\n\nIf critical issues found, block. Otherwise, allow with warnings."- }- ]-}-```--### Conditional Hooks--**Only on Main Branch**:-```json-{- "matcher": "Bash(git push*)",- "hooks": [- {- "type": "command",- "command": "BRANCH=$(git rev-parse --abbrev-ref HEAD); if [ \"$BRANCH\" = \"main\" ]; then echo 'ERROR: Cannot push directly to main' >&2; exit 2; fi"- }- ]-}-```--**Only in Production**:-```json-{- "matcher": "Bash(wrangler deploy*)",- "hooks": [- {- "type": "command",- "command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q 'production'; then read -p 'Deploy to production? (yes/no): ' confirm; [ \"$confirm\" = \"yes\" ] || exit 2; fi"- }- ]-}-```-------## Logging & Auditing--### Complete Audit Log--```bash-#!/bin/bash-# File: ~/.claude/hooks/complete-audit.sh--LOG_FILE="$HOME/.claude/complete-audit.log"--# Parse input-TOOL=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_name // "unknown"')-COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_input.command // .tool_input.file_path // "N/A"')--# Log with context-echo "[$(date -Iseconds)] ${USER}@$(hostname) | Tool: $TOOL | Action: $COMMAND" >> "$LOG_FILE"--exit 0-```--**Configuration**:-```json-{- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "~/.claude/hooks/complete-audit.sh"- }- ]-}-```-------## Testing Hooks--**Test Hook Script**:-```bash-# Simulate CLAUDE_TOOL_INPUT-export CLAUDE_TOOL_INPUT='{"tool_input":{"command":"git push --force origin main"}}'--# Run hook-python3 ~/.claude/hooks/dangerous-command-guard.py--# Check exit code-echo "Exit code: $?"-```--**Test in Claude Code**:-1. Configure hook in settings.json-2. Try triggering action-3. Verify hook runs-4. Check block behavior-------**Production Validated**: All examples tested in real projects.diff --git a/skills/claude-code-bash-patterns/references/security-best-practices.md b/skills/claude-code-bash-patterns/references/security-best-practices.mddeleted file mode 100644index 0b32ff8c..00000000--- a/skills/claude-code-bash-patterns/references/security-best-practices.md+++ /dev/null@@ -1,272 +0,0 @@-# Security Best Practices for Bash Automation--Production security patterns for Claude Code bash automation.-------## Critical Security Rules--### 1. Never Commit Secrets--**Block with PreToolUse Hook**:-```json-{- "matcher": "Bash(git add*|git commit*)",- "hooks": [- {- "type": "command",- "command": "if git diff --cached | grep -qE '(API_KEY|SECRET|PASSWORD|TOKEN).*='; then echo 'ERROR: Secrets detected in staged files' >&2; exit 2; fi"- }- ]-}-```--**Use .gitignore**:-```-.env-.env.*-*.key-*.secret-credentials.json-.dev.vars-```--### 2. Principle of Least Privilege--**Allowlist Pattern**:-```json-{- "allowedTools": [- "Read",- "Write",- "Edit",- "Bash(git *)",- "Bash(npm install*)",- "Bash(npm test*)"- ]-}-```--**NOT**:-```json-{- "allowedTools": ["Bash"] // ❌ Too permissive-}-```--### 3. Dangerous Command Blocking--**Use dangerous-command-guard.py** (see scripts/)--**Blocks**:-- `rm -rf /`-- `dd if=`-- `mkfs.*`-- Fork bombs-- `sudo rm`-- `git push --force main`--### 4. Audit Logging--**Log All Bash Commands**:-```bash-# ~/.claude/hooks/bash-audit-logger.sh-echo "[$(date -Iseconds)] $USER: $COMMAND" >> ~/.claude/audit.log-```--### 5. Production File Protection--**Block Production Edits**:-```json-{- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); if echo \"$FILE\" | grep -qE 'production|prod\\.'; then echo 'ERROR: Cannot modify production files' >&2; exit 2; fi"- }- ]-}-```-------## Secret Management--### Environment Variables--**✅ Correct**:-```bash-# Load from .env (gitignored)-export API_KEY=$(grep API_KEY .env | cut -d= -f2)-curl -H "Authorization: Bearer $API_KEY" https://api.example.com-```--**❌ Wrong**:-```bash-# Hardcoded secret-curl -H "Authorization: Bearer sk-abc123" https://api.example.com-```--### Secret Management Tools--**Doppler**:-```bash-doppler run -- npm start-```--**Infisical**:-```bash-infisical run -- npm start-```--**Dotenv Vault**:-```bash-npx dotenv-vault@latest decrypt-```-------## Docker Security--### Never Embed Secrets in Images--**❌ Wrong**:-```dockerfile-ENV API_KEY=sk-abc123-```--**✅ Correct**:-```dockerfile-# Runtime injection-docker run -e API_KEY=$API_KEY myimage-```--### Read-Only Mounts--```bash-docker run -v $(pwd):/app:ro myimage-```-------## CI/CD Security--### GitHub Actions--**Use Secrets**:-```yaml-env:- API_KEY: ${{ secrets.API_KEY }}-```--**Never**:-```yaml-env:- API_KEY: sk-abc123 # ❌ Exposed in logs-```--### Cloudflare Secrets--```bash-# Set secret (never in code)-npx wrangler secret put API_KEY--# Use in code-const apiKey = env.API_KEY;-```-------## File Permissions--### Scripts--```bash-# Executable, user-only-chmod 700 script.sh--# Readable, user-only-chmod 600 .env-```--### SSH Keys--```bash-chmod 600 ~/.ssh/id_rsa-chmod 644 ~/.ssh/id_rsa.pub-```-------## Network Security--### HTTPS Only--```bash-# ✅ Correct-curl https://api.example.com--# ❌ Wrong-curl http://api.example.com-```--### Verify Certificates--```bash-# Don't skip verification-curl -k https://... # ❌ Dangerous--# Verify properly-curl --cacert ca.crt https://... # ✅ Correct-```-------## Input Validation--### Command Injection Prevention--**❌ Vulnerable**:-```bash-USER_INPUT="test; rm -rf /"-eval "echo $USER_INPUT" # Executes rm -rf /-```--**✅ Safe**:-```bash-USER_INPUT="test; rm -rf /"-echo "$USER_INPUT" # Just echoes the string-```--### SQL Injection Prevention--**❌ Vulnerable**:-```bash-npx wrangler d1 execute mydb --command "SELECT * FROM users WHERE name = '$INPUT'"-```--**✅ Safe**:-```bash-# Use parameterized queries in application code, not bash-```-------## Checklist--- [ ] All secrets in .env (gitignored)-- [ ] .gitignore includes .env, .env.*, *.key-- [ ] PreToolUse hooks block dangerous commands-- [ ] Audit logging enabled-- [ ] Production files protected-- [ ] Allowlist configured (not wildcard)-- [ ] No secrets in Docker images-- [ ] CI/CD uses platform secrets-- [ ] File permissions correct (600 for secrets)-- [ ] HTTPS only-- [ ] Input validation on user input-------**Production Validated**: Security patterns tested and verified.diff --git a/skills/claude-code-bash-patterns/references/troubleshooting-guide.md b/skills/claude-code-bash-patterns/references/troubleshooting-guide.mddeleted file mode 100644index d7fab677..00000000--- a/skills/claude-code-bash-patterns/references/troubleshooting-guide.md+++ /dev/null@@ -1,525 +0,0 @@-# Troubleshooting Guide--Detailed solutions for all 12 known issues with Claude Code Bash tool.-------## Issue #1: Git Bash cygpath Command Not Found (Windows)--**Error**: `bash: line 1: cygpath: command not found`--**Source**: https://github.com/anthropics/claude-code/issues/9883--**Symptoms**:-- Occurs on Windows with Git Bash-- Prevents file path operations-- Intermittent failures--**Diagnosis**:-```bash-which cygpath # Returns nothing on MSYS/Git Bash-```--**Solutions**:--**Option 1: Use WSL (Recommended)**-```bash-# Install WSL2-wsl --install--# Use WSL terminal for Claude Code-```--**Option 2: Configure Git Bash Path**-```bash-export CLAUDE_CODE_GIT_BASH_PATH="/usr/bin/bash"-```--**Option 3: Install Cygwin**-- Download from https://www.cygwin.com/-- Add cygwin/bin to PATH--**Prevention**: Use WSL on Windows for best compatibility-------## Issue #2: Pipe Command Failures--**Error**: `echo test|grep test` returns error instead of "test"--**Source**: https://github.com/anthropics/claude-code/issues/774--**Symptoms**:-- Pipes don't work as expected-- Simple pipe operations fail--**Diagnosis**:-```bash-echo test|grep test # Fails-```--**Solutions**:--**Option 1: Use bash -c wrapper**-```bash-bash -c 'echo test | grep test' # Works-```--**Option 2: Use specialized tools**-```bash-# Instead of: cat file.txt | grep pattern-Grep(pattern="pattern", path="file.txt")-```--**Prevention**: Prefer specialized tools (Grep, Read) over bash pipes-------## Issue #3: Command Timeout (Hanging Promises)--**Error**: `A hanging Promise was canceled`--**Source**: Bash tool default timeout is 2 minutes--**Symptoms**:-- Long-running commands timeout-- Build processes interrupted--**Diagnosis**:-```bash-# Command takes > 2 minutes-npm run build # Times out-```--**Solutions**:--**Set Explicit Timeout**:-```bash-Bash(- command="npm run build",- timeout=600000, # 10 minutes- description="Build production bundle"-)-```--**Run in Background**:-```bash-npm run build > build.log 2>&1 &-```--**Prevention**: Set timeout for known long operations-------## Issue #4: Output Truncation Loss--**Error**: Important output missing from response--**Source**: Bash tool truncates output at 30,000 characters--**Symptoms**:-- Missing test results-- Incomplete error messages--**Diagnosis**:-```bash-npm test # Output > 30k chars, truncated-```--**Solutions**:--**Limit Output**:-```bash-npm test 2>&1 | head -100-```--**Save to File**:-```bash-npm test > test-results.txt && tail -50 test-results.txt-```--**Use Grep**:-```bash-npm test 2>&1 | grep -E '(PASS|FAIL|Error)'-```--**Prevention**: Always limit output for large commands-------## Issue #5: "No Suitable Shell Found" (Windows)--**Error**: CLI fails with "No suitable shell found"--**Source**: https://github.com/anthropics/claude-code/issues/3461--**Symptoms**:-- Windows-specific-- Shell detection fails--**Diagnosis**:-```bash-echo $SHELL # Empty or incorrect-```--**Solutions**:--**Set SHELL Variable**:-```bash-export SHELL=/usr/bin/bash-```--**Use WSL**:-```bash-wsl --install-# Use WSL terminal-```--**Update Claude Code**:-```bash-npm update -g claude-code-cli-```--**Prevention**: Use WSL on Windows-------## Issue #6: Bash Tool Access Loss--**Error**: Claude loses ability to run Bash() tool--**Source**: https://github.com/anthropics/claude-code/issues/1888--**Symptoms**:-- Tool unavailable after idle-- Occurs after overnight sessions--**Diagnosis**:-```bash-# Check permissions-/permissions-```--**Solutions**:--**Restart Session**:-```bash-# Exit and restart Claude Code-```--**Use Restart Parameter**:-```bash-Bash(- command="npm test",- restart=true-)-```--**Check Allowlist**:-```json-{- "allowedTools": ["Bash"]-}-```--**Prevention**: Restart sessions after long idle periods-------## Issue #7: Interactive Prompt Hangs--**Error**: Command hangs indefinitely, no output--**Symptoms**:-- No progress-- No error message-- Timeout eventually--**Diagnosis**:-```bash-# Command expects input-npm install # If package.json has prompts-```--**Solutions**:--**Use Non-Interactive Flags**:-```bash-npm install --yes-```--**Provide Input via Stdin**:-```bash-echo "yes" | command-that-needs-confirmation-```--**Check for Interactive Commands**:-```bash-# These will hang:-vim, nano, less, more, top, htop-```--**Prevention**: Always use `--yes`, `--no-interactive` flags-------## Issue #8: Permission Denied Errors--**Error**: `permission denied` or `command not found`--**Symptoms**:-- Script won't execute-- Command not in PATH--**Diagnosis**:-```bash-./script.sh # Permission denied--which mycli # Returns nothing-```--**Solutions**:--**Make Executable**:-```bash-chmod +x script.sh && ./script.sh-```--**Use Full Path**:-```bash-/usr/local/bin/mycli deploy-```--**Use Interpreter Directly**:-```bash-python3 script.py-node script.js-bash script.sh-```--**Add to PATH**:-```bash-export PATH="$PATH:/path/to/dir"-```--**Prevention**: Check script permissions before execution-------## Issue #9: Environment Variables Not Persisting--**Error**: Variable set in one command not available in next--**Symptoms**:-- `export` doesn't persist-- Working directory resets--**Diagnosis**:-```bash-# Call 1-export API_KEY=abc123--# Call 2-echo $API_KEY # Empty!-```--**Solutions**:--**Chain Commands**:-```bash-export API_KEY=abc123 && curl -H "Authorization: $API_KEY" https://api.example.com-```--**Use SessionStart Hook**:-```json-{- "hooks": {- "SessionStart": [- {- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "source .envrc; env > $CLAUDE_ENV_FILE"- }- ]- }- ]- }-}-```--**Use .env Files**:-```bash-source .env && command-using-vars-```--**Prevention**: Chain commands or use SessionStart hook-------## Issue #10: Git Commit Hook Modifications Not Detected--**Error**: Pre-commit hook changes files, but commit fails--**Symptoms**:-- Commit fails after hook runs-- Files modified by hook not staged--**Diagnosis**:-```bash-git commit -m "Message"-# Error: Hook modified files-```--**Solutions**:--**Check if Safe to Amend**:-```bash-# 1. Check authorship-git log -1 --format='%an %ae'--# 2. Check not pushed-git status # Should show "ahead of origin"-```--**Amend if Safe**:-```bash-git add . && git commit --amend --no-edit-```--**New Commit if Not Safe**:-```bash-git add . && git commit -m "Apply pre-commit hook changes"-```--**Prevention**: Always check authorship before amending-------## Issue #11: Wildcard Permission Matching Not Working--**Error**: `Bash(*)` or `Bash(*:*)` doesn't grant access--**Source**: https://github.com/anthropics/claude-code/issues/462--**Symptoms**:-- Wildcard allowlist fails-- Specific commands blocked--**Diagnosis**:-```json-{- "allowedTools": ["Bash(*)"] // Doesn't work-}-```--**Solutions**:--**Use Correct Syntax**:-```json-{- "allowedTools": ["Bash"] // All bash commands-}-```--**Or Specific Patterns**:-```json-{- "allowedTools": [- "Bash(git *)",- "Bash(npm *)",- "Bash(npx *)"- ]-}-```--**Prevention**: Use `"Bash"` for all or specific patterns-------## Issue #12: Dangerous Command Execution--**Error**: Accidental `rm -rf /` or force push to main--**Symptoms**:-- No protection against destructive commands-- Manual intervention required--**Diagnosis**:-```bash-# These should be blocked:-rm -rf /-git push --force origin main-```--**Solutions**:--**Install Dangerous Command Guard**:-```bash-cp scripts/dangerous-command-guard.py ~/.claude/hooks/-chmod +x ~/.claude/hooks/dangerous-command-guard.py-```--**Configure Hook**:-```json-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]- }- ]- }-}-```--**Prevention**: Always use PreToolUse guard hook-------## General Troubleshooting Steps--### 1. Check Claude Code Version-```bash-claude --version-npm update -g claude-code-cli-```--### 2. Verify Settings-```bash-cat ~/.claude/settings.json | jq empty # Validate JSON-```--### 3. Test Hook Scripts-```bash-export CLAUDE_TOOL_INPUT='{"tool_input":{"command":"test"}}'-~/.claude/hooks/your-script.sh-echo "Exit code: $?"-```--### 4. Check Permissions-```bash-/permissions # In Claude Code session-```--### 5. View Logs-```bash-tail -50 ~/.claude/bash-audit.log-tail -50 ~/.claude/audit.log-```--### 6. Restart Session-```bash-# Exit and restart Claude Code-```-------**All issues documented with sources and tested solutions.**diff --git a/skills/claude-code-bash-patterns/scripts/bash-audit-logger.sh b/skills/claude-code-bash-patterns/scripts/bash-audit-logger.shdeleted file mode 100755index 92b22b9a..00000000--- a/skills/claude-code-bash-patterns/scripts/bash-audit-logger.sh+++ /dev/null@@ -1,62 +0,0 @@-#!/bin/bash-#-# Bash Audit Logger - PreToolUse Hook for Claude Code-#-# Logs all bash commands with timestamps for compliance and debugging.-#-# Usage:-# Configure as PreToolUse hook in ~/.claude/settings.json:-#-# {-# "hooks": {-# "PreToolUse": [-# {-# "matcher": "Bash",-# "hooks": [-# {-# "type": "command",-# "command": "~/.claude/hooks/bash-audit-logger.sh"-# }-# ]-# }-# ]-# }-# }-#-# Output:-# Appends to ~/.claude/bash-audit.log-#-# Exit Codes:-# 0 = Always (this hook never blocks)--# Configuration-LOG_FILE="${HOME}/.claude/bash-audit.log"-MAX_LOG_SIZE=10485760 # 10MB--# Create log directory if doesn't exist-mkdir -p "$(dirname "$LOG_FILE")"--# Parse command from CLAUDE_TOOL_INPUT-COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_input.command // "N/A"')-DESCRIPTION=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_input.description // "No description"')--# Get timestamp-TIMESTAMP=$(date -Iseconds)--# Log entry format: [timestamp] user@host:pwd $ command-LOG_ENTRY="[${TIMESTAMP}] ${USER}@$(hostname):$(pwd) $ ${COMMAND}"--# Append to log file-echo "$LOG_ENTRY" >> "$LOG_FILE"--# Rotate log if too large-if [ -f "$LOG_FILE" ]; then- LOG_SIZE=$(stat -f%z "$LOG_FILE" 2>/dev/null || stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)- if [ "$LOG_SIZE" -gt "$MAX_LOG_SIZE" ]; then- mv "$LOG_FILE" "${LOG_FILE}.old"- echo "[${TIMESTAMP}] Log rotated (size: ${LOG_SIZE} bytes)" > "$LOG_FILE"- fi-fi--# Always allow execution-exit 0diff --git a/skills/claude-code-bash-patterns/scripts/dangerous-command-guard.py b/skills/claude-code-bash-patterns/scripts/dangerous-command-guard.pydeleted file mode 100755index e335ff62..00000000--- a/skills/claude-code-bash-patterns/scripts/dangerous-command-guard.py+++ /dev/null@@ -1,84 +0,0 @@-#!/usr/bin/env python3-"""-Dangerous Command Guard - PreToolUse Hook for Claude Code--Blocks dangerous bash commands that could cause system damage or data loss.--Usage:- Configure as PreToolUse hook in ~/.claude/settings.json:-- {- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py"- }- ]- }- ]- }- }--Exit Codes:- 0 = Allow execution- 1 = Block with generic error- 2 = Block with custom error message (from stderr)-"""--import json-import sys-import re--# Read hook input from stdin (JSON format)-try:- data = json.load(sys.stdin)- command = data.get('tool_input', {}).get('command', '')-except (json.JSONDecodeError, KeyError) as e:- # If can't parse input, allow execution (fail open for safety)- sys.exit(0)--# Dangerous command patterns to block-DANGEROUS_PATTERNS = [- # Filesystem destruction- (r'rm\s+-rf\s+/', 'Delete root directory (rm -rf /)'),- (r'rm\s+-rf\s+~/', 'Delete home directory (rm -rf ~/)'),- (r'rm\s+-rf\s+\*', 'Recursive delete with wildcard (rm -rf *)'),-- # Disk operations- (r'dd\s+if=', 'Direct disk write operation (dd)'),- (r'mkfs\.', 'Format filesystem (mkfs)'),-- # Fork bomb- (r':\(\)\s*\{\s*:\|\:&\s*\}\s*;\s*:', 'Fork bomb'),-- # Dangerous sudo operations- (r'sudo\s+rm\s+-rf', 'Sudo recursive delete'),- (r'sudo\s+dd', 'Sudo disk operation'),-- # Git force operations on protected branches- (r'git\s+push\s+.*--force.*\s+(main|master)', 'Force push to main/master branch'),- (r'git\s+push\s+.*-f\s+.*(main|master)', 'Force push to main/master branch'),-- # Overwrite important system files- (r'>\s*/etc/passwd', 'Overwrite /etc/passwd'),- (r'>\s*/etc/shadow', 'Overwrite /etc/shadow'),- (r'>\s*/boot/', 'Overwrite boot files'),-- # Chmod dangerous patterns- (r'chmod\s+-R\s+777\s+/', 'Chmod 777 on root'),- (r'chmod\s+777\s+/etc', 'Chmod 777 on /etc'),-]--# Check command against all patterns-for pattern, description in DANGEROUS_PATTERNS:- if re.search(pattern, command, re.IGNORECASE):- error_msg = f"🚨 BLOCKED: {description}\n\nCommand: {command}\n\nThis command has been blocked for safety. If you need to perform this operation, please do it manually."- print(error_msg, file=sys.stderr)- sys.exit(2) # Exit code 2 = block with custom error--# Command is safe, allow execution-sys.exit(0)diff --git a/skills/claude-code-bash-patterns/scripts/package-manager-enforcer.sh b/skills/claude-code-bash-patterns/scripts/package-manager-enforcer.shdeleted file mode 100755index 2e0dcc45..00000000--- a/skills/claude-code-bash-patterns/scripts/package-manager-enforcer.sh+++ /dev/null@@ -1,77 +0,0 @@-#!/bin/bash-#-# Package Manager Enforcer - PreToolUse Hook for Claude Code-#-# Enforces consistent package manager usage based on lockfile.-# Prevents mixing npm/pnpm/yarn in the same project.-#-# Usage:-# Configure as PreToolUse hook in ~/.claude/settings.json:-#-# {-# "hooks": {-# "PreToolUse": [-# {-# "matcher": "Bash",-# "hooks": [-# {-# "type": "command",-# "command": "~/.claude/hooks/package-manager-enforcer.sh"-# }-# ]-# }-# ]-# }-# }-#-# Exit Codes:-# 0 = Allow execution-# 2 = Block with custom error message--# Parse command from CLAUDE_TOOL_INPUT-COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.tool_input.command // ""')--# Detect package manager from lockfile-DETECTED_PM=""-if [ -f "pnpm-lock.yaml" ]; then- DETECTED_PM="pnpm"-elif [ -f "yarn.lock" ]; then- DETECTED_PM="yarn"-elif [ -f "package-lock.json" ]; then- DETECTED_PM="npm"-else- # No lockfile detected, allow any package manager- exit 0-fi--# Check if command uses a different package manager-if echo "$COMMAND" | grep -qE '^(npm|pnpm|yarn)\s+'; then- # Extract package manager from command- USED_PM=$(echo "$COMMAND" | grep -oE '^(npm|pnpm|yarn)' | head -n1)-- # Check if it matches detected package manager- if [ "$USED_PM" != "$DETECTED_PM" ]; then- ERROR_MSG="🚨 BLOCKED: Package manager mismatch--Detected lockfile: ${DETECTED_PM}-lock.yaml / ${DETECTED_PM}.lock / package-lock.json-Command uses: ${USED_PM}--This project uses ${DETECTED_PM}. Please use '${DETECTED_PM}' instead of '${USED_PM}'.--Examples:- ${DETECTED_PM} install- ${DETECTED_PM} add <package>- ${DETECTED_PM} run <script>--If you want to switch package managers:- 1. Delete the old lockfile- 2. Run '${USED_PM} install' to create new lockfile- 3. Commit the new lockfile-"- echo "$ERROR_MSG" >&2- exit 2- fi-fi--# Allow execution-exit 0diff --git a/skills/claude-code-bash-patterns/templates/.envrc.example b/skills/claude-code-bash-patterns/templates/.envrc.exampledeleted file mode 100644index 65e3e9cc..00000000--- a/skills/claude-code-bash-patterns/templates/.envrc.example+++ /dev/null@@ -1,191 +0,0 @@-# .envrc Example - Environment Setup for Claude Code-#-# This file is used with direnv to automatically load environment variables-# when entering a project directory.-#-# Installation:-# 1. Install direnv: brew install direnv (or apt install direnv)-# 2. Add to shell: eval "$(direnv hook bash)" in ~/.bashrc-# 3. Copy this to .envrc in your project root-# 4. Run: direnv allow-#-# Claude Code Integration:-# Configure SessionStart hook to load .envrc:-#-# {-# "hooks": {-# "SessionStart": [-# {-# "matcher": "*",-# "hooks": [-# {-# "type": "command",-# "command": "[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE"-# }-# ]-# }-# ]-# }-# }--# ============================================================================-# Project Information-# ============================================================================--export PROJECT_NAME="my-project"-export PROJECT_ENV="development"--# ============================================================================-# Development Tools-# ============================================================================--# Add local node_modules/.bin to PATH-PATH_add node_modules/.bin--# Add project scripts to PATH-PATH_add scripts--# Use project-specific Node version (if using nvm)-# use node 20--# ============================================================================-# API Keys (Development Only - Never Commit Production Keys!)-# ============================================================================--# Cloudflare-export CLOUDFLARE_ACCOUNT_ID="your-account-id"-export CLOUDFLARE_API_TOKEN="your-dev-api-token"--# OpenAI (for development/testing)-export OPENAI_API_KEY="sk-..."--# Anthropic-export ANTHROPIC_API_KEY="sk-ant-..."--# ============================================================================-# Database Configuration-# ============================================================================--# Local D1 database-export DATABASE_URL="file:./.wrangler/state/v3/d1/my-db.sqlite"--# Or remote database connection-# export DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"--# ============================================================================-# Application Configuration-# ============================================================================--export APP_URL="http://localhost:8787"-export API_URL="http://localhost:8787/api"--# Feature flags-export FEATURE_NEW_UI="true"-export FEATURE_DEBUG_MODE="true"--# ============================================================================-# Wrangler Configuration-# ============================================================================--export WRANGLER_LOG_LEVEL="info"--# Use specific wrangler version-# export WRANGLER_VERSION="3.91.0"--# ============================================================================-# Custom Aliases (for CLI convenience)-# ============================================================================--# Git shortcuts-alias gst='git status'-alias gd='git diff'-alias gc='git commit'-alias gp='git push'--# Development shortcuts-alias dev='npm run dev'-alias build='npm run build'-alias test='npm test'-alias deploy='npx wrangler deploy'--# Wrangler shortcuts-alias w='npx wrangler'-alias d1='npx wrangler d1'-alias kv='npx wrangler kv'-alias r2='npx wrangler r2'--# ============================================================================-# Helper Functions-# ============================================================================--# Function to switch environment-switch_env() {- case $1 in- dev|development)- export PROJECT_ENV="development"- export APP_URL="http://localhost:8787"- echo "Switched to development environment"- ;;- staging)- export PROJECT_ENV="staging"- export APP_URL="https://staging.example.com"- echo "Switched to staging environment"- ;;- prod|production)- export PROJECT_ENV="production"- export APP_URL="https://example.com"- echo "Switched to production environment"- ;;- *)- echo "Usage: switch_env [dev|staging|prod]"- ;;- esac-}--# Function to check required environment variables-check_env() {- local missing=()-- [ -z "$CLOUDFLARE_ACCOUNT_ID" ] && missing+=("CLOUDFLARE_ACCOUNT_ID")- [ -z "$CLOUDFLARE_API_TOKEN" ] && missing+=("CLOUDFLARE_API_TOKEN")-- if [ ${#missing[@]} -gt 0 ]; then- echo "⚠️ Missing required environment variables:"- printf ' - %s\n' "${missing[@]}"- return 1- else- echo "✅ All required environment variables are set"- return 0- fi-}--# ============================================================================-# Startup Message-# ============================================================================--echo "✅ Environment loaded for $PROJECT_NAME ($PROJECT_ENV)"-echo " App URL: $APP_URL"-echo ""-echo "Available commands:"-echo " switch_env [dev|staging|prod] - Switch environment"-echo " check_env - Check required variables"-echo ""--# Auto-check environment on load-check_env--# ============================================================================-# Security Notes-# ============================================================================--# IMPORTANT:-# 1. Add .envrc to .gitignore (never commit!)-# 2. Use .envrc.example (this file) as template-# 3. Never put production secrets in .envrc-# 4. Use secret management tools for production (Doppler, Infisical, etc.)-# 5. Rotate API keys regularly-# 6. Use read-only keys when possible--# ============================================================================-# End of .envrc-# ============================================================================diff --git a/skills/claude-code-bash-patterns/templates/custom-command-template.md b/skills/claude-code-bash-patterns/templates/custom-command-template.mddeleted file mode 100644index 0a92a9c6..00000000--- a/skills/claude-code-bash-patterns/templates/custom-command-template.md+++ /dev/null@@ -1,198 +0,0 @@-# Custom Command Template--This is a template for creating custom commands in `.claude/commands/`.--## File Location--`.claude/commands/your-command-name.md`--## Usage--```-User: /your-command-name-Claude: [Executes the workflow described in this file]-```-------## Template Structure--```markdown-[Brief description of what this command does]--[Detailed workflow steps in imperative form:]--1. [First step with specific action]-2. [Second step with verification]-3. [Third step with error handling]-4. [Final step with success criteria]--[Optional: Rollback instructions if something fails]--[Optional: Expected output or success message]-```-------## Example: Deploy to Staging--**File**: `.claude/commands/deploy-staging.md`--```markdown-Deploy the current branch to staging environment.--1. Verify current branch is not main (exit if main)-2. Run full test suite (npm test)-3. If tests pass, build production bundle (npm run build)-4. Deploy to Cloudflare staging (npx wrangler deploy --env staging)-5. Wait for deployment to complete-6. Run health check on staging URL (curl https://staging.example.com/health)-7. If health check passes, report success with deployment URL-8. If health check fails, rollback deployment (npx wrangler rollback --env staging)-```-------## Best Practices--### ✅ Do:-- Use imperative language ("Run tests", not "Running tests")-- Include verification steps ("Verify X", "Check Y")-- Add error handling ("If X fails, then Y")-- Specify exact commands when helpful-- Keep focused on one workflow-- Document expected state before execution-- Include rollback steps for deployments--### ❌ Don't:-- Make commands too complex (split into multiple if needed)-- Include interactive prompts (commands should be fully automated)-- Assume state without verification-- Mix multiple unrelated workflows-- Use vague language ("do stuff", "handle errors")-------## Example Command Library--### Development Workflow--**`.claude/commands/run-tests.md`**-```markdown-Run full test suite with coverage.--1. Check if node_modules exists (run npm install if missing)-2. Run tests with coverage (npm test -- --coverage)-3. Generate coverage report-4. Display coverage summary-5. If coverage below 80%, warn user-```--### Deployment Workflow--**`.claude/commands/deploy-production.md`**-```markdown-Deploy to production with safety checks.--1. CRITICAL: Verify current branch is main (exit if not)-2. Verify no uncommitted changes (git status)-3. Pull latest changes (git pull origin main)-4. Run full test suite (npm test)-5. Build production bundle (npm run build)-6. Deploy to Cloudflare production (npx wrangler deploy --env production)-7. Run smoke tests on production URL-8. If smoke tests fail, IMMEDIATELY rollback-9. If success, create deployment tag (git tag -a deploy-$(date +%Y%m%d-%H%M%S))-10. Push tag to remote (git push --tags)-```--### Code Quality--**`.claude/commands/format-code.md`**-```markdown-Format all code files with prettier and eslint.--1. Run prettier on all files (npx prettier --write .)-2. Run eslint with auto-fix (npx eslint --fix .)-3. Show summary of changes-4. If any unfixable errors, list them-```--### Database Operations--**`.claude/commands/create-migration.md`**-```markdown-Create a new database migration.--1. Ask user for migration name-2. Generate migration file with timestamp (npx wrangler d1 migrations create <name>)-3. Open migration file location-4. Remind user to:- - Write up migration SQL- - Write down migration SQL- - Test locally (npx wrangler d1 migrations apply --local)- - Then apply to remote (npx wrangler d1 migrations apply --remote)-```-------## Advanced Patterns--### Conditional Execution--```markdown-Run tests only if code changed.--1. Check for uncommitted changes (git status)-2. If no changes, skip tests and report "No changes detected"-3. If changes exist:- a. Stage changes (git add .)- b. Run tests (npm test)- c. If tests pass, allow commit- d. If tests fail, report errors and unstage-```--### Multi-Environment Support--```markdown-Deploy to specified environment.--1. Prompt user to select environment (dev/staging/production)-2. Verify correct branch for environment:- - dev: any branch- - staging: develop or feature branches- - production: ONLY main branch-3. Run environment-specific tests-4. Deploy using environment flag (npx wrangler deploy --env {selected})-5. Run environment-specific smoke tests-6. Report deployment URL-```--### Error Recovery--```markdown-Fix common build errors automatically.--1. Try build (npm run build)-2. If build fails:- a. Check error message for common patterns- b. If "node_modules" related: delete node_modules and reinstall- c. If "cache" related: clear build cache- d. If "type error": run type checking (npm run type-check)- e. Retry build-3. If build still fails after retry, report full error to user-```-------## Testing Your Custom Command--1. Create the command file in `.claude/commands/`-2. Test with Claude Code: `/your-command-name`-3. Verify Claude executes all steps correctly-4. Check error handling works-5. Ensure success criteria are clear-------**Ready to create your custom command!**diff --git a/skills/claude-code-bash-patterns/templates/dangerous-commands.json b/skills/claude-code-bash-patterns/templates/dangerous-commands.jsondeleted file mode 100644index f7ae2690..00000000--- a/skills/claude-code-bash-patterns/templates/dangerous-commands.json+++ /dev/null@@ -1,101 +0,0 @@-{- "dangerous_patterns": [- {- "pattern": "rm\\s+-rf\\s+/",- "description": "Delete root directory",- "severity": "critical",- "example": "rm -rf /"- },- {- "pattern": "rm\\s+-rf\\s+~/",- "description": "Delete home directory",- "severity": "critical",- "example": "rm -rf ~/"- },- {- "pattern": "rm\\s+-rf\\s+\\*",- "description": "Recursive delete with wildcard",- "severity": "high",- "example": "rm -rf *"- },- {- "pattern": "dd\\s+if=",- "description": "Direct disk write operation",- "severity": "critical",- "example": "dd if=/dev/zero of=/dev/sda"- },- {- "pattern": "mkfs\\.",- "description": "Format filesystem",- "severity": "critical",- "example": "mkfs.ext4 /dev/sda1"- },- {- "pattern": ":\\(\\)\\s*\\{\\s*:\\|\\:&\\s*\\}\\s*;\\s*:",- "description": "Fork bomb",- "severity": "critical",- "example": ":(){ :|:& };:"- },- {- "pattern": "sudo\\s+rm\\s+-rf",- "description": "Sudo recursive delete",- "severity": "critical",- "example": "sudo rm -rf /"- },- {- "pattern": "sudo\\s+dd",- "description": "Sudo disk operation",- "severity": "critical",- "example": "sudo dd if=/dev/zero of=/dev/sda"- },- {- "pattern": "git\\s+push\\s+.*--force.*(main|master)",- "description": "Force push to main/master branch",- "severity": "high",- "example": "git push --force origin main"- },- {- "pattern": "git\\s+push\\s+.*-f\\s+.*(main|master)",- "description": "Force push to main/master branch (short flag)",- "severity": "high",- "example": "git push -f origin master"- },- {- "pattern": ">\\s*/etc/passwd",- "description": "Overwrite /etc/passwd",- "severity": "critical",- "example": "echo 'malicious' > /etc/passwd"- },- {- "pattern": ">\\s*/etc/shadow",- "description": "Overwrite /etc/shadow",- "severity": "critical",- "example": "echo 'malicious' > /etc/shadow"- },- {- "pattern": ">\\s*/boot/",- "description": "Overwrite boot files",- "severity": "critical",- "example": "echo 'malicious' > /boot/grub.cfg"- },- {- "pattern": "chmod\\s+-R\\s+777\\s+/",- "description": "Chmod 777 on root",- "severity": "critical",- "example": "chmod -R 777 /"- },- {- "pattern": "chmod\\s+777\\s+/etc",- "description": "Chmod 777 on /etc",- "severity": "high",- "example": "chmod 777 /etc"- }- ],- "usage": "These patterns are used by dangerous-command-guard.py to block unsafe bash commands. Each pattern is a regex that matches dangerous command structures.",- "severity_levels": {- "critical": "Immediate system damage or data loss",- "high": "Potential for significant damage",- "medium": "Security risk or data integrity issue",- "low": "Best practice violation"- }-}diff --git a/skills/claude-code-bash-patterns/templates/github-workflow.yml b/skills/claude-code-bash-patterns/templates/github-workflow.ymldeleted file mode 100644index 8aa66efc..00000000--- a/skills/claude-code-bash-patterns/templates/github-workflow.yml+++ /dev/null@@ -1,122 +0,0 @@-name: Claude Code CI/CD--# Example GitHub Actions workflow using Claude Code with bash automation--on:- pull_request:- branches: [main, develop]- push:- branches: [main, develop]--jobs:- test:- runs-on: ubuntu-latest- steps:- - name: Checkout code- uses: actions/checkout@v4-- - name: Setup Node.js- uses: actions/setup-node@v4- with:- node-version: '20'- cache: 'npm'-- - name: Install dependencies- run: npm ci-- - name: Run tests- run: npm test-- - name: Build- run: npm run build-- deploy-staging:- runs-on: ubuntu-latest- needs: test- if: github.ref == 'refs/heads/develop'- steps:- - name: Checkout code- uses: actions/checkout@v4-- - name: Setup Node.js- uses: actions/setup-node@v4- with:- node-version: '20'-- - name: Install dependencies- run: npm ci-- - name: Build- run: npm run build-- - name: Deploy to Cloudflare Staging- run: npx wrangler deploy --env staging- env:- CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}-- - name: Run smoke tests- run: |- STAGING_URL="https://staging.example.com"- STATUS=$(curl -s -o /dev/null -w "%{http_code}" ${STAGING_URL}/health)- if [ "$STATUS" != "200" ]; then- echo "Health check failed with status: $STATUS"- exit 1- fi- echo "Staging deployment successful: $STAGING_URL"-- deploy-production:- runs-on: ubuntu-latest- needs: test- if: github.ref == 'refs/heads/main'- environment:- name: production- url: https://example.com- steps:- - name: Checkout code- uses: actions/checkout@v4-- - name: Setup Node.js- uses: actions/setup-node@v4- with:- node-version: '20'-- - name: Install dependencies- run: npm ci-- - name: Run tests- run: npm test-- - name: Build- run: npm run build-- - name: Deploy to Cloudflare Production- run: npx wrangler deploy --env production- env:- CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}-- - name: Run smoke tests- run: |- PROD_URL="https://example.com"- STATUS=$(curl -s -o /dev/null -w "%{http_code}" ${PROD_URL}/health)- if [ "$STATUS" != "200" ]; then- echo "Health check failed with status: $STATUS"- echo "ALERT: Production deployment health check failed!"- exit 1- fi- echo "Production deployment successful: $PROD_URL"-- - name: Create deployment tag- run: |- TAG="deploy-$(date +%Y%m%d-%H%M%S)"- git tag -a "$TAG" -m "Production deployment $TAG"- git push origin "$TAG"- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}-- - name: Notify deployment- run: |- gh pr comment ${{ github.event.pull_request.number }} \- --body "✅ Deployed to production: https://example.com"- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- if: github.event_name == 'pull_request'diff --git a/skills/claude-code-bash-patterns/templates/settings.json b/skills/claude-code-bash-patterns/templates/settings.jsondeleted file mode 100644index 5d9fa79e..00000000--- a/skills/claude-code-bash-patterns/templates/settings.json+++ /dev/null@@ -1,82 +0,0 @@-{- "hooks": {- "PreToolUse": [- {- "matcher": "Bash",- "hooks": [- {- "type": "command",- "command": "python3 ~/.claude/hooks/dangerous-command-guard.py",- "description": "Block dangerous bash commands (rm -rf /, git push --force main, etc.)"- },- {- "type": "command",- "command": "~/.claude/hooks/bash-audit-logger.sh",- "description": "Log all bash commands to ~/.claude/bash-audit.log"- },- {- "type": "command",- "command": "~/.claude/hooks/package-manager-enforcer.sh",- "description": "Enforce package manager consistency (pnpm/yarn/npm)"- }- ]- },- {- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path // empty'); if echo \"$FILE\" | grep -qE '(^|\\/)(production\\.env|\\.env\\.production|prod\\.config)$'; then echo 'ERROR: Cannot modify production config files' >&2; exit 2; fi",- "description": "Prevent modification of production config files"- }- ]- }- ],- "PostToolUse": [- {- "matcher": "Write|Edit",- "hooks": [- {- "type": "command",- "command": "FILE=$(echo \"$CLAUDE_TOOL_INPUT\" | jq -r '.tool_input.file_path'); [ -f \"$FILE\" ] && prettier --write \"$FILE\" > /dev/null 2>&1 || true",- "description": "Auto-format files after editing (if prettier is available)"- }- ]- }- ],- "SessionStart": [- {- "matcher": "*",- "hooks": [- {- "type": "command",- "command": "[ -f .envrc ] && source .envrc || true; env > $CLAUDE_ENV_FILE",- "description": "Load project environment from .envrc (if exists)"- }- ]- }- ]- },- "allowedTools": [- "Read",- "Write",- "Edit",- "Glob",- "Grep",- "Bash(git *)",- "Bash(gh *)",- "Bash(npm *)",- "Bash(pnpm *)",- "Bash(npx *)",- "Bash(node *)",- "Bash(python*)",- "Bash(wrangler *)",- "Bash(ls *)",- "Bash(cat *)",- "Bash(echo *)",- "Bash(which *)",- "Bash(chmod *)",- "Bash(mkdir *)",- "Bash(touch *)"- ]-}