Skip to content
Back to skills

Precommit

ASecurity

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".

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
ai-agentsgojavabashspring

Security analysis

A100/100

Scanned September 5, 2026

npx -y skills add alexmond/alexmskills --skill precommit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Precommit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Precommit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alexmond-precommit/badge)](https://www.skillsdirectory.com/skills/alexmond-precommit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…