Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rules Java?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-rules-java)
---
name: rules-java
description: "ANVIL coding rules for java code (**/*.java, **/*.kt, **/*Test.java, **/*Tests.java): Java Security, Java / Kotlin, Java Testing."
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# ANVIL rules: java
Follow these rules for java code (**/*.java, **/*.kt, **/*Test.java, **/*Tests.java).
## Java Security
# Java Security
- Never deserialize untrusted byte streams with `ObjectInputStream`; prefer schema-validated JSON and disable DTDs/external entities (`XXE`) on XML parsers.
- Use `PreparedStatement` or bound JPA query parameters exclusively; never concatenate user input into SQL, JPQL, or `ProcessBuilder` shell strings.
- Use `SecureRandom` and `MessageDigest.isEqual` for cryptographic tokens and MAC checks, never `java.util.Random` or `Arrays.equals`.
- Canonicalize file paths (`Path.normalize().toRealPath()`) inside allowed roots and avoid logging Authorization headers or credentials.
## Java / Kotlin
# Java / Kotlin
- try-with-resources for all closeables; `Optional` for absent return values.
- Constructor injection; immutable value objects.
- No blocking calls in reactive or coroutine code paths.
## Java Testing
# Java Testing
- Use JUnit 5 with `@ParameterizedTest` instead of copy-pasted test methods.
- Inject clocks (`java.time.Clock`) and fake HTTP/repository clients rather than hitting live networks or wall clocks.
- Use AssertJ or JUnit `assertAll` for clear failure diagnostics, and `@TempDir` for filesystem cleanup.
- Isolate slow database or integration suites with `*IT.java` or tags so fast unit checks finish quickly.