From 1f216243f01b628ca3e666873156e848ecf3020f Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Mon, 16 Feb 2026 13:44:00 +0100 Subject: [PATCH] Add Claude Code hooks and release skill - PostToolUse hook: auto-format .rs files with rustfmt after edit - PreToolUse hook: block direct edits to Cargo.lock - /release skill: build .deb and inspect package metadata Co-Authored-By: Claude Opus 4.6 --- .claude/hooks/block-cargo-lock.sh | 16 ++++++++++++++++ .claude/hooks/format-rs.sh | 8 ++++++++ .claude/settings.json | 27 +++++++++++++++++++++++++++ .claude/skills/release/SKILL.md | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100755 .claude/hooks/block-cargo-lock.sh create mode 100755 .claude/hooks/format-rs.sh create mode 100644 .claude/settings.json create mode 100644 .claude/skills/release/SKILL.md diff --git a/.claude/hooks/block-cargo-lock.sh b/.claude/hooks/block-cargo-lock.sh new file mode 100755 index 0000000..3032612 --- /dev/null +++ b/.claude/hooks/block-cargo-lock.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Block direct edits to Cargo.lock — it should only change via cargo +INPUT=$(cat) +FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') + +if [[ "$FILE_PATH" == *"Cargo.lock" ]]; then + echo '{ + "hookSpecificOutput": { + "hookEventName": "PreToolUse", + "permissionDecision": "deny", + "permissionDecisionReason": "Cargo.lock is auto-generated. Use cargo to update dependencies." + } + }' +else + exit 0 +fi diff --git a/.claude/hooks/format-rs.sh b/.claude/hooks/format-rs.sh new file mode 100755 index 0000000..7ae91f4 --- /dev/null +++ b/.claude/hooks/format-rs.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Auto-format Rust files after Edit/Write +INPUT=$(cat) +FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') + +if [[ "$FILE_PATH" == *.rs ]]; then + rustfmt --edition 2021 "$FILE_PATH" 2>/dev/null || true +fi diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..ee99580 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,27 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/format-rs.sh", + "statusMessage": "Formatting Rust code..." + } + ] + } + ], + "PreToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/block-cargo-lock.sh" + } + ] + } + ] + } +} diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md new file mode 100644 index 0000000..77b7b11 --- /dev/null +++ b/.claude/skills/release/SKILL.md @@ -0,0 +1,17 @@ +--- +name: release +description: Build claudify .deb package and show build info +disable-model-invocation: true +--- + +# Release + +Build the claudify .deb package and verify the output. + +## Steps + +1. Run `cargo tauri build` from the project root +2. Show the build output path and file size +3. Inspect the .deb package metadata with `dpkg-deb --info` +4. List the .deb package contents with `dpkg-deb --contents` +5. Report the package name, version, architecture, and installed size