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
.claude/rules/naming-format.mdWhat 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
isprefixes on Boolean POJO properties - check indentation, line length, and brace placement
- flatten deeply nested
if-elselogic
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
switchhas adefaultbranch.
How to install naming-format
Manually: put the files in place
.claude/rules/naming-format.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/naming-format.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/naming-format.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/naming-format.mdManually: put the files in place
.clinerules/naming-format.mdStep 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