From 491d9302662e0e8dbaac9db3406139d89df14bdd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 4 May 2026 22:57:11 +0900 Subject: claude: __claude-code-block-bash-tool --- .config/claude/settings.json | 15 ++++++++++++++- bin/__claude-code-block-bash-tool | 8 ++++++++ home-manager/modules/common.nix | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 bin/__claude-code-block-bash-tool diff --git a/.config/claude/settings.json b/.config/claude/settings.json index 98d819f..1dc9b1e 100644 --- a/.config/claude/settings.json +++ b/.config/claude/settings.json @@ -15,7 +15,8 @@ "Bash(rg:*)", "Bash(touch:*)", "Bash(tree:*)", - "Bash(wc:*)" + "Bash(wc:*)", + "Skill(conventional-commit)" ], "deny": [ "Bash(git push:*)", @@ -27,6 +28,18 @@ "disableBypassPermissionsMode": "disable" }, "hooks": { + "PreToolUse": [ + { + "matcher": "Bash", + "hooks": [ + { + "type": "command", + "command": "__claude-code-block-bash-tool rm", + "if": "Bash(rm *)" + } + ] + } + ], "Notification": [ { "hooks": [ diff --git a/bin/__claude-code-block-bash-tool b/bin/__claude-code-block-bash-tool new file mode 100644 index 0000000..b95771f --- /dev/null +++ b/bin/__claude-code-block-bash-tool @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +case "$1" in + rm) + echo "The command 'rm' is denied. Use 'git rm' if the file or the directory is tracked by git. If not, request deletion to user.";; +esac + +exit 2 diff --git a/home-manager/modules/common.nix b/home-manager/modules/common.nix index 63e8ab4..edbcf3c 100644 --- a/home-manager/modules/common.nix +++ b/home-manager/modules/common.nix @@ -150,6 +150,7 @@ in ".local/share/fonts/BIZUDPGothic-Regular.ttf".source = "${pkgs.biz-ud-gothic}/share/fonts/truetype/BIZUDPGothic-Regular.ttf"; ".zshrc".source = ../config/zsh/.zshrc; + "bin/__claude-code-block-bash-tool".source = ../../bin/__claude-code-block-bash-tool; "bin/__claude-code-notify".source = ../../bin/__claude-code-notify; "bin/__claude-code-statusline".source = ../../bin/__claude-code-statusline; "bin/tmux-pane-idx".source = ../../bin/tmux-pane-idx; -- cgit v1.3.1