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
Markdown
[](/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
- {
- "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
- "name": "ai-driven-development",
- "owner": {
- "name": "CodeAlive-AI",
- "email": "contact@codealive.ai"
- },
- "metadata": {
- "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).",
- "version": "10.10.0"
- },
- "plugins": [
- {
- "name": "ai-driven-development",
- "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.",
- "version": "10.10.0",
- "author": {
- "name": "CodeAlive-AI",
- "email": "contact@codealive.ai"
- },
- "homepage": "https://github.com/CodeAlive-AI/ai-driven-development",
- "repository": "https://github.com/CodeAlive-AI/ai-driven-development",
- "license": "MIT",
- "source": "./",
- "category": "developer-tools",
- "tags": [
- "skills",
- "meta-skills",
- "ai-driven-development",
- "agent-reflection",
- "engineering-practices",
- "mcp",
- "hooks",
- "plugins",
- "settings",
- "prompt-engineering",
- "fpf",
- "bug-fix-protocol",
- "research",
- "ubiquitous-language",
- "claude-code",
- "codex-cli",
- "opencode",
- "cursor"
- ],
- "keywords": [
- "claude-code",
- "codex-cli",
- "opencode",
- "cursor",
- "gemini-cli",
- "antigravity",
- "skills",
- "meta-skills",
- "ai-driven-development",
- "engineering-protocols",
- "prompt-engineering",
- "fpf",
- "bug-fix",
- "research",
- "mcp",
- "hooks",
- "plugins"
- ]
- }
- ]
- }
README.md · README · 213 lines · 1 finding marked
- <p align="center">
- <img src="https://img.shields.io/badge/Agent_Skills-Collection-blueviolet?style=for-the-badge" alt="Agent Skills Collection">
- <img src="https://img.shields.io/badge/Skills-24-blue?style=for-the-badge" alt="24 Skills">
- <img src="https://img.shields.io/badge/Hooks-1-yellow?style=for-the-badge" alt="1 Hook">
- <img src="https://img.shields.io/badge/Agents-12+-orange?style=for-the-badge" alt="12+ Agents">
- <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="MIT License">
- </p>
- <h1 align="center">AI-Driven Development</h1>
- <p align="center">
- <strong>Practices, protocols, and skills for AI-driven software development</strong>
- </p>
- <p align="center">
- 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.
- </p>
- ---
- ## Related Projects
- - [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`.
- - [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.
- ---
- ## Installation
- **Via Skills CLI** (recommended — works in 12+ agents):
- ```bash
- # 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:**
- ```bash
- /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's Included
- ### Agent reflection & meta (7)
- Meta-skills that let AI coding agents configure themselves. No more editing config files — just tell your agent what you need.
- | Skill | What It Does |
- |-------|--------------|
- | [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 |
- | [hooks-management](skills/hooks-management/) | Manage hooks and automation for Claude Code, Codex CLI, OpenCode, and Devin CLI/Desktop |
- | [settings-management](skills/settings-management/) | Configure settings for Claude Code (JSON), Codex CLI (TOML), OpenCode (JSON/JSONC), and Devin CLI/Desktop (JSON) |
- | [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 |
- | [plugins-management](skills/plugins-management/) | Package and publish plugins for Claude Code, OpenCode, and Devin CLI/Desktop (validate, scaffold, submit to Anthropic's directory) |
- | [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 |
- | [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 |
- ### Engineering practices (10)
- Disciplined approaches that improve how agents and humans collaborate on code.
- | Skill | What It Does |
- |-------|--------------|
- | [ux-best-practices](skills/ux-best-practices/) | Design and review user experiences, including AI features, accessibility, interaction states, and evidence-grounded usability findings |
- | [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 |
- | [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) |
- | [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) |
- | [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 |
- | [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 |
- | [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` |
- | [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 |
- | [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 |
- | [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 |
- ### AI infrastructure
- **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).
- ### Research & docs (3)
- | Skill | What It Does |
- |-------|--------------|
- | [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 |
- | [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 |
- | [ubiquitous-language](skills/ubiquitous-language/) | Domain thesaurus manager — DDD naming consistency, thesaurus generation, naming audit, git-history mining for naming ambiguities |
- ### Multi-agent orchestration
- **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`.
- ### macOS & Windows system health (2)
- | Skill | What It Does |
- |-------|--------------|
- | [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 |
- | [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 |
- ### Niche utilities (2)
- | Skill | What It Does |
- |-------|--------------|
- | [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 |
- | [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 |
- ### Hooks (1)
- 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.
- | Hook | What It Does | Install |
- |------|--------------|---------|
- | [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
- ---
- ## Working principles
- This collection is built on four principles that show up across all skills:
- 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.
- 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.
- 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.
- 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.
- ---
- ## Repository structure
- ```
- ai-driven-development/
- ├── .claude-plugin/
- │ ├── marketplace.json ← lists this repo as a single plugin (source: "./")
- │ └── plugin.json ← umbrella plugin manifest
- ├── skills/ ← canonical agent-skills layout
- │ ├── agentic-readiness/
- │ ├── bug-fix-protocol/
- │ ├── clipboard/
- │ ├── code-that-fits-in-your-head/
- │ ├── fetch-url-as-markdown/
- │ ├── fpf-problem-solving/
- │ ├── hooks-management/
- │ ├── installing-cli-tools/
- │ ├── investigating-repository-history/
- │ ├── maintaining-macos-health/
- │ ├── maintaining-windows-health/
- │ ├── mcp-management/
- │ ├── plan-mode/
- │ ├── plugins-management/
- │ ├── pragmatic-verification/
- │ ├── prompt-engineering/
- │ ├── refactoring-csharp/
- │ ├── repo-activity-summary/
- │ ├── semantic-scholar-deep/
- │ ├── settings-management/
- │ ├── skills-management/
- │ ├── ubiquitous-language/
- │ ├── ux-best-practices/
- │ └── windows-qa-engineer/
- ├── hooks/
- │ └── balanced-safety-hooks/ ← bash-guard (Go, pre-built binaries via release)
- ├── README.md
- ├── AGENTS.md ← canonical repository instructions
- ├── CLAUDE.md ← imports AGENTS.md for Claude Code
- └── LICENSE
- ```
- 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: "./"`.
- ---
- ## Contributing
- 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.
- When adding a skill or materially changing one, refresh:
- - The skill's own `SKILL.md` and `README.md`
- - The relevant section table above
- - `.claude-plugin/plugin.json` and `.claude-plugin/marketplace.json` version (semver — minor bump for new skills, major for breaking interface changes)
- See [AGENTS.md](AGENTS.md) for the full development guide.
- ---
- ## Heritage
- This collection is the consolidation of nine previously-separate CodeAlive-AI repositories:
- - `agents-reflection-skills` (the 7 meta-skills, the marketplace base)
- - `prompt-engineering-skill`
- - `fpf-problem-solving-skill`
- - `clipboard-skill`
- - `claude-repo-explorer-skill`
- - `windows-qa-engineer-skill`
- - `ai-driven-development` (the original — bug-fix protocol)
- - `awesome-agent-skills` (5 skills + the bash-guard hook)
- 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.
- ---
- ## License
- MIT
hooks/balanced-safety-hooks/install-prebuilt.sh · Bundled script · 366 lines · 1 finding marked
- #!/usr/bin/env bash
- # install-prebuilt.sh — install bash-guard from a GitHub release without a Go
- # toolchain. Detects OS/arch, downloads the matching binary + SHA256SUMS,
- # verifies the checksum, drops the binary at ~/.claude/hooks/bash-guard/ and/or
- # ~/.codex/hooks/bash-guard/, and patches Claude Code settings.json and/or
- # Codex hooks.json with a PreToolUse[matcher=Bash] entry.
- #
- # Pipe-friendly:
- # 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
- #
- # With args (note `sh -s --` to forward args through the pipe):
- # curl -fsSL …install-prebuilt.sh | sh -s -- --shadow
- #
- # Pin a specific release:
- # BASH_GUARD_VERSION=bash-guard-v0.1.0 curl -fsSL …install-prebuilt.sh | sh
- #
- # Modes:
- # --live Real enforcement — emits ask for risky commands. Default.
- # --shadow Logs every decision, never prompts. For tuning safe paths.
- # --dry-run Same as shadow with a distinct log label.
- # --uninstall Remove the hook entry from settings.json and delete the binary.
- # --claude Install for Claude Code (default).
- # --codex Install for Codex CLI / Codex App.
- # --both Install for both agents.
- # --codex-native-prompts
- # Experimental: defer selected Codex ask decisions to
- # execpolicy prompt rules instead of fail-closed deny.
- set -euo pipefail
- REPO="CodeAlive-AI/ai-driven-development"
- CLAUDE_BIN_DIR="$HOME/.claude/hooks/bash-guard"
- CLAUDE_BIN_PATH="$CLAUDE_BIN_DIR/bash_guard.bin"
- CLAUDE_SETTINGS="$HOME/.claude/settings.json"
- CODEX_BIN_DIR="$HOME/.codex/hooks/bash-guard"
- CODEX_BIN_PATH="$CODEX_BIN_DIR/bash_guard.bin"
- CODEX_HOOKS="$HOME/.codex/hooks.json"
- CODEX_RULES="$HOME/.codex/rules/default.rules"
- mode="live"
- agent="claude"
- codex_native_prompts=0
- for arg in "$@"; do
- case "$arg" in
- --live) mode="live" ;;
- --shadow) mode="shadow" ;;
- --dry-run) mode="dry-run" ;;
- --uninstall) mode="uninstall" ;;
- --claude) agent="claude" ;;
- --codex) agent="codex" ;;
- --both) agent="both" ;;
- --codex-native-prompts) codex_native_prompts=1 ;;
- -h|--help)
- sed -n '2,/^$/p' "$0" | sed 's/^# \{0,1\}//'
- exit 0
- ;;
- *) echo "error: unknown arg: $arg" >&2; exit 2 ;;
- esac
- done
- require() {
- command -v "$1" >/dev/null 2>&1 || {
- echo "error: $1 is required" >&2
- [[ -n "${2:-}" ]] && echo "install: $2" >&2
- exit 1
- }
- }
- detect_platform() {
- local os arch
- os="$(uname -s | tr '[:upper:]' '[:lower:]')"
- arch="$(uname -m)"
- case "$os" in
- darwin|linux) ;;
- *) echo "error: unsupported OS: $os (need darwin or linux)" >&2; exit 1 ;;
- esac
- case "$arch" in
- x86_64|amd64) arch="amd64" ;;
- arm64|aarch64) arch="arm64" ;;
- *) echo "error: unsupported arch: $arch (need amd64 or arm64)" >&2; exit 1 ;;
- esac
- echo "${os}-${arch}"
- }
- # Resolve which release tag to install. Honour an explicit pin first, then
- # fall back to the newest tag whose name starts with `bash-guard-v` so that
- # unrelated releases in this monorepo (other skills, etc.) don't get picked up.
- resolve_tag() {
- if [[ -n "${BASH_GUARD_VERSION:-}" ]]; then
- echo "$BASH_GUARD_VERSION"
- return
- fi
- local tag
- tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=50" \
- | grep -oE '"tag_name":[[:space:]]*"bash-guard-v[^"]*"' \
- | head -1 \
- | sed -E 's/.*"(bash-guard-v[^"]*)"/\1/')" || true
- if [[ -z "$tag" ]]; then
- echo "error: no bash-guard-v* release found in $REPO" >&2
- exit 1
- fi
- echo "$tag"
- }
- download_and_verify() {
- local platform="$1" tag="$2"
- local asset="bash-guard-${platform}"
- local base="https://github.com/${REPO}/releases/download/${tag}"
- local tmp_bin tmp_sums expected actual sum_tool
- tmp_bin="$(mktemp)"
- tmp_sums="$(mktemp)"
- trap 'rm -f "$tmp_bin" "$tmp_sums"' RETURN
- echo " downloading ${asset} (${tag})…"
- curl -fsSL "${base}/${asset}" -o "$tmp_bin"
- curl -fsSL "${base}/SHA256SUMS" -o "$tmp_sums"
- expected="$(awk -v a="$asset" '$2 == a { print $1 }' "$tmp_sums")"
- if [[ -z "$expected" ]]; then
- echo "error: ${asset} not listed in SHA256SUMS" >&2
- exit 1
- fi
- if command -v shasum >/dev/null 2>&1; then sum_tool="shasum -a 256"
- elif command -v sha256sum >/dev/null 2>&1; then sum_tool="sha256sum"
- else echo "error: need shasum or sha256sum to verify the download" >&2; exit 1
- fi
- actual="$($sum_tool "$tmp_bin" | awk '{print $1}')"
- if [[ "$actual" != "$expected" ]]; then
- echo "error: checksum mismatch for ${asset}" >&2
- echo " expected: $expected" >&2
- echo " got: $actual" >&2
- exit 1
- fi
- install_verified_binary "$tmp_bin"
- }
- install_one_binary() {
- local src="$1" bin_dir="$2" bin_path="$3"
- # Replace any prior symlink (from source-based install) with a real dir.
- if [[ -L "$bin_dir" ]]; then
- rm "$bin_dir"
- fi
- mkdir -p "$bin_dir"
- cp "$src" "$bin_path"
- chmod +x "$bin_path"
- echo " installed: $bin_path"
- }
- install_verified_binary() {
- local src="$1"
- case "$agent" in
- claude|both) install_one_binary "$src" "$CLAUDE_BIN_DIR" "$CLAUDE_BIN_PATH" ;;
- esac
- case "$agent" in
- codex|both) install_one_binary "$src" "$CODEX_BIN_DIR" "$CODEX_BIN_PATH" ;;
- esac
- }
- backup_file() {
- local path="$1"
- if [[ -f "$path" ]]; then
- local ts
- ts="$(date +%Y%m%d-%H%M%S)"
- cp "$path" "$path.bak.$ts"
- echo " backup: $path.bak.$ts"
- fi
- }
- hook_entry_json() {
- local target="$1"
- local adapter="$2"
- local env_prefix="BASH_GUARD_ADAPTER=$adapter"
- if [[ "$adapter" == "codex" && "$mode" == "live" && "$codex_native_prompts" == 1 ]]; then
- env_prefix="$env_prefix BASH_GUARD_CODEX_DEFER_REASON_CODES=supabase.db_push"
- fi
- case "$mode" in
- shadow) printf '{"type":"command","command":"%s BASH_GUARD_SHADOW=1 %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
- dry-run) printf '{"type":"command","command":"%s BASH_GUARD_DRY_RUN=1 %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
- live) printf '{"type":"command","command":"%s %s","timeout":30,"statusMessage":"Checking Bash command"}' "$env_prefix" "$target" ;;
- esac
- }
- patch_claude_settings_install() {
- backup_file "$CLAUDE_SETTINGS"
- [[ -f "$CLAUDE_SETTINGS" ]] || { mkdir -p "$(dirname "$CLAUDE_SETTINGS")"; echo '{}' > "$CLAUDE_SETTINGS"; }
- local hook_entry tmp
- hook_entry="$(hook_entry_json '~/.claude/hooks/bash-guard/bash_guard.bin' claude)"
- tmp="$(mktemp)"
- jq --argjson entry "$hook_entry" '
- .hooks //= {} |
- .hooks.PreToolUse //= [] |
- .hooks.PreToolUse |=
- ( map( if .matcher == "Bash" then
- .hooks //= [] |
- .hooks |= ( map(select((.command // "") | test("bash-guard") | not)) + [$entry] )
- else . end ) ) |
- ( if any(.hooks.PreToolUse[]?; .matcher == "Bash") then .
- else .hooks.PreToolUse += [{"matcher":"Bash","hooks":[$entry]}] end )
- ' "$CLAUDE_SETTINGS" > "$tmp"
- mv "$tmp" "$CLAUDE_SETTINGS"
- echo " patched: $CLAUDE_SETTINGS"
- }
- patch_codex_hooks_install() {
- backup_file "$CODEX_HOOKS"
- [[ -f "$CODEX_HOOKS" ]] || { mkdir -p "$(dirname "$CODEX_HOOKS")"; echo '{"hooks":{}}' > "$CODEX_HOOKS"; }
- local hook_entry tmp
- hook_entry="$(hook_entry_json '~/.codex/hooks/bash-guard/bash_guard.bin' codex)"
- tmp="$(mktemp)"
- jq --argjson entry "$hook_entry" '
- .hooks //= {} |
- .hooks.PreToolUse //= [] |
- .hooks.PreToolUse |=
- ( map( if .matcher == "^Bash$" or .matcher == "Bash" then
- .hooks //= [] |
- .hooks |= ( map(select((.command // "") | test("bash-guard") | not)) + [$entry] ) |
- .matcher = "^Bash$"
- else . end ) ) |
- ( if any(.hooks.PreToolUse[]?; .matcher == "^Bash$" or .matcher == "Bash") then .
- else .hooks.PreToolUse += [{"matcher":"^Bash$","hooks":[$entry]}] end )
- ' "$CODEX_HOOKS" > "$tmp"
- mv "$tmp" "$CODEX_HOOKS"
- echo " patched: $CODEX_HOOKS"
- }
- patch_codex_rules_install() {
- mkdir -p "$(dirname "$CODEX_RULES")"
- touch "$CODEX_RULES"
- if grep -q 'bash-guard:begin supabase.db_push' "$CODEX_RULES"; then
- echo " rule present: $CODEX_RULES"
- return
- fi
- backup_file "$CODEX_RULES"
- cat >> "$CODEX_RULES" <<'EOF'
- # bash-guard:begin supabase.db_push
- prefix_rule(
- pattern=["supabase", "db", "push"],
- decision="prompt",
- justification="supabase db push pushes migrations to the remote database; require explicit approval before running.",
- match=["supabase db push", "supabase db push --include-all"],
- not_match=["supabase db reset --linked"],
- )
- # bash-guard:end supabase.db_push
- EOF
- echo " patched: $CODEX_RULES"
- }
- patch_selected_install() {
- case "$agent" in
- claude|both) patch_claude_settings_install ;;
- esac
- case "$agent" in
- codex|both)
- patch_codex_hooks_install
- if [[ "$codex_native_prompts" == 1 ]]; then
- patch_codex_rules_install
- fi
- ;;
- esac
- }
- patch_claude_settings_uninstall() {
- [[ -f "$CLAUDE_SETTINGS" ]] || return
- backup_file "$CLAUDE_SETTINGS"
- local tmp
- tmp="$(mktemp)"
- jq '
- if .hooks.PreToolUse then
- .hooks.PreToolUse |=
- map( if .matcher == "Bash" then
- .hooks |= map(select((.command // "") | test("bash-guard") | not))
- else . end )
- else . end
- ' "$CLAUDE_SETTINGS" > "$tmp"
- mv "$tmp" "$CLAUDE_SETTINGS"
- echo " removed bash-guard from $CLAUDE_SETTINGS"
- }
- patch_codex_hooks_uninstall() {
- [[ -f "$CODEX_HOOKS" ]] || return
- backup_file "$CODEX_HOOKS"
- local tmp
- tmp="$(mktemp)"
- jq '
- if .hooks.PreToolUse then
- .hooks.PreToolUse |=
- map( if .matcher == "^Bash$" or .matcher == "Bash" then
- .hooks |= map(select((.command // "") | test("bash-guard") | not))
- else . end )
- else . end
- ' "$CODEX_HOOKS" > "$tmp"
- mv "$tmp" "$CODEX_HOOKS"
- echo " removed bash-guard from $CODEX_HOOKS"
- }
- patch_codex_rules_uninstall() {
- [[ -f "$CODEX_RULES" ]] || return
- if ! grep -q 'bash-guard:begin supabase.db_push' "$CODEX_RULES"; then
- return
- fi
- backup_file "$CODEX_RULES"
- local tmp
- tmp="$(mktemp)"
- awk '
- /# bash-guard:begin supabase.db_push/ { skip=1; next }
- /# bash-guard:end supabase.db_push/ { skip=0; next }
- !skip { print }
- ' "$CODEX_RULES" > "$tmp"
- mv "$tmp" "$CODEX_RULES"
- echo " removed bash-guard rule from $CODEX_RULES"
- }
- uninstall_selected() {
- case "$agent" in
- claude|both)
- patch_claude_settings_uninstall
- if [[ -f "$CLAUDE_BIN_PATH" ]]; then
- rm "$CLAUDE_BIN_PATH"
- rmdir "$CLAUDE_BIN_DIR" 2>/dev/null || true
- echo " removed: $CLAUDE_BIN_PATH"
- fi
- ;;
- esac
- case "$agent" in
- codex|both)
- patch_codex_hooks_uninstall
- patch_codex_rules_uninstall
- if [[ -f "$CODEX_BIN_PATH" ]]; then
- rm "$CODEX_BIN_PATH"
- rmdir "$CODEX_BIN_DIR" 2>/dev/null || true
- echo " removed: $CODEX_BIN_PATH"
- fi
- ;;
- esac
- }
- case "$mode" in
- live|shadow|dry-run)
- echo "Installing bash-guard ($mode mode, prebuilt, agent: $agent)"
- require curl
- require jq "brew install jq (macOS) / apt install jq (Linux)"
- platform="$(detect_platform)"
- tag="$(resolve_tag)"
- download_and_verify "$platform" "$tag"
- patch_selected_install
- echo
- echo "Done."
- echo " Claude selftest: $CLAUDE_BIN_PATH --selftest"
- echo " Codex selftest: $CODEX_BIN_PATH --selftest"
- echo " Audit: tail -f ~/.claude/logs/bash-guard.jsonl | jq '.'"
- echo " Restart the agent. In Codex CLI/App, open /hooks and trust the new hook if prompted."
- echo " Codex live mode is fail-closed by default; --codex-native-prompts enables experimental execpolicy prompts."
- ;;
- uninstall)
- echo "Uninstalling bash-guard (agent: $agent)"
- require jq "brew install jq (macOS) / apt install jq (Linux)"
- uninstall_selected
- echo "Done."
- ;;
- esac
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.