AI Coding Prompt Generator
0 characters
0 characters
Paste your code to generate the prompt.
Processed entirely in your browser — nothing is sent to a server.
A prompt handed to an AI assistant with no structure forces the assistant to guess at things a human reviewer would simply ask about: what language and version, what the code is supposed to do, what “done” looks like. Six parts consistently move a coding prompt from “vague guess” to “usable answer”: a role (what kind of expertise to bring to the task), context (the language, version, and framework the code actually runs on), the task itself (review, test, debug, refactor, explain, or document — stated plainly, not implied), the code verbatim, any relevant constraints (what the assistant must or must not change), and the output format you actually want back. Leaving any of these out doesn’t make the assistant ask a clarifying question — it makes it quietly assume an answer, often the wrong one.
Stack context matters more than it looks like it should. “Refactor this” gets a different, sometimes invalid answer depending on whether the target is Java 8 or Java 21: records, sealed classes, and virtual threads are simply unavailable below certain versions, and an assistant with no version information has no way to know which features are safe to suggest. The same is true for a test framework — a “write tests” prompt with no framework specified is as likely to come back mixing JUnit 4 and JUnit 5 APIs as picking either one consistently.
This tool assembles all of that into one prompt from a short form: pick a task, pick a language (Java gets dedicated version/framework/build-tool/test-framework fields; anything else gets a free-text language name and language-agnostic guidance), paste the code, and optionally add an error message, a focus area, or constraints. The result can be rendered two ways: Markdown, with headings and fenced code blocks — the safer default, readable in almost any chat interface — or XML tags, which some assistants parse more reliably when a prompt has several distinct sections that shouldn’t bleed into each other. Both are built by the same deterministic function from the same input; switching styles never changes what information is included, only how it’s delimited.
Every part of this — reading the form, building the prompt string, estimating its size, and scanning for accidentally pasted secrets — runs locally in your browser. Nothing is transmitted anywhere, and the tool never calls an AI model itself; it only prepares text you choose to paste into one.
Examples
Java code review, with Spring Boot 3.x and Java 21 selected:
# Role
You are an experienced software engineer helping with the following task: Code review.
# Context
- Language: Java
- Java version: 21
- Framework: Spring Boot 3.x
# Task
Get correctness, security, and maintainability feedback on existing code.
# Code
```java
@GetMapping("/users/{id}")
public User getUser(@PathVariable String id) {
return userRepository.findAll().stream()
.filter(u -> u.getId().equals(id))
.findFirst()
.get();
}
```
# Requirements
- Identify correctness bugs and edge cases first, then security concerns, then maintainability and readability issues.
- Rank findings by severity — critical, major, minor — rather than listing them in file order.
- For each finding, explain why it matters and suggest a concrete fix.
- Check null handling and Optional misuse — e.g. Optional.get() called without isPresent()/isEmpty() first, or a field or parameter typed Optional.
- Check that anything implementing AutoCloseable/Closeable is closed via try-with-resources, not a manual close() that can be skipped on an exception path.
- Check equals()/hashCode(): both should be overridden together, and neither should depend on a mutable field.
- Check thread-safety of any shared mutable state (fields read/written from more than one thread, mutable static fields).
- Flag swallowed exceptions (empty catch blocks) and overly broad catches (catch (Exception e) or catch (Throwable t)).
- Since a Spring/JPA-based framework is in use, also check transaction boundaries (@Transactional placement and propagation) and N+1 query patterns in repository/service code.
# Output format
A list of findings grouped by severity, each with a short explanation and a suggested fix.
If any of the information above is missing or unclear, state your assumptions explicitly, or ask clarifying questions before proceeding.
Debugging an error, with a stack trace pasted in:
# Task
Diagnose a bug from code plus an error message or stack trace.
# Error output
```
java.lang.NullPointerException: Cannot invoke "String.length()" because "name" is null
at com.example.orders.OrderService.validate(OrderService.java:42)
at com.example.orders.OrderService.placeOrder(OrderService.java:18)
```
# Requirements
- Work out the most likely root cause from the code and the error output below, rather than the first plausible-looking guess.
- If the code or error output doesn't contain enough information to diagnose the problem confidently, say what's missing and ask for it instead of guessing.
- Read the stack trace top-down to the first frame inside the project's own packages, not a library or JDK frame.
- If the exception has a "Caused by:" chain, follow it to the root cause rather than stopping at the outermost exception.
Unit tests, with JUnit 5 and Mockito selected — notice the framework-specific requirement lines this adds automatically:
# Requirements
- Cover the normal case, boundary values, and error/edge cases.
- Each test should verify exactly one behavior.
- Test through the public API — never rely on implementation-internal access to reach private members.
- Use parameterized tests (e.g. @ParameterizedTest) for boundary values instead of near-duplicate test methods.
- Mock collaborators — dependencies with real behavior or side effects — never simple value objects or data classes.
- Never use reflection to invoke or test private methods directly; test behavior through the class's public API.
- Use only the JUnit 5/6 Jupiter API (org.junit.jupiter.api.*) — never mix in JUnit 4's org.junit.Test or other JUnit 4 annotations.
- Mock collaborators using Mockito specifically — never mock simple value objects or data classes.
If the pasted code takes a JSON payload as input, running it through JSON Formatter first makes it easier to read before you paste it in here. Once an assistant returns an answer, AI Text Cleaner strips the em-dashes, curly quotes, and stock filler phrases that tend to show up in AI-written prose, before you paste that answer anywhere else.
Frequently asked questions
Is my code sent anywhere?
Which AI assistants does this work with?
Should I use Markdown or XML tags?
Is the token count exact?
Should I paste proprietary code into an AI assistant at all?
More specific versions of AI Coding Prompt Generator
Looking for one option in particular? These pages are pre-configured for it, with a worked example and copy-pasteable code: