Skip to content
Back to search

ai-driven-development

SkillGitHubIncomplete

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/codealive-ai--ai-driven-development/badge.svg)](/listings/codealive-ai--ai-driven-development)

HTML

<a href="/listings/codealive-ai--ai-driven-development"><img src="/api/listings/codealive-ai--ai-driven-development/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

**Via Skills CLI** (recommended — works in 12+ agents):

# Install all 24 skills
npx skills add CodeAlive-AI/ai-driven-development

# Or pick a single skill
npx skills add CodeAlive-AI/ai-driven-development --skill prompt-engineering

**Via Claude Code plugin marketplace:**

/plugin marketplace add CodeAlive-AI/ai-driven-development
/plugin install ai-driven-development@ai-driven-development
# Restart Claude Code for changes to take effect

The Bash safety hook (`bash-guard`) ships separately — see [hooks/balanced-safety-hooks/](hooks/balanced-safety-hooks/) for its install one-liner.

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 67 lines
  1. {
  2. "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
  3. "name": "ai-driven-development",
  4. "owner": {
  5. "name": "CodeAlive-AI",
  6. "email": "contact@codealive.ai"
  7. },
  8. "metadata": {
  9. "description": "Practices, protocols, and skills for AI-driven software development — for any agent that supports the Agent Skills standard (Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, Antigravity, and more).",
  10. "version": "10.10.0"
  11. },
  12. "plugins": [
  13. {
  14. "name": "ai-driven-development",
  15. "description": "An umbrella collection of 24 skills + 1 hook for AI-driven development: agent self-configuration (MCP / hooks / settings / skills / plugins / cross-agent repository readiness / safe CLI installation), engineering practices (UX review and accessibility, maintainable complexity, prompt engineering, FPF problem solving, bug-fix protocol, pragmatic verification for tests, QA and test-suite audits, planning gate, repository-history investigation, repository activity summary, C# refactoring), AI infrastructure (OpenRouter endpoint ranking and routing), research & docs (Semantic Scholar deep research, URL-to-Markdown, ubiquitous-language thesaurus), macOS & Windows health & cleanup, and niche utilities (clipboard, Windows QA). Plus a Claude Code Bash safety hook.",
  16. "version": "10.10.0",
  17. "author": {
  18. "name": "CodeAlive-AI",
  19. "email": "contact@codealive.ai"
  20. },
  21. "homepage": "https://github.com/CodeAlive-AI/ai-driven-development",
  22. "repository": "https://github.com/CodeAlive-AI/ai-driven-development",
  23. "license": "MIT",
  24. "source": "./",
  25. "category": "developer-tools",
  26. "tags": [
  27. "skills",
  28. "meta-skills",
  29. "ai-driven-development",
  30. "agent-reflection",
  31. "engineering-practices",
  32. "mcp",
  33. "hooks",
  34. "plugins",
  35. "settings",
  36. "prompt-engineering",
  37. "fpf",
  38. "bug-fix-protocol",
  39. "research",
  40. "ubiquitous-language",
  41. "claude-code",
  42. "codex-cli",
  43. "opencode",
  44. "cursor"
  45. ],
  46. "keywords": [
  47. "claude-code",
  48. "codex-cli",
  49. "opencode",
  50. "cursor",
  51. "gemini-cli",
  52. "antigravity",
  53. "skills",
  54. "meta-skills",
  55. "ai-driven-development",
  56. "engineering-protocols",
  57. "prompt-engineering",
  58. "fpf",
  59. "bug-fix",
  60. "research",
  61. "mcp",
  62. "hooks",
  63. "plugins"
  64. ]
  65. }
  66. ]
  67. }
README.md · README · 213 lines · 1 finding marked
  1. <p align="center">
  2. <img src="https://img.shields.io/badge/Agent_Skills-Collection-blueviolet?style=for-the-badge" alt="Agent Skills Collection">
  3. <img src="https://img.shields.io/badge/Skills-24-blue?style=for-the-badge" alt="24 Skills">
  4. <img src="https://img.shields.io/badge/Hooks-1-yellow?style=for-the-badge" alt="1 Hook">
  5. <img src="https://img.shields.io/badge/Agents-12+-orange?style=for-the-badge" alt="12+ Agents">
  6. <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="MIT License">
  7. </p>
  8. <h1 align="center">AI-Driven Development</h1>
  9. <p align="center">
  10. <strong>Practices, protocols, and skills for AI-driven software development</strong>
  11. </p>
  12. <p align="center">
  13. An umbrella collection of 24 skills + 1 hook that work across <strong>Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, Antigravity</strong>, and any other agent that supports the <a href="https://agentskills.io">Agent Skills</a> standard.
  14. </p>
  15. ---
  16. ## Related Projects
  17. - [Apple App Store Reviewer](https://github.com/CodeAlive-AI/vibe-stack/tree/main/skills/apple-app-store-reviewer) — moved to Vibe Stack in full; install this skill from `CodeAlive-AI/vibe-stack`.
  18. - [Vibe Stack](https://github.com/CodeAlive-AI/vibe-stack) — an opinionated AI-native development stack with one verified default per layer, covering web apps, agent apps, deployment, persistence, error tracking, and observability.
  19. ---
  20. ## Installation
  21. **Via Skills CLI** (recommended — works in 12+ agents):
  22. ```bash
  23. # Install all 24 skills
  24. npx skills add CodeAlive-AI/ai-driven-development
  25. # Or pick a single skill
  26. npx skills add CodeAlive-AI/ai-driven-development --skill prompt-engineering
  27. ```
  28. **Via Claude Code plugin marketplace:**
  29. ```bash
  30. /plugin marketplace add CodeAlive-AI/ai-driven-development
  31. /plugin install ai-driven-development@ai-driven-development
  32. # Restart Claude Code for changes to take effect
  33. ```
  34. The Bash safety hook (`bash-guard`) ships separately — see [hooks/balanced-safety-hooks/](hooks/balanced-safety-hooks/) for its install one-liner.
  35. ---
  36. ## What's Included
  37. ### Agent reflection & meta (7)
  38. Meta-skills that let AI coding agents configure themselves. No more editing config files — just tell your agent what you need.
  39. | Skill | What It Does |
  40. |-------|--------------|
  41. | [mcp-management](skills/mcp-management/) | Install and manage MCP servers across 10+ coding agents (Claude Code, Cursor, VS Code, Gemini CLI, Codex, Goose, Copilot CLI, OpenCode, Zed, Devin) — single command, handles JSON/YAML/TOML config differences |
  42. | [hooks-management](skills/hooks-management/) | Manage hooks and automation for Claude Code, Codex CLI, OpenCode, and Devin CLI/Desktop |
  43. | [settings-management](skills/settings-management/) | Configure settings for Claude Code (JSON), Codex CLI (TOML), OpenCode (JSON/JSONC), and Devin CLI/Desktop (JSON) |
  44. | [skills-management](skills/skills-management/) | Organise, discover, share, and **train** skills for coding agents — SkillOpt-style optimisation loop with bounded edits, held-out validation gate, rejected-edit buffer, epoch-wise slow/meta update, plus trigger / transfer / diff / edit-log tooling |
  45. | [plugins-management](skills/plugins-management/) | Package and publish plugins for Claude Code, OpenCode, and Devin CLI/Desktop (validate, scaffold, submit to Anthropic's directory) |
  46. | [agentic-readiness](skills/agentic-readiness/) | Audit and improve repositories for Codex/Codex App, Claude Code, and OpenCode, including `AGENTS.md`/`CLAUDE.md` discovery and routing |
  47. | [installing-cli-tools](skills/installing-cli-tools/) | Install, upgrade, authenticate, verify, and roll back developer CLIs while keeping tokens and API keys out of chat, logs, shell history, startup files, and repositories |
  48. ### Engineering practices (10)
  49. Disciplined approaches that improve how agents and humans collaborate on code.
  50. | Skill | What It Does |
  51. |-------|--------------|
  52. | [ux-best-practices](skills/ux-best-practices/) | Design and review user experiences, including AI features, accessibility, interaction states, and evidence-grounded usability findings |
  53. | [code-that-fits-in-your-head](skills/code-that-fits-in-your-head/) | Keep agent-authored systems understandable and maintainable by resisting accidental complexity, Big Balls of Mud, and technical-debt accumulation. Supports large changes when architecture, acceptance criteria, verification, and recovery are explicit; uses structural heuristics without universal formatting or task-size limits |
  54. | [prompt-engineering](skills/prompt-engineering/) | Universal prompt-engineering toolkit. 14 reference docs covering Claude / GPT / Gemini family-specific guidance, prompting techniques, evaluation & red-teaming, common failure modes (hallucinations, security, structure, debt) |
  55. | [fpf-problem-solving](skills/fpf-problem-solving/) | First Principles Framework — a transdisciplinary "operating system for thought", with all 36 domain frameworks (strategy, goals/OKR, research, decision design, systems engineering and more) stored locally. Decompose cross-domain problems, audit conclusions, apply a named pattern such as F.19 or GOALS.7, and reason rigorously about complex systems. Based on Anatoly Levenchuk's [FPF Library](https://github.com/ailev/FPF) |
  56. | [bug-fix-protocol](skills/bug-fix-protocol/) | 8-step bug-fix protocol. Treats every production bug as **two** failures (the code defect + the testing system that allowed it through) and enforces a step-8 audit that closes the gap |
  57. | [pragmatic-verification](skills/pragmatic-verification/) | Language-agnostic playbook for thoughtful tests and checks: which cases go to unit, integration, contract or e2e, when to mock, how to avoid redundant, self-confirming, brittle and flaky tests, and which QA scenarios to run through browser, computer or phone use. Also audits an existing project's tests and gates: parallel workers on a cheaper model scan, the auditor verifies their claims and ranks concrete fixes |
  58. | [plan-mode](skills/plan-mode/) | Planning gate for any project change. Investigate context → analyse the task → surface ambiguities, contradictions, risks, and blockers → ask focused questions → produce an evidence-based, step-by-step plan → implement **only after explicit approval**, then validate. Compact always-on `SKILL.md` + full `PROTOCOL.md` |
  59. | [investigating-repository-history](skills/investigating-repository-history/) | Reconstruct historical intent before risky edits. Local `git blame`/`log` + GitHub PR/review evidence (via `gh`, never direct API), with squash/rebase/cherry-pick/rename/revert anomaly handling, decision-atom extraction, and confidence-scored output — produces a cited history note instead of guessing |
  60. | [refactoring-csharp](skills/refactoring-csharp/) | One-shot Roslyn contract for renaming C# symbols from `file + 1-based line + oldName`, with dry-run preview, safe file moves for supported named types, and explicit error codes |
  61. | [repo-activity-summary](skills/repo-activity-summary/) | Summarize what a repository has *been doing* from local `git log` — technologies, work types, churn hotspots, contributor patterns, velocity, and health signals. Stdlib-only Python, no network or API keys. Benchmarked at **−42% cost / −37% wall clock** versus the same agent answering the same question unaided, at equal factual accuracy; flags its own low-confidence classification instead of asserting it |
  62. ### AI infrastructure
  63. **Moved out:** the `openrouter-provider-ranking` skill now lives with the model selector in [rodion-m/model-that-fits-my-task](https://github.com/rodion-m/model-that-fits-my-task).
  64. ### Research & docs (3)
  65. | Skill | What It Does |
  66. |-------|--------------|
  67. | [semantic-scholar-deep](skills/semantic-scholar-deep/) | Deep research over the Semantic Scholar Graph API — backward references, recommendations, batch lookup (up to 500 IDs), multi-hop citation-graph BFS, snippet search. Ships with an optional paired subagent for token-isolated literature reviews |
  68. | [fetch-url-as-markdown](skills/fetch-url-as-markdown/) | URL → clean Markdown via local trafilatura (real-browser UA, anti-stub guards, structured exit codes), with Exa MCP as a fallback for JS-rendered or anti-bot pages. Drop-in replacement for built-in WebFetch |
  69. | [ubiquitous-language](skills/ubiquitous-language/) | Domain thesaurus manager — DDD naming consistency, thesaurus generation, naming audit, git-history mining for naming ambiguities |
  70. ### Multi-agent orchestration
  71. **Moved out:** the `agents-consilium` skill now lives in its own repository — [CodeAlive-AI/pragmatic-orchestration](https://github.com/CodeAlive-AI/pragmatic-orchestration) (CLI renamed to `porch`). Install it with `npx skills add CodeAlive-AI/pragmatic-orchestration@pragmatic-orchestration -g -y`.
  72. ### macOS & Windows system health (2)
  73. | Skill | What It Does |
  74. |-------|--------------|
  75. | [maintaining-macos-health](skills/maintaining-macos-health/) | Disk cleanup + dev-machine optimisation + proactive health alerting. Triage for kernel panic / watchdog timeout / `vm-compressor-space-shortage` / Jetsam events. Tiered cleanup, Mole safety guards, and a noise-resistant LaunchAgent alerter. Independent first-use opt-ins for bounded emergency package-cache cleanup (< 2%) and a Codex cleanup plan/page (<= 5%), with exact-session continuation and separate deletion confirmation. Both default off. Apple Silicon focus |
  76. | [maintaining-windows-health](skills/maintaining-windows-health/) | Windows 11 port of the macOS health skill. Triage flow for BSOD / Kernel-Power 41 / crash dumps / commit-memory pressure. Ten-tier cleanup playbook (Storage Sense → discuss-first) using native Microsoft tooling (cleanmgr / DISM / pnputil / vssadmin / wevtutil / powercfg), a drift-protected HTML cleanup UI with an NTFS-hardened apply validator, and a Task Scheduler + BurntToast alerter (interactive-session, hysteresis, calibration). Heavy AI/Docker/WSL focus |
  77. ### Niche utilities (2)
  78. | Skill | What It Does |
  79. |-------|--------------|
  80. | [clipboard](skills/clipboard/) | Copy text to macOS clipboard with optional rich formatting (HTML + plain text). Slack/LinkedIn-aware — uses HTML rich text instead of mrkdwn, and warns about `<table>` not rendering in chat targets |
  81. | [windows-qa-engineer](skills/windows-qa-engineer/) | Manual QA copilot for Windows 11 desktop apps (WinForms / WPF / UWP). Uses Microsoft UFO (UIA / Win32) + FastMCP `mount()` composition + MCP protocol |
  82. ### Hooks (1)
  83. Standalone agent-safety tooling that doesn't fit the skill format — typically because it has to live inside an agent's hook protocol or run as a compiled binary.
  84. | Hook | What It Does | Install |
  85. |------|--------------|---------|
  86. | [balanced-safety-hooks](hooks/balanced-safety-hooks/) | `bash-guard` — Claude Code `PreToolUse:Bash` safety hook in Go. Real Bash AST parsing via [`mvdan.cc/sh`](https://github.com/mvdan/sh) (heredocs, single-quoted prose, `sudo`/`env`/`xargs`/`bash -c`/`eval`/`ssh`/pipe-to-shell). Catastrophic-path matrix with safe-path carve-outs. **Default rule set uses `ask`, not `deny`** — agents trivially bypass `deny` by rephrasing. Covers `rm`/`unlink`/`shred`, ORM migrations, infra (kubectl/gcloud/helm/docker/terraform/`git push -f`), PaaS CLIs (railway/fly/heroku), DB clients (psql/redis-cli), and cloud control-plane API mutations | `curl -fsSL https://raw.githubusercontent.com/CodeAlive-AI/ai-driven-development/main/hooks/balanced-safety-hooks/install-prebuilt.sh \| sh` |
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 121 on GitHub
  87. ---
  88. ## Working principles
  89. This collection is built on four principles that show up across all skills:
  90. 1. **Cross-agent first.** Skills follow the [Agent Skills](https://agentskills.io) open standard so they work in Claude Code, Cursor, Codex, Gemini, OpenCode, Antigravity, Copilot CLI — anywhere `npx skills add` reaches.
  91. 2. **Low false-positive friction.** Tools that interrupt your workflow (the bash-guard hook, agent prompts) are tuned for high signal: only ask when the action is genuinely destructive, not when there's a fuzzy keyword match.
  92. 3. **Disciplined defaults.** Skills like `bug-fix-protocol` and `fpf-problem-solving` codify practices that pay off when the agent goes off the happy path — multi-step protocols rather than one-shot prompts.
  93. 4. **Token-cheap.** Skill descriptions are kept tight so they don't dominate context. The [`semantic-scholar-deep`](skills/semantic-scholar-deep/) skill goes further with an optional paired subagent for token-isolated research.
  94. ---
  95. ## Repository structure
  96. ```
  97. ai-driven-development/
  98. ├── .claude-plugin/
  99. │ ├── marketplace.json ← lists this repo as a single plugin (source: "./")
  100. │ └── plugin.json ← umbrella plugin manifest
  101. ├── skills/ ← canonical agent-skills layout
  102. │ ├── agentic-readiness/
  103. │ ├── bug-fix-protocol/
  104. │ ├── clipboard/
  105. │ ├── code-that-fits-in-your-head/
  106. │ ├── fetch-url-as-markdown/
  107. │ ├── fpf-problem-solving/
  108. │ ├── hooks-management/
  109. │ ├── installing-cli-tools/
  110. │ ├── investigating-repository-history/
  111. │ ├── maintaining-macos-health/
  112. │ ├── maintaining-windows-health/
  113. │ ├── mcp-management/
  114. │ ├── plan-mode/
  115. │ ├── plugins-management/
  116. │ ├── pragmatic-verification/
  117. │ ├── prompt-engineering/
  118. │ ├── refactoring-csharp/
  119. │ ├── repo-activity-summary/
  120. │ ├── semantic-scholar-deep/
  121. │ ├── settings-management/
  122. │ ├── skills-management/
  123. │ ├── ubiquitous-language/
  124. │ ├── ux-best-practices/
  125. │ └── windows-qa-engineer/
  126. ├── hooks/
  127. │ └── balanced-safety-hooks/ ← bash-guard (Go, pre-built binaries via release)
  128. ├── README.md
  129. ├── AGENTS.md ← canonical repository instructions
  130. ├── CLAUDE.md ← imports AGENTS.md for Claude Code
  131. └── LICENSE
  132. ```
  133. The same `skills/` directory is read by both `npx skills add` (the cross-agent CLI) and Claude Code's plugin install — no symlinks, no duplication. The `.claude-plugin/marketplace.json` declares this repo itself as a single plugin via `source: "./"`.
  134. ---
  135. ## Contributing
  136. Each skill lives in `skills/<skill-name>/` with a `SKILL.md` (agent-facing contract) and an optional `README.md` (human-facing entry). Most skills also have `references/`, `scripts/`, or `assets/` directories for supporting material.
  137. When adding a skill or materially changing one, refresh:
  138. - The skill's own `SKILL.md` and `README.md`
  139. - The relevant section table above
  140. - `.claude-plugin/plugin.json` and `.claude-plugin/marketplace.json` version (semver — minor bump for new skills, major for breaking interface changes)
  141. See [AGENTS.md](AGENTS.md) for the full development guide.
  142. ---
  143. ## Heritage
  144. This collection is the consolidation of nine previously-separate CodeAlive-AI repositories:
  145. - `agents-reflection-skills` (the 7 meta-skills, the marketplace base)
  146. - `prompt-engineering-skill`
  147. - `fpf-problem-solving-skill`
  148. - `clipboard-skill`
  149. - `claude-repo-explorer-skill`
  150. - `windows-qa-engineer-skill`
  151. - `ai-driven-development` (the original — bug-fix protocol)
  152. - `awesome-agent-skills` (5 skills + the bash-guard hook)
  153. The 7 meta-skills' commit history lives on in this repo (consolidated via `git mv`). The other source repos retain their own histories at their original URLs and will be archived with pointer READMEs shortly.
  154. ---
  155. ## License
  156. MIT
hooks/balanced-safety-hooks/install-prebuilt.sh · Bundled script · 366 lines · 1 finding marked
  1. #!/usr/bin/env bash
  2. # install-prebuilt.sh — install bash-guard from a GitHub release without a Go
  3. # toolchain. Detects OS/arch, downloads the matching binary + SHA256SUMS,
  4. # verifies the checksum, drops the binary at ~/.claude/hooks/bash-guard/ and/or
  5. # ~/.codex/hooks/bash-guard/, and patches Claude Code settings.json and/or
  6. # Codex hooks.json with a PreToolUse[matcher=Bash] entry.
  7. #
  8. # Pipe-friendly:
  9. # curl -fsSL https://raw.githubusercontent.com/CodeAlive-AI/ai-driven-development/main/hooks/balanced-safety-hooks/install-prebuilt.sh | sh
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 9 on GitHub
  10. #
  11. # With args (note `sh -s --` to forward args through the pipe):
  12. # curl -fsSL …install-prebuilt.sh | sh -s -- --shadow
  13. #
  14. # Pin a specific release:
  15. # BASH_GUARD_VERSION=bash-guard-v0.1.0 curl -fsSL …install-prebuilt.sh | sh
  16. #
  17. # Modes:
  18. # --live Real enforcement — emits ask for risky commands. Default.
  19. # --shadow Logs every decision, never prompts. For tuning safe paths.
  20. # --dry-run Same as shadow with a distinct log label.
  21. # --uninstall Remove the hook entry from settings.json and delete the binary.
  22. # --claude Install for Claude Code (default).
  23. # --codex Install for Codex CLI / Codex App.
  24. # --both Install for both agents.
  25. # --codex-native-prompts
  26. # Experimental: defer selected Codex ask decisions to
  27. # execpolicy prompt rules instead of fail-closed deny.
  28. set -euo pipefail
  29. REPO="CodeAlive-AI/ai-driven-development"
  30. CLAUDE_BIN_DIR="$HOME/.claude/hooks/bash-guard"
  31. CLAUDE_BIN_PATH="$CLAUDE_BIN_DIR/bash_guard.bin"
  32. CLAUDE_SETTINGS="$HOME/.claude/settings.json"
  33. CODEX_BIN_DIR="$HOME/.codex/hooks/bash-guard"
  34. CODEX_BIN_PATH="$CODEX_BIN_DIR/bash_guard.bin"
  35. CODEX_HOOKS="$HOME/.codex/hooks.json"
  36. CODEX_RULES="$HOME/.codex/rules/default.rules"
  37. mode="live"
  38. agent="claude"
  39. codex_native_prompts=0
  40. for arg in "$@"; do
  41. case "$arg" in
  42. --live) mode="live" ;;
  43. --shadow) mode="shadow" ;;
  44. --dry-run) mode="dry-run" ;;
  45. --uninstall) mode="uninstall" ;;
  46. --claude) agent="claude" ;;
  47. --codex) agent="codex" ;;
  48. --both) agent="both" ;;
  49. --codex-native-prompts) codex_native_prompts=1 ;;
  50. -h|--help)
  51. sed -n '2,/^$/p' "$0" | sed 's/^# \{0,1\}//'
  52. exit 0
  53. ;;
  54. *) echo "error: unknown arg: $arg" >&2; exit 2 ;;
  55. esac
  56. done
  57. require() {
  58. command -v "$1" >/dev/null 2>&1 || {
  59. echo "error: $1 is required" >&2
  60. [[ -n "${2:-}" ]] && echo "install: $2" >&2
  61. exit 1
  62. }
  63. }
  64. detect_platform() {
  65. local os arch
  66. os="$(uname -s | tr '[:upper:]' '[:lower:]')"
  67. arch="$(uname -m)"
  68. case "$os" in
  69. darwin|linux) ;;
  70. *) echo "error: unsupported OS: $os (need darwin or linux)" >&2; exit 1 ;;
  71. esac
  72. case "$arch" in
  73. x86_64|amd64) arch="amd64" ;;
  74. arm64|aarch64) arch="arm64" ;;
  75. *) echo "error: unsupported arch: $arch (need amd64 or arm64)" >&2; exit 1 ;;
  76. esac
  77. echo "${os}-${arch}"
  78. }
  79. # Resolve which release tag to install. Honour an explicit pin first, then
  80. # fall back to the newest tag whose name starts with `bash-guard-v` so that
  81. # unrelated releases in this monorepo (other skills, etc.) don't get picked up.
  82. resolve_tag() {
  83. if [[ -n "${BASH_GUARD_VERSION:-}" ]]; then
  84. echo "$BASH_GUARD_VERSION"
  85. return
  86. fi
  87. local tag
  88. tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=50" \
  89. | grep -oE '"tag_name":[[:space:]]*"bash-guard-v[^"]*"' \
  90. | head -1 \
  91. | sed -E 's/.*"(bash-guard-v[^"]*)"/\1/')" || true
  92. if [[ -z "$tag" ]]; then
  93. echo "error: no bash-guard-v* release found in $REPO" >&2
  94. exit 1
  95. fi
  96. echo "$tag"
  97. }
  98. download_and_verify() {
  99. local platform="$1" tag="$2"
  100. local asset="bash-guard-${platform}"
  101. local base="https://github.com/${REPO}/releases/download/${tag}"
  102. local tmp_bin tmp_sums expected actual sum_tool
  103. tmp_bin="$(mktemp)"
  104. tmp_sums="$(mktemp)"
  105. trap 'rm -f "$tmp_bin" "$tmp_sums"' RETURN
  106. echo " downloading ${asset} (${tag})…"
  107. curl -fsSL "${base}/${asset}" -o "$tmp_bin"
  108. curl -fsSL "${base}/SHA256SUMS" -o "$tmp_sums"
  109. expected="$(awk -v a="$asset" '$2 == a { print $1 }' "$tmp_sums")"
  110. if [[ -z "$expected" ]]; then
  111. echo "error: ${asset} not listed in SHA256SUMS" >&2
  112. exit 1
  113. fi
  114. if command -v shasum >/dev/null 2>&1; then sum_tool="shasum -a 256"
  115. elif command -v sha256sum >/dev/null 2>&1; then sum_tool="sha256sum"
  116. else echo "error: need shasum or sha256sum to verify the download" >&2; exit 1
  117. fi
  118. actual="$($sum_tool "$tmp_bin" | awk '{print $1}')"
  119. if [[ "$actual" != "$expected" ]]; then
  120. echo "error: checksum mismatch for ${asset}" >&2
  121. echo " expected: $expected" >&2
  122. echo " got: $actual" >&2
  123. exit 1
  124. fi
  125. install_verified_binary "$tmp_bin"
  126. }
  127. install_one_binary() {
  128. local src="$1" bin_dir="$2" bin_path="$3"
  129. # Replace any prior symlink (from source-based install) with a real dir.
  130. if [[ -L "$bin_dir" ]]; then
  131. rm "$bin_dir"
  132. fi
  133. mkdir -p "$bin_dir"
  134. cp "$src" "$bin_path"
  135. chmod +x "$bin_path"
  136. echo " installed: $bin_path"
  137. }
  138. install_verified_binary() {
  139. local src="$1"
  140. case "$agent" in
  141. claude|both) install_one_binary "$src" "$CLAUDE_BIN_DIR" "$CLAUDE_BIN_PATH" ;;
  142. esac
  143. case "$agent" in
  144. codex|both) install_one_binary "$src" "$CODEX_BIN_DIR" "$CODEX_BIN_PATH" ;;
  145. esac
  146. }
  147. backup_file() {
  148. local path="$1"
  149. if [[ -f "$path" ]]; then
  150. local ts
  151. ts="$(date +%Y%m%d-%H%M%S)"
  152. cp "$path" "$path.bak.$ts"
  153. echo " backup: $path.bak.$ts"
  154. fi
  155. }
  156. hook_entry_json() {
  157. local target="$1"
  158. local adapter="$2"
  159. local env_prefix="BASH_GUARD_ADAPTER=$adapter"
  160. if [[ "$adapter" == "codex" && "$mode" == "live" && "$codex_native_prompts" == 1 ]]; then
  161. env_prefix="$env_prefix BASH_GUARD_CODEX_DEFER_REASON_CODES=supabase.db_push"
  162. fi
  163. case "$mode" in
  164. shadow) printf '{"type":"command","command":"%s BASH_GUARD_SHADOW=1 %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
  165. dry-run) printf '{"type":"command","command":"%s BASH_GUARD_DRY_RUN=1 %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
  166. live) printf '{"type":"command","command":"%s %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
  167. esac
  168. }
  169. patch_claude_settings_install() {
  170. backup_file "$CLAUDE_SETTINGS"
  171. [[ -f "$CLAUDE_SETTINGS" ]] || { mkdir -p "$(dirname "$CLAUDE_SETTINGS")"; echo '{}' > "$CLAUDE_SETTINGS"; }
  172. local hook_entry tmp
  173. hook_entry="$(hook_entry_json '~/.claude/hooks/bash-guard/bash_guard.bin' claude)"
  174. tmp="$(mktemp)"
  175. jq --argjson entry "$hook_entry" '
  176. .hooks //= {} |
  177. .hooks.PreToolUse //= [] |
  178. .hooks.PreToolUse |=
  179. ( map( if .matcher == "Bash" then
  180. .hooks //= [] |
  181. .hooks |= ( map(select((.command // "") | test("bash-guard") | not)) + [$entry] )
  182. else . end ) ) |
  183. ( if any(.hooks.PreToolUse[]?; .matcher == "Bash") then .
  184. else .hooks.PreToolUse += [{"matcher":"Bash","hooks":[$entry]}] end )
  185. ' "$CLAUDE_SETTINGS" > "$tmp"
  186. mv "$tmp" "$CLAUDE_SETTINGS"
  187. echo " patched: $CLAUDE_SETTINGS"
  188. }
  189. patch_codex_hooks_install() {
  190. backup_file "$CODEX_HOOKS"
  191. [[ -f "$CODEX_HOOKS" ]] || { mkdir -p "$(dirname "$CODEX_HOOKS")"; echo '{"hooks":{}}' > "$CODEX_HOOKS"; }
  192. local hook_entry tmp
  193. hook_entry="$(hook_entry_json '~/.codex/hooks/bash-guard/bash_guard.bin' codex)"
  194. tmp="$(mktemp)"
  195. jq --argjson entry "$hook_entry" '
  196. .hooks //= {} |
  197. .hooks.PreToolUse //= [] |
  198. .hooks.PreToolUse |=
  199. ( map( if .matcher == "^Bash$" or .matcher == "Bash" then
  200. .hooks //= [] |
  201. .hooks |= ( map(select((.command // "") | test("bash-guard") | not)) + [$entry] ) |
  202. .matcher = "^Bash$"
  203. else . end ) ) |
  204. ( if any(.hooks.PreToolUse[]?; .matcher == "^Bash$" or .matcher == "Bash") then .
  205. else .hooks.PreToolUse += [{"matcher":"^Bash$","hooks":[$entry]}] end )
  206. ' "$CODEX_HOOKS" > "$tmp"
  207. mv "$tmp" "$CODEX_HOOKS"
  208. echo " patched: $CODEX_HOOKS"
  209. }
  210. patch_codex_rules_install() {
  211. mkdir -p "$(dirname "$CODEX_RULES")"
  212. touch "$CODEX_RULES"
  213. if grep -q 'bash-guard:begin supabase.db_push' "$CODEX_RULES"; then
  214. echo " rule present: $CODEX_RULES"
  215. return
  216. fi
  217. backup_file "$CODEX_RULES"
  218. cat >> "$CODEX_RULES" <<'EOF'
  219. # bash-guard:begin supabase.db_push
  220. prefix_rule(
  221. pattern=["supabase", "db", "push"],
  222. decision="prompt",
  223. justification="supabase db push pushes migrations to the remote database; require explicit approval before running.",
  224. match=["supabase db push", "supabase db push --include-all"],
  225. not_match=["supabase db reset --linked"],
  226. )
  227. # bash-guard:end supabase.db_push
  228. EOF
  229. echo " patched: $CODEX_RULES"
  230. }
  231. patch_selected_install() {
  232. case "$agent" in
  233. claude|both) patch_claude_settings_install ;;
  234. esac
  235. case "$agent" in
  236. codex|both)
  237. patch_codex_hooks_install
  238. if [[ "$codex_native_prompts" == 1 ]]; then
  239. patch_codex_rules_install
  240. fi
  241. ;;
  242. esac
  243. }
  244. patch_claude_settings_uninstall() {
  245. [[ -f "$CLAUDE_SETTINGS" ]] || return
  246. backup_file "$CLAUDE_SETTINGS"
  247. local tmp
  248. tmp="$(mktemp)"
  249. jq '
  250. if .hooks.PreToolUse then
  251. .hooks.PreToolUse |=
  252. map( if .matcher == "Bash" then
  253. .hooks |= map(select((.command // "") | test("bash-guard") | not))
  254. else . end )
  255. else . end
  256. ' "$CLAUDE_SETTINGS" > "$tmp"
  257. mv "$tmp" "$CLAUDE_SETTINGS"
  258. echo " removed bash-guard from $CLAUDE_SETTINGS"
  259. }
  260. patch_codex_hooks_uninstall() {
  261. [[ -f "$CODEX_HOOKS" ]] || return
  262. backup_file "$CODEX_HOOKS"
  263. local tmp
  264. tmp="$(mktemp)"
  265. jq '
  266. if .hooks.PreToolUse then
  267. .hooks.PreToolUse |=
  268. map( if .matcher == "^Bash$" or .matcher == "Bash" then
  269. .hooks |= map(select((.command // "") | test("bash-guard") | not))
  270. else . end )
  271. else . end
  272. ' "$CODEX_HOOKS" > "$tmp"
  273. mv "$tmp" "$CODEX_HOOKS"
  274. echo " removed bash-guard from $CODEX_HOOKS"
  275. }
  276. patch_codex_rules_uninstall() {
  277. [[ -f "$CODEX_RULES" ]] || return
  278. if ! grep -q 'bash-guard:begin supabase.db_push' "$CODEX_RULES"; then
  279. return
  280. fi
  281. backup_file "$CODEX_RULES"
  282. local tmp
  283. tmp="$(mktemp)"
  284. awk '
  285. /# bash-guard:begin supabase.db_push/ { skip=1; next }
  286. /# bash-guard:end supabase.db_push/ { skip=0; next }
  287. !skip { print }
  288. ' "$CODEX_RULES" > "$tmp"
  289. mv "$tmp" "$CODEX_RULES"
  290. echo " removed bash-guard rule from $CODEX_RULES"
  291. }
  292. uninstall_selected() {
  293. case "$agent" in
  294. claude|both)
  295. patch_claude_settings_uninstall
  296. if [[ -f "$CLAUDE_BIN_PATH" ]]; then
  297. rm "$CLAUDE_BIN_PATH"
  298. rmdir "$CLAUDE_BIN_DIR" 2>/dev/null || true
  299. echo " removed: $CLAUDE_BIN_PATH"
  300. fi
  301. ;;
  302. esac
  303. case "$agent" in
  304. codex|both)
  305. patch_codex_hooks_uninstall
  306. patch_codex_rules_uninstall
  307. if [[ -f "$CODEX_BIN_PATH" ]]; then
  308. rm "$CODEX_BIN_PATH"
  309. rmdir "$CODEX_BIN_DIR" 2>/dev/null || true
  310. echo " removed: $CODEX_BIN_PATH"
  311. fi
  312. ;;
  313. esac
  314. }
  315. case "$mode" in
  316. live|shadow|dry-run)
  317. echo "Installing bash-guard ($mode mode, prebuilt, agent: $agent)"
  318. require curl
  319. require jq "brew install jq (macOS) / apt install jq (Linux)"
  320. platform="$(detect_platform)"
  321. tag="$(resolve_tag)"
  322. download_and_verify "$platform" "$tag"
  323. patch_selected_install
  324. echo
  325. echo "Done."
  326. echo " Claude selftest: $CLAUDE_BIN_PATH --selftest"
  327. echo " Codex selftest: $CODEX_BIN_PATH --selftest"
  328. echo " Audit: tail -f ~/.claude/logs/bash-guard.jsonl | jq '.'"
  329. echo " Restart the agent. In Codex CLI/App, open /hooks and trust the new hook if prompted."
  330. echo " Codex live mode is fail-closed by default; --codex-native-prompts enables experimental execpolicy prompts."
  331. ;;
  332. uninstall)
  333. echo "Uninstalling bash-guard (agent: $agent)"
  334. require jq "brew install jq (macOS) / apt install jq (Linux)"
  335. uninstall_selected
  336. echo "Done."
  337. ;;
  338. esac

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.