From a9a3a7af754f370e6d4a045523d8dbeef2d3cbfa Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 18 May 2026 23:24:11 +0200 Subject: feat(claude): track CLAUDE.md, settings, agents, hooks, skills --- .claude/hooks/bash-format.sh | 5 ++++ .claude/hooks/black-format.sh | 5 ++++ .claude/hooks/clang-format.sh | 5 ++++ .claude/hooks/cmake-format.sh | 5 ++++ .claude/hooks/markdown-format.sh | 5 ++++ .claude/hooks/php-cs-fixer.sh | 5 ++++ .claude/hooks/qml-format.sh | 5 ++++ .claude/hooks/status-line.sh | 58 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 93 insertions(+) create mode 100755 .claude/hooks/bash-format.sh create mode 100755 .claude/hooks/black-format.sh create mode 100755 .claude/hooks/clang-format.sh create mode 100755 .claude/hooks/cmake-format.sh create mode 100755 .claude/hooks/markdown-format.sh create mode 100755 .claude/hooks/php-cs-fixer.sh create mode 100755 .claude/hooks/qml-format.sh create mode 100755 .claude/hooks/status-line.sh (limited to '.claude/hooks') diff --git a/.claude/hooks/bash-format.sh b/.claude/hooks/bash-format.sh new file mode 100755 index 0000000..b260fae --- /dev/null +++ b/.claude/hooks/bash-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.(sh|bash)$ ]] || head -1 "$file_path" 2>/dev/null | grep -q '^#!/.*bash\|^#!/.*sh'; then + shfmt -w "$file_path" +fi diff --git a/.claude/hooks/black-format.sh b/.claude/hooks/black-format.sh new file mode 100755 index 0000000..21fef5e --- /dev/null +++ b/.claude/hooks/black-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.py$ ]]; then + black -q "$file_path" +fi diff --git a/.claude/hooks/clang-format.sh b/.claude/hooks/clang-format.sh new file mode 100755 index 0000000..28b4c9c --- /dev/null +++ b/.claude/hooks/clang-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.(c|h|cpp|hpp)$ ]]; then + clang-format -i "$file_path" +fi diff --git a/.claude/hooks/cmake-format.sh b/.claude/hooks/cmake-format.sh new file mode 100755 index 0000000..fc1f2cc --- /dev/null +++ b/.claude/hooks/cmake-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ (CMakeLists\.txt|\.cmake)$ ]]; then + cmake-format -i "$file_path" +fi diff --git a/.claude/hooks/markdown-format.sh b/.claude/hooks/markdown-format.sh new file mode 100755 index 0000000..8728aeb --- /dev/null +++ b/.claude/hooks/markdown-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.(md|markdown)$ ]]; then + mdformat --number --extensions tables --extensions frontmatter --wrap 120 "$file_path" +fi diff --git a/.claude/hooks/php-cs-fixer.sh b/.claude/hooks/php-cs-fixer.sh new file mode 100755 index 0000000..247fa65 --- /dev/null +++ b/.claude/hooks/php-cs-fixer.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.php$ ]]; then + php-cs-fixer fix "$file_path" 2>/dev/null || true +fi diff --git a/.claude/hooks/qml-format.sh b/.claude/hooks/qml-format.sh new file mode 100755 index 0000000..70ad656 --- /dev/null +++ b/.claude/hooks/qml-format.sh @@ -0,0 +1,5 @@ +#!/bin/bash +file_path=$(jq -r '.tool_input.file_path') +if [[ "$file_path" =~ \.qml$ ]]; then + qmlformat --inplace "$file_path" +fi diff --git a/.claude/hooks/status-line.sh b/.claude/hooks/status-line.sh new file mode 100755 index 0000000..578dc2b --- /dev/null +++ b/.claude/hooks/status-line.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +input=$(cat) + +session_name=$(echo "$input" | jq -r '.session_name // empty') +project_dir=$(echo "$input" | jq -r '.workspace.project_dir') +cwd=$(echo "$input" | jq -r '.workspace.current_dir') +model=$(echo "$input" | jq -r '.model.display_name') + +total_in=$(echo "$input" | jq -r '.context_window.total_input_tokens // empty') +total_out=$(echo "$input" | jq -r '.context_window.total_output_tokens // empty') +ctx_size=$(echo "$input" | jq -r '.context_window.context_window_size // empty') +cur_in=$(echo "$input" | jq -r '.context_window.current_usage.input_tokens // empty') +cur_out=$(echo "$input" | jq -r '.context_window.current_usage.output_tokens // empty') +cache_read=$(echo "$input" | jq -r '.context_window.current_usage.cache_read_input_tokens // empty') + +git_branch=$(cd "$cwd" 2>/dev/null && git -c core.useBuiltinFSMonitor=false rev-parse --abbrev-ref HEAD 2>/dev/null) +git_stat=$(cd "$cwd" 2>/dev/null && git -c core.useBuiltinFSMonitor=false diff --shortstat HEAD 2>/dev/null | awk '{ + ins=0; del=0 + for (i = 1; i <= NF; i++) { + if ($i ~ /insertion/) { ins = $(i-1) } + if ($i ~ /deletion/) { del = $(i-1) } + } + if (ins > 0 || del > 0) { printf "+%d/-%d", ins, del } +}') + +output="" +[ -n "$session_name" ] && output="[$session_name] " + +project_name=$(basename "$project_dir") +output="${output}${project_name}" + +if [ -n "$git_branch" ]; then + git_info="git:$git_branch" + [ -n "$git_stat" ] && git_info="$git_info $git_stat" + output="$output ($git_info)" +fi + +output="$output | $model" + +if [ -n "$total_in" ] && [ -n "$total_out" ] && [ -n "$ctx_size" ]; then + total_used=$((total_in + total_out)) + used_k=$(awk "BEGIN {printf \"%.1f\", $total_used/1000}") + output="$output | Session: ${used_k}k" +fi + +if [ -n "$cur_in" ] && [ -n "$cur_out" ]; then + cur_total=$((cur_in + cur_out)) + cur_k=$(awk "BEGIN {printf \"%.1f\", $cur_total/1000}") + if [ -n "$cache_read" ] && [ "$cache_read" != "0" ]; then + cache_read_k=$(awk "BEGIN {printf \"%.1f\", $cache_read/1000}") + output="$output | Cached: ${cache_read_k}k (last:${cur_k}k)" + else + output="$output | Last: ${cur_k}k" + fi +fi + +echo "$output" -- cgit v1.3.1