precommit

Automate Maven pre-commit checks for formatting, static analysis, and tests.

4|Updated Sep 24, 2025
One-click install
npx skills add https://github.com/alexmond/yj-schema-validator --skill precommit-alexmond
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: precommit
Source: https://github.com/alexmond/yj-schema-validator/tree/main/.claude/skills/precommit
Command: npx skills add https://github.com/alexmond/yj-schema-validator --skill precommit-alexmond

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automatically formats code, runs static analysis, and executes tests before commits to prevent style violations and broken builds in Java projects.

Core Features & Use Cases

  • Auto-formatting: Applies spring-javaformat:apply via the Maven wrapper to standardize code style.
  • Static analysis: Runs checkstyle and PMD through mvn validate to catch violations before commit.
  • Test execution: Executes mvn test to verify that tests pass locally prior to committing.

Quick Start

Commit code after installing the pre-commit hook; the process will format, validate, and test automatically.

Frequently Asked Questions about precommit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Maven pre-commit checks to format Java code and run tests before committing?

You can automate pre-commit checks by installing a hook that runs spring-javaformat:apply, mvn validate for checkstyle and PMD, and mvn test to format code, enforce style, and verify tests pass before each commit.

What do checkstyle and PMD static analysis checks do during a pre-commit hook?

Checkstyle and PMD static analysis checks run via mvn validate to catch code style violations and potential issues before commit, preventing broken builds and ensuring code quality in Java projects.

Do I need a Maven wrapper to run pre-commit formatting and static analysis locally?

Yes, running pre-commit checks requires a Maven wrapper (./mvnw), a properly configured Maven project, and access to project source files to perform auto-formatting, static analysis, and test execution.

What's the best way to enforce Java code formatting standards before pushing to a repository?

Applying spring-javaformat:apply through a pre-commit hook standardizes Java code style automatically, coordinating formatting, validation, and test execution in local development workflows to prevent style violations.

Can I run checkstyle and PMD validation automatically as part of my local Java workflow?

Yes, a pre-commit hook can coordinate checkstyle and PMD validation through mvn validate, automatically running static analysis to catch violations locally before code is committed.