Skip to main content
rule CX Codex

baseline-java — Claude Code rule: Java checks

The baseline-java Claude Code rule adds Java checks for security, concurrency, and exception handling. It applies during Java code review.

MIT ★ 517 updated 2026-11-16

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

What baseline-java does

The rule flags SQL built by string concatenation, credentials embedded in source, and untrusted content passed to HTML rendering. It also checks calls to Runtime.exec and ProcessBuilder, along with logs that may expose sensitive fields.

Other checks cover shared SimpleDateFormat instances, thread-pool factories that can create unbounded resources, and empty catch blocks. Authorization needs a manual semantic check: queries for user data should include the current user or tenant, not just a business ID. The rule set can be edited for a project’s stack without changing the orchestration logic in SKILL.md.

What it helps with

  • spot SQL statements assembled through string concatenation
  • find credentials embedded in Java source
  • flag logs that expose sensitive values
  • catch empty exception handlers and shared date formatters
  • check whether user-data queries include a user or tenant condition

Example prompts for the agent

  • Review this Java code for security and concurrency issues.
  • Find credentials in the Java source and sensitive values in logs.
  • Check user-data queries for an authorization condition.

How to install baseline-java

Manually: put the files in place

.claude/rules/baseline-java.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 baseline-java

How do I install baseline-java in Claude Code?

Add the rule file at .claude/rules/baseline-java.md.

What does baseline-java do?

It checks Java code for common security, concurrency, and exception-handling issues, including unsafe SQL construction, exposed credentials, and empty catch blocks.

How does baseline-java check query authorization?

That check is semantic and manual. A query for user data should include userId or tenantId, rather than filtering only by orderId or id.

Source text

baseline-java.md · MIT
# Common baseline (Java)

A minimal usable rule set covering three high-frequency categories: security, concurrency, and exceptions.
Add or remove rules according to the project's actual stack; replacing this file does not affect the orchestration logic in `SKILL.md`.

## Security

### SEC-001 [HIGH] SQL string concatenation

SQL must use parameter binding; user input must never be concatenated into statements.

**Detection pattern** (any hit is a violation):
- `Statement[^;]*execute(Query|Update)?\s*\(\s*["'][^"']*["']\s*\+`
- `create(Query|NativeQuery)\s*\(\s*["'][^"']*["']\s*\+`
- `["'][^"']*(SELECT|INSERT|UPDATE|DELETE)[^"']*["']\s*\+`

### SEC-002 [HIGH] Hard-coded credentials

Passwords, keys, and tokens must not be written in source code.

**Detection pattern**:
- `(password|passwd|secret|token|apiKey|accessKey|privateKey)\s*=\s*"[^"]{6,}"`

### SEC-003 [HIGH] Dangerous XSS rendering

Untrusted content must not be passed directly to HTML rendering.

**Detection pattern**:
- `v-html|dangerouslySetInnerHTML|innerHTML\s*=`

### SEC-004 [HIGH] Command execution

Confirm that arguments do not come from user input before invoking a system command.

**Detection pattern**:
- `Runtime\.getRuntime\(\)\.exec\s*\(|new\s+ProcessBuilder\s*\(`

### AUTH-001 [HIGH] Missing authorization on queries
**Detection mode**: semantic

When querying user data by business ID, include the current user or tenant condition as well.

**Detection pattern**: none (manual check: whether the query condition contains only orderId / id, with no userId / tenantId)

## Logging and data

### LOG-001 [HIGH] Sensitive fields in logs

ID card numbers, phone numbers, bank card numbers, passwords, and tokens must not appear in logs in plaintext.

**Detection pattern**:
- `log(ger)?\.(info|debug|warn|error)\([^)]*(idCard|idNo|phone|mobile|bankCard|password|token)`

## Concurrency and exceptions

### CONC-001 [HIGH] Shared SimpleDateFormat

`SimpleDateFormat` is not thread-safe and must not be used as a static shared instance.

**Detection pattern**:
- `static\s+(final\s+)?SimpleDateFormat`

### CONC-002 [MEDIUM] Thread pool without explicit bounds

`Executors` factory methods can easily create unbounded queues or unlimited threads.

**Detection pattern**:
- `Executors\.(newCachedThreadPool|newFixedThreadPool)\s*\(`

### ERR-001 [HIGH] Empty catch swallows exceptions

An empty catch block fails silently; it must at least log the exception or rethrow it.

**Detection pattern**:
- `catch\s*\([^)]*\)\s*\{\s*\}`

© 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 →
index The index Claude Code rule describes the built-in code review files and how the tool locates them. A project rule pack replaces the built-in pack instead of merging with it. 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 naming-format The naming-format Claude Code rule sets Java naming and formatting conventions. It covers classes, methods, constants, and control flow. 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

Project sponsors

Companies that keep this analytics open