agentleFS
testdino-hqtestdino-hq/google-styleguides-skills/java/SKILL.md

java

Skill15 starsChanged 9 months agoMITView on GitHub

Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use node and rust.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mcollinaSkill

    node

    Provides domain-specific best practices for Node.js development with TypeScript, covering type stripping, async patterns, error handling, streams, modules, testing, performance, caching, logging, and more. Use when setting up Node.js projects with native TypeScript support, configuring type stripping (--experimental-strip-types), writing Node 22+ TypeScript without a build step, or when the user mentions 'native TypeScript in Node', 'strip types', 'Node 22 TypeScript', '.ts files without compilation', 'ts-node alternative', or needs guidance on error handling, graceful shutdown, flaky tests, profiling, or environment configuration in Node.js. Helps configure tsconfig.json for type stripping, set up package.json scripts, handle module resolution and import extensions, and apply robust patterns across the full Node.js stack.

    Also in 3 projects that use this

  • MicrosoftSkill

    rust

    Use this guide when working on Rust changes in the FAST monorepo.

    Also in 4 projects that use this

The file

Files
SKILL.md

Google Java Style Guide

Official Google Java coding standards for consistent, maintainable code.

Golden Rules

  1. 2-space indentation — no tabs
  2. Column limit: 100 characters
  3. Use @Override whenever applicable
  4. No wildcard imports — import specific types
  5. Braces required even for single-statement blocks
  6. One top-level class per file
  7. Prefer interfaces for type definitions

Quick Reference

Naming Conventions

ElementConventionExample
Packageslowercase.dottedcom.example.project
Classes/InterfacesUpperCamelCaseUserService
MethodslowerCamelCasegetUserById
VariableslowerCamelCaseuserCount
ConstantsUPPER_SNAKE_CASEMAX_RETRIES
Type parametersSingle letterT, RequestT

Classes

// ✓ CORRECT
public class Animal {
    private final String name;

    public Animal(String name) {
        this.name = name;
    }

    public String speak() {
        return name + " makes a sound.";
    }
}

Control Structures

// ✓ CORRECT - braces always required
if (condition) {
    doSomething();
}

// ✗ INCORRECT - no braces
if (condition)
    doSomething();

// ✓ CORRECT - enhanced for loop
for (String item : items) {
    process(item);
}

Exception Handling

// ✓ CORRECT
try {
    processData(input);
} catch (IOException e) {
    logger.error("IO error: {}", e.getMessage());
    throw new ServiceException("Failed", e);
}

// ✓ CORRECT - try-with-resources
try (InputStream in = new FileInputStream(file)) {
    return IOUtils.toByteArray(in);
}

// ✗ INCORRECT
try {
    ...
} catch (Exception e) {    // too broad
    e.printStackTrace();   // don't use printStackTrace
}

Lambdas and Streams

// ✓ CORRECT
List<String> names = users.stream()
    .filter(u -> u.isActive())
    .map(User::getName)
    .sorted()
    .collect(Collectors.toList());

// ✓ CORRECT - method references
users.forEach(System.out::println);

Javadoc

/**
 * Finds a user by their unique identifier.
 *
 * @param userId the user's unique ID
 * @return an Optional containing the user, or empty if not found
 */
public Optional<User> findUserById(long userId) { ... }

Imports

// ✓ CORRECT
import java.util.List;
import java.util.Optional;

// ✗ INCORRECT
import java.util.*;  // no wildcard imports

Common Mistakes

MistakeCorrect Approach
Wildcard importsSpecific imports only
Omitting bracesAlways use braces
Missing @OverrideAlways annotate overridden methods
e.printStackTrace()Use a proper logger
Catching Exception broadlyCatch specific exceptions
4-space indentationUse 2-space indentation

When to Use This Guide

  • Writing new Java code
  • Refactoring existing Java
  • Code reviews
  • Setting up Checkstyle rules
  • Onboarding new team members

Install

npx skills add testdino-hq/google-styleguides-skills/java

Full Guide

See java.md for complete details, examples, and edge cases.

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.