agentleFS
nxd1184nxd1184/java-clean-code-skill/.claude/skills/java-clean-code/SKILL.md

java-clean-code

Skill1 starsChanged 7 months agoMITView on GitHub

Use when writing, reviewing, or refactoring Java code — services, controllers, libraries, batch jobs, CLIs (Spring Boot, Quarkus, plain Java). Triggers: "clean this up", "is this idiomatic?", code review on Java files, code-smell or technical-debt concerns, SOLID/DRY/SRP questions, TDD setup for Java.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. CasLubbers/code-design-skills★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Files
SKILL.md

Java Clean Code

Overview

20 high-ROI rules for Java, with topic references for depth. Same checklist for writing, reviewing, and refactoring.

When to Apply

Writing, reviewing, or refactoring Java classes/methods/endpoints/services; or answering principle questions about Java design.

Skip when: trivial edits, build/config files, non-Java code, or when the user opts out.

The Top 20 Rules

Each rule links to a reference file for depth. A subset keeps a Check hint where the name alone is ambiguous.

  1. Names reveal intent. naming
  2. Functions do one thing. functions
  3. ≤3 arguments per function. functions
  4. No flag (boolean) arguments. functions
  5. Command-Query Separation. Method either does OR answers, not both. functions
  6. One abstraction level per function. functions
  7. Stepdown rule (newspaper metaphor). High-level entry points at top, helpers below. formatting
  8. No hidden side effects. functions
  9. Exceptions over error codes. functions
  10. Law of Demeter — no trainwrecks. No a.getB().getC().doD() chains on objects (chains on data structures OK). objects-and-data
  11. Objects hide data; expose behavior. objects-and-data
  12. Single Responsibility Principle. solid
  13. DRY. functions
  14. Consistent vocabulary. naming
  15. Write the test first (TDD). testing
  16. Tests are FIRST. Fast, Independent, Repeatable, Self-validating, Timely. testing
  17. No magic numbers or unexplained literals. naming
  18. Early returns over deep nesting. Max 2 levels of nesting inside a function. functions
  19. Constructor injection (DIP). @Autowired field injection is a smell; inject via final constructor params. solid
  20. Comments earn their keep. Explain WHY, not WHAT. comments

Workflow

Writing: (1) Name the behavior — if you can't, the design isn't ready. (2) Write the failing test (JUnit 5). (3) Implement minimally, rules 2–6 in mind. (4) Self-check with the checklist below.

Reviewing: (1) Cite each violation by rule name (Demeter, SRP, DIP — never bare "R10") + file:line. (2) Prioritize severity — SRP/Demeter/testing gaps outrank naming nits. (3) Diff-style fixes, each naming the rule. (4) Open references/*.md for rationale.

References

Each rule links inline to the topic file. Additional depth: smells, architecture, concurrency, craftsmanship, creating-objects, generics, lambdas-and-streams, exceptions.

Pre-delivery checklist

  • Verb+noun names; no flags; ≤3 args.
  • Tests exist, run fast, written first.

Rationalizations

ExcuseCounter
"One more arg"Args/Flags: extract a record.
"Use Lombok @Data"DIP: write the explicit constructor.
"Fine for a demo"SRP holds under pressure.
"Review with bare numbers (R10)"Cite the rule name + references/*.md.

Violating the letter of a rule is violating its spirit. Pressure (time, demo, sunk cost) does not suspend the rules — it makes them more valuable.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.