Run pre-commit quality checks for a Maven/Java project — auto-format, validate Checkstyle and PMD, and run the tests. Use before creating a commit, and when the user says "run the pre-commit checks", "am I ready to commit", "check this before I commit", or "is the working tree clean".
Scanned 9/5/2026
Install to Claude Code
npx -y skills add alexmond/alexmskills --skill precommit --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Precommit?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/alexmond-precommit)More formats (shields.io, HTML) on the badges page.
---
name: precommit
description: Run pre-commit quality checks for a Maven/Java project — auto-format, validate Checkstyle and PMD, and run the tests. Use before creating a commit, and when the user says "run the pre-commit checks", "am I ready to commit", "check this before I commit", or "is the working tree clean".
---
## Pre-commit Check: Format → Validate → Test
> **Try it:** `/maven-quality:precommit` — or say "format and validate this before I commit".
Run this before every commit to catch format, style, and test failures early.
Defaults target a Maven/Java project using spring-javaformat, Checkstyle, and
PMD. Adjust module names (`-pl`), profiles, and the `mvn` invocation to match
your project.
> Examples use the Maven wrapper `./mvnw`. If your environment has no wrapper,
> substitute your `mvn` binary, e.g.
> `bash "/path/to/mvn" <goal> -f pom.xml`.
> For multi-module builds, scope steps with `-pl <module>`.
---
### Step 1: Auto-format
```bash
./mvnw spring-javaformat:apply
```
---
### Step 2: Validate (Checkstyle + PMD)
```bash
./mvnw validate 2>&1 | grep -E "^\[ERROR\]|violations|PMD Failure"
```
If violations remain after auto-format, fix them manually (see the `codestyle`
skill). Do **not** proceed to Step 3 until `validate` passes cleanly.
---
### Step 3: Run tests
```bash
./mvnw test 2>&1 | tail -20
```
---
### Step 4: Report outcome
Summarize the result:
| Step | Result |
|------|--------|
| Format | Applied / Already clean |
| Validate | 0 violations / N violations (list them) |
| Tests | X passed, 0 failures / list failures |
- If everything is green, the working tree is ready to commit.
- If formatting changed files, list them so they can be staged.
- If any step fails, report which step failed with the error details, and fix it before committing.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!