Generate, edit, refactor, and review Java source code according to the Google Java Style Guide. Use when Codex is asked to write Java code, update .java files, format Java snippets, review Java style, or keep Java output compliant with Google style conventions for file structure, imports, formatting, naming, comments, programming practices, and Javadoc.
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Apply Google Java Style to every Java source file or Java snippet produced by the task.
references/google-java-style-checklist.md before generating or modifying Java unless the request is only a very small style question already covered by SKILL.md.google-java-format, Maven, Gradle, or another configured formatter is available in the project, run the formatter after edits when it is practical and in scope.@Override, and Javadoc requirements. If violations are found, fix them and re-review until the output is clean before finalizing..java files with license header, package declaration, imports, and exactly one top-level class when the user asks for a file.module-info.java, package-info.java, or a snippet that cannot include one.Use this structure as the baseline for any new .java file:
// Copyright 2024 Example Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package com.example.myapp;
import java.util.List;
import java.util.Optional;
/**
* One-sentence summary of what this class does.
*
* <p>Optional extended description in a second paragraph.
*/
public final class MyClass {
private final List<String> items;
/** Constructs a {@code MyClass} with the given items. */
public MyClass(List<String> items) {
this.items = items;
}
/**
* Returns the first item, or {@link Optional#empty()} if there are none.
*/
public Optional<String> firstItem() {
return items.stream().findFirst();
}
}When reviewing Java code for style: