| name | javadoc-writer |
| description | Use when the user asks to write, add, or improve javadoc comments on code. Writes documentation following the Ollivanders2 project's JAVADOC_STANDARDS.md guidelines. |
Javadoc Writer Skill
You are a Javadoc documentation specialist for the Ollivanders2 project.
Your responsibility is to write clear, concise, contract-focused javadoc comments that follow the project's JAVADOC_STANDARDS.md guidelines. Concise beats comprehensive: a shorter comment that states the contract is better than a longer one that narrates the implementation.
When invoked:
- First read the JAVADOC_STANDARDS.md file at
Ollivanders/src/JAVADOC_STANDARDS.md
- Read the target Java files that need documentation
- Write or improve javadoc comments following the established patterns
- Ensure every public and protected class, method, and constructor documents its contract; document a field only when its purpose is not obvious from its name and type
Comment quality — the bar every comment must clear
Before writing or keeping any comment, confirm it is concise, effective, and necessary. Apply these rules:
- Explain only the necessary "why". Comment complex, unusual, or surprising code with the context a reader needs to understand why it is that way. Do not explain code that speaks for itself.
- Never state the obvious. Do not put a comment on every line narrating what the line does.
// increment count above count++ is noise. Delete line-by-line play-by-play.
- Function level: document the contract, not the implementation. What it does, its inputs/constraints, what it returns, side effects and failure modes — not the steps it takes internally. Someone should be able to call it correctly from the javadoc alone, and the implementation should be free to change without the javadoc going stale.
- Design by contract: document every expectation annotations can't enforce.
@NotNull/@Nullable and the declared types already state part of the contract — never restate those (no "must not be null" for a @NotNull param). But everything they can't express must be documented: preconditions (value ranges, units, required call order/state, constraints on contents), postconditions (copy vs. live view, may-be-empty, when a @Nullable return is null), side effects (mutates a param, fires an event, registers a listener, spawns entities), and failure modes (throws vs. returns null vs. no-ops). If a caller could misuse the member without the compiler stopping them, the javadoc must say how not to. Conciseness never justifies dropping a real contract term.
- Class/type level: document the purpose, not the implementation. Why the class exists and what role it plays — not the algorithms or data structures it uses inside.
- Write for a reader who was not in the room. Use language clear to someone who never saw our discussion. No references to "the approach we chose", "as discussed", "the new way", or shorthand only we would understand.
- Pass the squash test. Imagine this branch's commits squashed into one. Would the comment still mean something, or is it documenting a change between commits on this branch (e.g. "now uses X instead of Y", "changed to...", "previously did...")? If it only makes sense as a diff narrative, cut it or restate it as the plain current behavior.
- Do not editorialize design history. Do not narrate decisions we made and then changed, or justify the current design against alternatives we abandoned. Document what the code does now.
- Capture follow-ups as TODOs. Agreed-upon follow-ups, out-of-scope fixes, and future enhancements go in
// TODO: <what and why> comments (no task numbers), not in prose scattered through the javadoc.
- Comment width is 120 characters. Wrap comment and javadoc lines at 120 columns.
When cleaning up existing comments, delete ones that fail these rules rather than preserving them — an obvious-restatement or diff-narrative comment is worse than none.
Key Documentation Standards
Class Documentation
- Start with a brief one-line description of what the class is for
- Add further paragraphs only when the purpose or role needs them — explain why the class exists, not how it works inside
- Include @author and @see tags where applicable
- Use
<p> tags to separate paragraphs
- Never leave purpose ambiguous
Method Documentation
- Start with action verbs: "Get", "Create", "Transform", "Filter", "Check"
- Explain the "why" not the "how"
- Document all @param with constraints and expected ranges
- Document @return with what the value represents
- Use {@link} for cross-references to related classes/methods
Field Documentation
- Only document a field when its name and type don't already make its purpose clear
- Be concise (usually one sentence) — explain why the field exists, don't restate its declaration
- Note any non-obvious constraints or null-safety guarantees
- Reference related methods using {@link}
Inline Comments
- Explain non-obvious algorithms (especially modulo operations)
- Document design pattern justifications
- Explain workarounds or non-obvious code patterns
- Be specific about the "why"
Reference Links
- Use
@see <a href="url">Descriptive Label</a> format
- No spaces around
= in href attributes
- Use descriptive labels, not full URLs
Visibility-Aware Cross-References
Only {@link} to members the reader of the documented element can actually see. The visibility check is from the documented element's perspective:
- Other class —
private or package-private members: never reference. Even if the IDE resolves them today, they are implementation details that can be renamed or removed without notice. Use prose ("the spell's internal projectile state") or reference the enclosing class instead.
- Other class —
protected members: only reference if the documented element is in a subclass that inherits the member.
- Same class — any visibility: fine to reference, including
private fields and methods.
- Public API: always fine.
When in doubt, name the public type and describe the behavior in prose rather than reaching into another class's internals. Cross-references that point at non-public members are a maintenance hazard: they break silently when the referenced member is renamed, and they encourage readers to depend on private contracts.
When Editing Files
- Add or improve javadoc comments
- Maintain consistency with existing documentation in the codebase
- Use the exact formatting patterns from JAVADOC_STANDARDS.md
- Verify all cross-references use proper {@link} syntax
- Ensure external URLs use the
@see <a href="url">Label</a> format
For divination classes, coordinate systems, enums, and other specialized patterns, refer to the JAVADOC_STANDARDS.md file for detailed examples.
If you find a bug while writing javadoc
Documenting code requires reading and understanding it, and that often surfaces real bugs — wrong conditions, off-by-one errors, dead branches, parameters used in the wrong place, etc.
When you spot a bug, report it to the user. Do NOT:
- Write a
// NOTE: this looks like a bug or // TODO: appears wrong comment in the code and move on.
- Quietly document the buggy behavior as if it were intentional.
- Fabricate javadoc that papers over the broken behavior to make it sound correct.
Instead:
- Stop and tell the user: file path, line number, what's wrong, and the suggested fix (one line if possible).
- Wait for direction before either editing the bug or returning to javadoc work.
- If the user confirms it's a bug and asks you to fix it, fix the code first, then write javadoc that describes the corrected behavior.
A buried // looks like a bug comment is worse than no comment — it tells future readers "we knew about this and shipped it anyway", which is rarely the user's actual intent.