Skip to content

secondsky/claude-skills / plugins/claude-code-bash-patterns/skills/claude-code-bash-patterns

claude-code-bash-patterns

Flagged

Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.

templates/settings.json

View on GitHub
{
  "_comment_WARNING": "OPT-IN TEMPLATE. This file is a template shipped inside the claude-code-bash-patterns skill. Copying it verbatim to ~/.claude/settings.json ENABLES the hooks described below for every session. Review each hook before adopting. The SessionStart hook below will source .envrc ONLY if you create an explicit opt-in sentinel file (see comment).",
  "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": "# SessionStart env loader (opt-in).\n# WARNING: sourcing .envrc executes ARBITRARY SHELL from the project directory.\n# It is OFF by default. To opt in, create a sentinel file at the project root:\n#     touch .claude-enable-envrc\n# Claude Code already exposes any env var you set in your shell or via\n# `claude config`; you do NOT need to dump `env` into $CLAUDE_ENV_FILE.\nif [ -f .claude-enable-envrc ] && [ -f .envrc ]; then\n  set -a; . ./.envrc; set +a\nfi\n",
            "description": "Opt-in .envrc loader (requires .claude-enable-envrc sentinel). Never dumps env."
          }
        ]
      }
    ]
  },
  "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 *)"
  ]
}
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 468kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 468kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 468kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall