Skip to main content
rule CX Codex

naming-format — Claude Code rule: Java style and setup

The naming-format Claude Code rule sets Java naming and formatting conventions. It covers classes, methods, constants, and control flow.

MIT ★ 517 updated 2026-11-16

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/naming-format.md
Open on GitHub

What naming-format does

The rule defines naming patterns for classes, methods, variables, constants, and packages. Boolean POJO properties must not start with is; getter and update methods use distinct verb prefixes. Formatting requirements cover indentation, line and method length, braces, and switch branches.

Control statements require braces, and if-else nesting is capped at three levels. Tabs or a method longer than 80 lines violate the stated limits. In Claude Code, install the rule at .claude/rules/naming-format.md.

What it helps with

  • standardize Java class and method names
  • catch is prefixes on Boolean POJO properties
  • check indentation, line length, and brace placement
  • flatten deeply nested if-else logic

Example prompts for the agent

  • Check this Java code against the naming-format rule.
  • Find naming and formatting violations in this class.
  • Check that every switch has a default branch.

How to install naming-format

Manually: put the files in place

.claude/rules/naming-format.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about naming-format

How do I install naming-format in Claude Code?

Add the rule file at .claude/rules/naming-format.md.

What does naming-format do?

It sets conventions for Java names and formatting. The rule bars the is prefix on Boolean POJO properties and requires braces around control statements.

What method naming and length rules does naming-format set?

Use get for one result, list for collections, and count for counts. Method names use lowerCamelCase, and a method must not exceed 80 lines.

Source text

naming-format.md · MIT
# Naming and formatting guidelines

## Naming conventions

### Basic naming rules
**Detection mode**: semantic

| Type | Rule ID | Convention | Example | Forbidden example |
|------|--------|------|------|---------|
| Class name | MULT-NAME-003 | UpperCamelCase | `UserDO`, `HtmlUtil`, `OrderService` | `userDo`, `htmlutil` |
| Method name | MULT-NAME-004 | lowerCamelCase | `getUserById()`, `calculateTotal()` | `GetUserById()`, `calculate_total()` |
| Constant | MULT-CONST-005 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT`, `DEFAULT_TIMEOUT` | `maxRetryCount`, `Max_Retry_Count` |
| Package name | MULT-NAME-009 | all lowercase, singular | `com.example.user` | `com.example.Users`, `com.example.userMgmt` |
| Variable | MULT-NAME-004 | lowerCamelCase | `userName`, `orderList` | `user_name`, `UserName` |
| Array | MULT-NAME-007 | `String[] args` | `String[] args` | `String args[]` |

### Special naming rules
**Detection mode**: semantic

| Rule ID | Rule | Description | Example |
|--------|------|------|------|
| MULT-NAME-006 | Abstract class | Must start with Abstract or Base | `AbstractProcessor`, `BaseServiceImpl` |
| MULT-NAME-006 | Exception class | Must end with Exception | `UserNotFoundException`, `InvalidParameterException` |
| MULT-NAME-006 | Test class | Name of the class under test + Test | `UserServiceTest`, `OrderControllerTest` |
| MULT-NAME-011 | Interface implementation | Impl suffix | `UserServiceImpl`, `OrderServiceImpl` |
| MULT-NAME-017 | Domain model | DO/DTO/VO/BO suffix | `UserDO`, `UserDTO`, `UserVO`, `UserBO` |
| MULT-NAME-013 | Enum class | Enum suffix | `StatusEnum`, `TypeEnum` |

### Boolean variable naming
**Detection mode**: semantic

**Boolean properties in POJOs must not use the is prefix (MULT-NAME-008):**

```java
// Wrong: causes serialization problems
public class User {
    private Boolean isSuccess;  // Forbidden!
    private boolean isActive;   // Forbidden!
}

// Correct
public class User {
    private Boolean success;
    private boolean active;
    
    // getter methods may use the is prefix
    public boolean isSuccess() {
        return success;
    }
}
```

### Method naming conventions
**Detection mode**: semantic

| Operation | Rule ID | Naming prefix | Example |
|---------|--------|---------|------|
| Get one | MULT-NAME-014 | get | `getUserById()`, `getOrderByNo()` |
| Get many | MULT-NAME-014 | list | `listUsersByStatus()`, `listOrdersByUser()` |
| Get count | MULT-NAME-014 | count | `countActiveUsers()`, `countOrders()` |
| Insert | MULT-NAME-014 | save/insert | `saveUser()`, `insertOrder()` |
| Delete | MULT-NAME-014 | remove/delete | `removeUser()`, `deleteOrder()` |
| Update | MULT-NAME-014 | update | `updateUserStatus()`, `updateOrderAmount()` |
| Predicate | - | is/has/can | `isActive()`, `hasPermission()`, `canDelete()` |

### Constant conventions
**Detection mode**: semantic

| Rule ID | Rule | Description |
|--------|------|------|
| MULT-CONST-001 | No magic values | Undefined constants must not appear directly |
| MULT-CONST-002 | Use uppercase L for long literals | `long amount = 2L` (lowercase l is forbidden) |
| MULT-CONST-003 | Group constants by function | Do not keep all constants in one class |
| MULT-CONST-004 | Use enum for fixed ranges | Use an enum when a variable's value changes only within a fixed range |

## Code formatting conventions

### Indentation and spacing
**Detection mode**: semantic

| Rule ID | Rule | Description |
|--------|------|------|
| MULT-FMT-001 | Indentation | 4 spaces; tab characters are forbidden |
| MULT-FMT-002 | Line length | No more than 120 characters |
| MULT-FMT-181 | Operator spacing | One space on each side: `a + b`, `a == b` |
| MULT-FMT-183 | Comma spacing | One space after a comma: `func(a, b, c)` |
| MULT-FMT-181 | Parenthesis spacing | One space between if/for/while and the parenthesis: `if (condition)` |
| MULT-FMT-184 | File encoding | UTF-8, Unix line endings |

### Brace rules
**Detection mode**: semantic

```java
// Correct: opening brace on the same line, body on the next line
if (condition) {
    doSomething();
} else {
    doOther();
}

// Wrong: opening brace on a new line
if (condition)
{
    doSomething();
}
```

### Control statements
**Detection mode**: semantic

**All control statements must use braces, even for a single line (MULT-CTRL-133):**

```java
// Wrong
if (condition) doSomething();

// Correct
if (condition) {
    doSomething();
}
```

**switch must have a default branch (MULT-CTRL-132):**

```java
switch (status) {
    case Status.ACTIVE:
        return "active";
    case Status.INACTIVE:
        return "inactive";
    default:
        return "unknown";
}
```

**if-else nesting must not exceed 3 levels; use guard clauses beyond that (MULT-CTRL-134):**

```java
// Wrong: nesting too deep
if (user != null) {
    if (user.isActive()) {
        if (user.hasPermission()) {
            // ...
        }
    }
}

// Correct: guard clauses
if (user == null) {
    return;
}
if (!user.isActive()) {
    return;
}
if (!user.hasPermission()) {
    return;
}
// Normal logic
```

### Method length limit
**Detection mode**: semantic

**A single method must not exceed 80 lines in total (MULT-FMT-186):**

```java
// Correct: single responsibility, manageable length
public UserDTO convertToDTO(UserDO userDO) {
    if (userDO == null) {
        return null;
    }
    UserDTO dto = new UserDTO();
    dto.setId(userDO.getId());
    dto.setName(userDO.getName());
    dto.setStatus(userDO.getStatus());
    return dto;
}
```

© kyy-logs · MIT · kyy-logs/code-review-gate-skill

Similar IDE rules

All IDE rules for Code review and refactoring →

From the same set10

The whole set →
baseline-java The baseline-java Claude Code rule adds Java checks for security, concurrency, and exception handling. It applies during Java code review. CX Codex +1 ★ 517repo stars spring-performance spring-performance is a Claude Code rule for Spring/JPA practices and performance tuning. It guides agents working on Java code, database queries, and server settings. CX Codex +1 ★ 517repo stars spring-performance The spring-performance Claude Code rule sets Spring/JPA and performance checks. It flags issues in validation, transactions, queries, and batch operations. CX Codex +1 ★ 517repo stars concurrency This Claude Code rule sets Java concurrency guidelines. It covers thread pools, locks, shared records, and other sources of concurrent access bugs. CX Codex +1 ★ 517repo stars exception-logging exception-logging — a rule for Claude Code that enforces Java exception handling and logging standards. Runs during code review to catch empty catch blocks, unmasked data, and missing transaction rollbacks. CX Codex +1 ★ 517repo stars testing-engineering The testing-engineering Claude Code rule sets expectations for unit tests, project structure, and dependencies. It covers application layers, exception handling, and domain models. CX Codex +1 ★ 517repo stars code-review-gate The code-review-gate Claude Code skill reviews code changes before a commit or PR merge. It gathers the diff, checks test quality, and records issues. CX Codex +1 ★ 517repo stars oop-collection The oop-collection Claude Code rule sets guidelines for Java objects and collections. It covers null checks, object comparisons, and safe list updates. CX Codex +1 ★ 517repo stars

Project sponsors

Companies that keep this analytics open