File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # PreToolUse hook: block direct edits to generated dictionary data files.
3+ # These files are produced by the dictionary compiler and must not be edited manually.
4+ # Exit code 2 blocks the tool from executing.
5+
6+ set -euo pipefail
7+
8+ INPUT=$( cat)
9+ FILE_PATH=$( echo " $INPUT " | jq -r ' .tool_input.file_path // empty' )
10+
11+ if [[ -z " $FILE_PATH " ]]; then
12+ exit 0
13+ fi
14+
15+ # Block generated data files in Source/Data/
16+ case " $FILE_PATH " in
17+ * /Source/Data/data.txt|* /Source/Data/data-plain-bpmf.txt|* /Source/Data/associated-phrases-v2.txt)
18+ echo " Blocked: $FILE_PATH is a generated file. Edit the source and rebuild instead." >&2
19+ exit 2
20+ ;;
21+ esac
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # PostToolUse hook: auto-format C++/ObjC files with clang-format after edits.
3+ # Reads the tool input JSON from stdin to extract the edited file path.
4+
5+ set -euo pipefail
6+
7+ # Read stdin JSON and extract file_path
8+ INPUT=$( cat)
9+ FILE_PATH=$( echo " $INPUT " | jq -r ' .tool_input.file_path // empty' )
10+
11+ if [[ -z " $FILE_PATH " ]]; then
12+ exit 0
13+ fi
14+
15+ # Only format C++/ObjC source files
16+ case " $FILE_PATH " in
17+ * .cpp|* .h|* .mm|* .m)
18+ if [[ -f " $FILE_PATH " ]]; then
19+ xcrun clang-format -i " $FILE_PATH "
20+ fi
21+ ;;
22+ esac
Original file line number Diff line number Diff line change 1+ {
2+ "hooks" : {
3+ "PostToolUse" : [
4+ {
5+ "matcher" : " Edit|Write" ,
6+ "hooks" : [
7+ {
8+ "type" : " command" ,
9+ "command" : " bash .claude/hooks/format-cpp.sh"
10+ }
11+ ]
12+ }
13+ ],
14+ "PreToolUse" : [
15+ {
16+ "matcher" : " Edit|Write" ,
17+ "hooks" : [
18+ {
19+ "type" : " command" ,
20+ "command" : " bash .claude/hooks/block-generated-data.sh"
21+ }
22+ ]
23+ }
24+ ]
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ ---
2+ description : Verify branch and worktree before making edits
3+ user-invocable : false
4+ ---
5+
6+ # Branch Guard
7+
8+ Before editing files, verify:
9+
10+ 1 . ** Current branch** : Run ` git rev-parse --abbrev-ref HEAD ` and confirm it matches the expected branch for the current task.
11+
12+ 2 . ** Worktree isolation** : Run ` git rev-parse --show-toplevel ` and confirm edits target the correct worktree directory.
13+
14+ 3 . ** Clean state** : Run ` git status --porcelain ` and warn if there are uncommitted changes that might conflict.
15+
16+ If any check fails, stop and alert the user before proceeding.
Original file line number Diff line number Diff line change 1+ ---
2+ description : Build and run C++ engine tests
3+ user-invocable : true
4+ ---
5+
6+ # /engine-test
7+
8+ Build and run the full C++ engine unit tests.
9+
10+ ## Steps
11+
12+ 1 . Create the build directory if needed:
13+ ``` bash
14+ mkdir -p Source/Engine/build
15+ ```
16+
17+ 2 . Configure with CMake:
18+ ``` bash
19+ cd Source/Engine/build && cmake -DENABLE_TEST=ON ..
20+ ```
21+
22+ 3 . Build:
23+ ``` bash
24+ cd Source/Engine/build && make -j$( sysctl -n hw.ncpu)
25+ ```
26+
27+ 4 . Run tests:
28+ ``` bash
29+ cd Source/Engine/build && ctest --output-on-failure
30+ ```
31+
32+ Report test results. If any tests fail, show the failing test names and output.
You can’t perform that action at this time.
0 commit comments