diff --git a/justfile b/justfile
index 92d8432..2a96cbf 100644
--- a/justfile
+++ b/justfile
@@ -61,3 +61,49 @@ verify:
javadoc:
./mvnw javadoc:javadoc
@echo "Javadoc: target/site/apidocs/index.html"
+
+# Format all Java files using Google Java Format
+format:
+ ./mvnw spotless:apply
+
+# Check if Java files are properly formatted (for CI/hooks)
+format-check:
+ ./mvnw spotless:check
+
+# Validate YAML files syntax
+yaml-check:
+ #!/usr/bin/env bash
+ set -euo pipefail
+ yaml_files=$(find . -name "*.yml" -o -name "*.yaml" | grep -v ".git" | grep -v "target")
+ if [ -z "$yaml_files" ]; then
+ echo "No YAML files found"
+ exit 0
+ fi
+ for file in $yaml_files; do
+ if ! ./mvnw validate -f "$file" &>/dev/null; then
+ # Fallback to basic syntax check using Python or yq if available
+ if command -v python3 &>/dev/null; then
+ python3 -c "import yaml; yaml.safe_load(open('$file'))" || {
+ echo "YAML validation failed for: $file"
+ exit 1
+ }
+ elif command -v yq &>/dev/null; then
+ yq eval "$file" > /dev/null || {
+ echo "YAML validation failed for: $file"
+ exit 1
+ }
+ else
+ echo "Warning: No YAML validator available (install python3 or yq)"
+ exit 0
+ fi
+ fi
+ done
+ echo "All YAML files are valid"
+
+# Install git hooks using lefthook
+hooks-install:
+ lefthook install
+
+# Uninstall git hooks
+hooks-uninstall:
+ lefthook uninstall
diff --git a/lefthook.yml b/lefthook.yml
new file mode 100644
index 0000000..35ef54f
--- /dev/null
+++ b/lefthook.yml
@@ -0,0 +1,24 @@
+# Lefthook configuration for java-faker
+# Install hooks with: just hooks-install
+# See: https://github.com/evilmartians/lefthook
+
+pre-commit:
+ parallel: true
+ commands:
+ compile:
+ run: just build
+
+ format-check:
+ glob: "*.java"
+ run: just format-check
+
+ yaml-validate:
+ glob: "*.{yml,yaml}"
+ run: just yaml-check
+
+# Optional: enforce conventional commit messages
+# Uncomment to enable
+# commit-msg:
+# commands:
+# conventional:
+# run: just commit-msg-check {1}
diff --git a/pom.xml b/pom.xml
index 1866689..d1eadcb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -157,6 +157,21 @@
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.45.0
+
+
+
+ 1.27.0
+
+
+
+
+
+
+