Category Archives: Useful Prompts

20 AI Prompts for Java Concurrency and CompletableFuture

Java concurrency is the topic that trips up senior engineers more than almost anything else in the ecosystem. It is not that the APIs are hard to read — CompletableFuture.thenCompose() is not a complicated method signature. The problem is that the consequences of getting it wrong are invisible until production load hits: a thread pool sized for 50 concurrent requests that quietly saturates at 200, a CompletableFuture chain that swallows exceptions because no one added exceptionally(), a fan-out that completes 99 of 100 calls in 50ms and then waits 30 seconds for the one that timed out. I have spent more time debugging Java concurrency bugs than I care to admit. The ones that hurt most were not deadlocks — those are at least loud. They were the silent ones: a shared SimpleDateFormat causing random NumberFormatException in production, a ForkJoinPool getting saturated by blocking I/O calls that belonged in a separate executor, a CompletableFuture chain that worked perfectly in tests because the test executor ran everything synchronously. These 20 prompts encode the diagnostic questions and implementation patterns I reach for in those situations. AI assistants are unusually well-suited to Java concurrency work. They know the java.util.concurrent API surface in full, understand the difference between thenApply and thenApplyAsync, can read a thread dump and identify the contention point, and will not lose track of which executor each stage of a pipeline is running on. The prompts below are structured to give the AI exactly what it needs to help: the right diagnostic data for debugging prompts, and the right context (pool sizes, workload type, latency targets) for implementation prompts.

This post gives you 20 copy-paste AI prompts for Java concurrency and CompletableFuture, progressing from fundamentals through advanced production patterns and into debugging. Each prompt is explained so you know when to reach for it and what context to provide for the best output.

For background on the underlying mechanics, see the Java Concurrency Deep Dive and Virtual Threads vs Platform Threads benchmarks. For the performance analysis layer, see 10 AI Prompts for Java Performance Optimization.

Continue reading 20 AI Prompts for Java Concurrency and CompletableFuture

Java 25 LTS: Every JEP That Matters (with AI Prompts for Each Migration)

Java 25 is the LTS that most production teams have been waiting for since Java 21. After spending several weeks working through a real Spring Boot 3.4 codebase with a Java 25 migration — updating dependencies, testing each JEP feature against actual production code, and specifically trying to break things with the new patterns — I came away with a clearer picture of which JEPs matter day-to-day versus which ones are mostly interesting in theory. What I did not expect: JEP 491 (synchronized no-pinning) had the biggest practical impact, and I found it in places I wasn’t looking. A legacy JDBC connection pool that I assumed was fine under virtual threads turned out to have been quietly starving the carrier pool. The other surprise was how little JEP 495 (Simple Source Files) moved the needle in a production context — useful for scripts and documentation, but rarely relevant inside a mature codebase. This post takes the format I could not find anywhere: one JEP per section, each with a concrete before-and-after, an explanation of what the JVM actually does differently, the pitfall that will bite you, and a copy-paste AI prompt to retrofit your existing codebase. The Java 21 to 25 feature overview and the upgrade AI prompts playbook are good starting points before this deeper dive.

Continue reading Java 25 LTS: Every JEP That Matters (with AI Prompts for Each Migration)

10 AI Prompts for Designing Java Microservices

Microservices architecture introduces a class of problems that monoliths simply do not have: partial failures, distributed transactions, network latency between services, schema versioning across independent deployments, and the operational complexity of coordinating dozens of independently deployed components. The first time I designed a circuit breaker configuration for a production service, I guessed the thresholds. The circuit opened too aggressively during a transient network hiccup and caused more downtime than the downstream failure it was meant to protect against. The second time, I ran the numbers from the downstream service’s SLA and worked backwards. There was no tutorial that taught me to do that — I learned it the hard way. These 10 prompts encode the questions you need to answer before you configure Resilience4j, write an OpenAPI contract, or design a Kafka consumer group — so the AI produces configuration that fits your actual failure scenario rather than a generic example. Getting these patterns right requires both architectural experience and fluency with a large surface area of libraries and specifications. AI assistants are well-positioned here — they know the Resilience4j API, the OpenAPI specification, the Kafka consumer group model, the Micrometer tracing API, and the Kubernetes health probe semantics.

This post gives you 10 copy-paste AI prompts for designing Java microservices. Each prompt targets a specific cross-cutting architecture concern and is engineered to produce production-grade, runnable output rather than pseudocode.

For related reading, see 10 AI Prompts for Spring Boot Development and the Java series. For the Spring AI and LLM Gateway patterns, see the LLM Gateway for Java Microservices post.

Continue reading 10 AI Prompts for Designing Java Microservices

10 AI Prompts for Java Performance Optimization

Java performance problems are notoriously difficult to diagnose: they are intermittent, load-dependent, and often invisible until a production incident. Reading a GC log, interpreting a thread dump, or identifying a memory leak in a heap dump requires both tool knowledge and pattern recognition that most developers only acquire after encountering these problems in production. I have sat in enough Java postmortems to recognise the pattern: the engineer who fixed the GC pause issue had seen that exact pause signature before. The one who found the connection pool leak recognised the symptom from a previous incident. That experience is transferable to an AI assistant if you provide the right diagnostic artifact in the right format — the AI knows the GC log structure, the HikariCP timeout messages, the thread dump markers for a deadlock. These 10 prompts are structured around that transfer: they tell you exactly which artifact to collect and how to present it for maximum diagnostic accuracy.

For related content, see Virtual Threads vs Platform Threads — Benchmarks and Code and 10 AI Prompts to Review and Improve Java Code Quality.

Continue reading 10 AI Prompts for Java Performance Optimization

10 AI Prompts for Hibernate and JPA

Hibernate is powerful and largely invisible when it works — and deeply confusing when it does not. N+1 queries, LazyInitializationException, detached entity exceptions, first-level cache surprises, and migration scripts that silently break the schema are problems that most Java developers encounter repeatedly throughout their careers. I started keeping a list of Hibernate bugs that slipped through review in a large Spring Boot 3 codebase — things that passed all unit tests, passed all integration tests, and only surfaced under production load or after a schema migration. After a dozen entries the pattern was clear: almost all of them were diagnosable by AI if you pasted the right context. The problem was knowing which context to paste. These 10 prompts encode that knowledge — each one specifies exactly what diagnostic data to provide, so the AI can reason about the real problem rather than the surface symptom. AI assistants handle Hibernate well: they know the JPA specification, the Hibernate-specific extensions, the Spring Data abstractions, and the performance implications of every mapping decision.

This post gives you 10 copy-paste AI prompts for Hibernate and JPA development. Each prompt is designed to produce production-quality output — not tutorial-level simplifications — and includes enough context for the AI to reason about the trade-offs specific to your use case.

For foundational reading, see the Hibernate Tutorials series. For complementary AI prompts, see 10 AI Prompts to Review and Improve Java Code Quality.

Continue reading 10 AI Prompts for Hibernate and JPA

10 AI Prompts to Review and Improve Java Code Quality

Code review is the most effective quality gate in software development — but it is also the most time-constrained. Reviewers scan for obvious bugs and style issues, but subtle problems like carrier pinning inside synchronized blocks, hidden N+1 queries in service layers, and resource leaks in non-obvious code paths regularly slip through. I built these prompts after a quarter where our team’s post-incident reviews kept surfacing the same categories of bug: thread-safety assumptions broken by virtual threads, transaction boundaries that worked in tests but silently failed under concurrent load, and SOLID violations that only became painful when the code needed to be extended. The pattern was clear — these were not one-off mistakes, they were the class of problem that human reviewers consistently miss because they require holding the entire call graph in working memory at once. AI assistants handle this better. These 10 prompts are structured to extract that analysis reliably.

This post gives you 10 AI prompts engineered for Java code quality review. Each prompt targets a specific class of problem, provides a structured diagnosis checklist, and requests actionable fixes rather than just observations. Use them before a pull request, as part of a legacy codebase audit, or as a learning tool when onboarding to an unfamiliar module.

For complementary content, see 10 AI Prompts to Generate JUnit 6 Tests and Virtual Threads vs Platform Threads — Benchmarks and Code.

Continue reading 10 AI Prompts to Review and Improve Java Code Quality

10 AI Prompts for Spring Boot Development

Spring Boot’s convention-over-configuration model is genuinely one of the best things to happen to Java productivity — and also the source of the most confusing production bugs I have debugged. Autoconfiguration fires conditions you never set consciously. Security filters block requests for reasons that aren’t logged. Default settings that are fine for development (open-in-view=true, 10-connection HikariCP pool, permissive CORS) quietly create problems at scale. I built this prompt set specifically for gaps I kept hitting when using AI assistants for Spring Boot work. Generic prompts produce boilerplate that compiles but ignores your Spring Boot version, your actual security requirements, and the performance implications of the defaults chosen. These 10 prompts are engineered around context: they ask you to provide your Spring Boot version, your business rules, and your actual failure scenario, so the AI produces output you can actually commit. Tested against Claude Sonnet 4 and GPT-4o with Spring Boot 3.4 and Spring Security 7. This post gives you 10 copy-paste AI prompts for Spring Boot development, covering the full lifecycle from initial scaffolding to production hardening and version migration. Each prompt is engineered to give the AI enough context to produce immediately usable, production-quality output. For background on the Spring ecosystem, see the Java category. For complementary testing prompts, see 10 AI Prompts to Generate JUnit 6 Tests for New Projects.

Continue reading 10 AI Prompts for Spring Boot Development