Files
claude-howto/ja/06-hooks/log-bash.sh
T
Luong NGUYENandGitHub b9a973bf32 docs: accuracy pass against Claude Code v2.1.220 (#155)
Internal accuracy pass against v2.1.220 — no missing upstream features, but broken example code, disagreeing counts, and metadata drift.

Functional fixes: pre-commit.sh now exits 2 so it actually blocks; dependency-check.sh reads file_path from stdin JSON instead of $1; database-mcp.json uses ${DATABASE_URL}; broken fences repaired; three command templates had invalid skill names.

Factual corrections: /fork and /subtask unswapped and /subtask added; /fewer-permission-prompts; permissions.defaultMode; dontAsk/auto unreversed; 31 hook events verified name-by-name; subagent depth 3; skill precedence enterprise > project > personal; /output-style removed not deprecated; permissionDecision gained defer.

Follow-up review fixed defects the pass left behind: zh/vi headers claiming 31 events above 25-name lists, a surviving hardcoded DB credential in the MCP README examples, an unbalanced fence swallowing a metadata footer, and non-canonical tool names. All four translated CATALOG summary tables were recounted so their arithmetic holds.

Full detail in CHANGELOG.md under v2.1.220-r2.
2026-08-04 15:41:12 +07:00

32 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# すべての bash コマンドを記録する
# フック:PostToolUsematcher: Bash
#
# 標準入力の JSON から実行コマンドを読み取り、ファイルに記録する。
#
# 対応:macOS、Linux、WindowsGit Bash
# Claude Code フックプロトコルに従い、標準入力から JSON を読み取る
INPUT=$(cat)
# tool_input から bash コマンドを抽出
# 注:sed の [^"]* は JSON 内のエスケープされた引用符で停止する。ダブルクォートを
# 含むコマンドの場合、最初の \" までしかキャプチャできない。これは sed ベースの
# JSON パースの既知の制約だが、ロギング用途としては許容範囲。
COMMAND=$(echo "$INPUT" | sed -n 's/.*"command"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
if [ -z "$COMMAND" ]; then
exit 0
fi
TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
LOGFILE="$HOME/.claude/bash-commands.log"
# ログディレクトリが無ければ作成
mkdir -p "$(dirname "$LOGFILE")"
# コマンドを記録
echo "[$TIMESTAMP] $COMMAND" >> "$LOGFILE"
exit 0