AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

code-reviewer

Use for any code review: a pull request, a diff, a commit, or a pasted function, handler or file in TypeScript, JavaScript, Python, Go, Swift, Kotlin, C#/.NET, Java, C, C++, Rust, Ruby, PHP or Dart/Flutter. Applies per-language rule packs (security such as SQL injection and missing auth, async and resource handling, error handling, performance) and scripts that score a PR's risk and complexity, then gives a merge verdict with blocking and non-blocking findings. Use whenever the user asks to review, check or look over code, says 'code review', 'review this PR', 'review this diff' or 'is this safe to merge', or asks what is wrong with a snippet, even a single function.

Original source
alirezarezvani
License
MIT
Pinned revision
e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read alirezarezvani--code-reviewer at revision e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 16

languages/java.md


language: java extensions: [".java"]

Java — Language-Specific Review Notes

Load this file alongside rules/universal.md. Universal rules are not repeated here — only Java-specific rules and idioms.


PR Analyzer — Java Risk Signals

  • System.out.println / e.printStackTrace() left in production code
  • @SuppressWarnings annotations — verify they are justified
  • Hardcoded JDBC URLs or credentials in source
  • Raw type usage (List, Map without generics)

Code Quality — Java Checks

  • Empty catch blocks swallowing exceptions silently
  • Checked exceptions caught and not re-thrown with context
  • Closeable / AutoCloseable resources not in try-with-resources
  • Raw type usage — defeats generics type safety
  • Missing @Override on overriding methods
  • InterruptedException caught without calling Thread.currentThread().interrupt()

Security

  • Flag JPQL / HQL or native SQL string concatenation — require named parameters or CriteriaBuilder
  • Flag @RequestMapping without explicit HTTP method restriction on state-changing endpoints
  • Flag user-controlled input passed to Runtime.exec() or ProcessBuilder without validation
  • Flag ObjectInputStream.readObject() on untrusted data — unsafe deserialization
  • Flag hardcoded JDBC URLs or credentials — require environment variables or a vault

Async / Concurrency

  • Flag ExecutorService.submit() return value ignored — exceptions are swallowed
  • Flag Thread.sleep() used as a synchronization mechanism — use CountDownLatch, CompletableFuture, or await()
  • Flag CompletableFuture chains with no .exceptionally() or .handle() terminal handler
  • Flag InterruptedException caught without calling Thread.currentThread().interrupt()
  • Flag synchronized on a non-final field — the lock object can be replaced
  • Flag HashMap used in multi-threaded context — use ConcurrentHashMap

Resource Management

  • Flag InputStream, OutputStream, Connection, ResultSet, PreparedStatement not wrapped in try-with-resources
  • Flag manual finally { resource.close() } — replace with try-with-resources
  • Flag HttpURLConnection not disconnected after use
  • Flag JDBC Connection obtained from a pool and not returned (missing close()) on all paths
  • Flag static HttpClient or Connection fields shared across threads without connection pool management

Exception Handling

  • Flag empty catch blocks — catch (Exception e) {}
  • Flag InterruptedException caught without Thread.currentThread().interrupt() — breaks cooperative cancellation
  • Flag checked exceptions swallowed in a catch and not re-thrown or logged with context
  • Flag throw new RuntimeException(e) without a descriptive message — loses context
  • Flag printStackTrace() as the sole error handling — use a proper logger

Performance

  • Flag String concatenation in loops — use StringBuilder
  • Flag List.contains() / Map.get() in a loop on large collections — review data structure choice
  • Flag N+1 JPA / Hibernate queries — use JOIN FETCH or @BatchSize
  • Flag new ObjectMapper() / new Gson() instantiated per-request — share a singleton
  • Flag ResultSet fully iterated when only the first result is needed — use LIMIT 1 in the query

Idioms and Best Practices

Null Safety

  • Prefer returning Optional<T> over null from methods
  • Flag unchecked dereferences without a prior null guard
  • Do not catch NullPointerException — fix the root cause instead

Collections and Streams

  • Flag == used to compare String or boxed types — use .equals()
  • Flag .collect(Collectors.toList()) where .toList() (Java 16+) suffices
  • Flag premature .stream().collect() round-trips that could be a single-pass operation

Generics

  • Flag raw types in any new code — always parameterize (List<String>, not List)
  • Flag unchecked cast warnings suppressed without explanation

Modern Java (11+)

  • Prefer var for local variables where the type is obvious from the right-hand side
  • Prefer records for pure data carriers over manual POJOs with getters/setters
  • Prefer instanceof pattern matching (if (obj instanceof String s)) over explicit casts
  • Prefer switch expressions over switch statements where a value is returned