How to optimize a prompt in six steps before you trust the rewrite
A rewritten prompt can sound clearer and still fail the job. Extra roles, longer instructions, or a more polished tone will change the model's output, but a change is not an improvement until it meets a standard you can
A rewritten prompt can sound clearer and still fail the job. Extra roles, longer instructions, or a more polished tone will change the model's output, but a change is not an improvement until it meets a standard you can actually check. If you write prompts that other people, scripts, or future you will reuse, that distinction matters more than a single good-looking answer.
This article walks through a repeatable way to revise an existing prompt: define what a usable answer must do, test the current wording on representative inputs, and change only the narrow part that could explain a failure. The method is for developers, writers, and researchers who need instructions they can run more than once. Reading this page is free. If you later use the public guide linked below, local templates there are free without signing in; any AI rewrite requires an account, and the credit cost is shown before the run.
Write the success criteria before you edit
Start with the decision the model must make, not with βmake it better.β A usable definition is observable. For example: return valid JSON with every required field; quote only the supplied source; and flag the case for a human when the evidence is incomplete. A goal like βbe more accurateβ or βsound professionalβ will push you toward subjective edits that you cannot compare.
Write the checks down first:
- Task completion. Did the answer do the requested operation, not a nearby one?
- Evidence. Are claims grounded in the material you actually provided?
- Format. Can the next person or system parse the result?
- Uncertainty. When information is missing or conflicting, does the prompt allow a safe fallback instead of a confident guess?
If you use another model to grade outputs, confirm that the grader is applying the same checks a human would. A generic βqualityβ score can hide a missing field, an unsupported claim, or a format break.
Build a small set of representative inputs
You do not need a huge dataset to start. Three carefully chosen cases usually reveal more than a pile of near-duplicates:
- A routine input the prompt should handle cleanly.
- A boundary case (two issues at once, an ambiguous audience, a long or noisy input).
- An input with missing or conflicting information.
For each case, record what a passing answer must do. Keep the cases that fail. Deleting the hard examples makes every later comparison look better than it is. A small set is a practical check, not statistical proof that the prompt will work on every future input.
A six-step loop you can repeat
Work on one existing prompt at a time. Keep the model, settings, tools, and supplied context unchanged while you compare versions, otherwise you cannot tell what caused the difference.
- Describe the job. State the input, the action, and who or what will use the answer. Keep instructions separate from quoted or retrieved material so source text is not treated as a new rule.
- Specify the output. Name required fields, format, length limits, and what to do when a requirement cannot be met. A short schema or example is often clearer than another paragraph of adjectives.
- Run a baseline. Save the current prompt and the test inputs. Record where it already passes or fails.
- Diagnose one failure. Find the smallest observable issue: a missing field, a label outside the allowed set, an invented fact, or invalid markup. If one missing rule explains the failure, do not rewrite the entire prompt.
- Change one likely cause. Add or revise the narrowest instruction, example, constraint, or context source. Changing several things at once makes the next test hard to interpret.
- Retest and decide. Run the same examples, plus the case that exposed the failure. Accept, reject, or revise the candidate, and write down why. Keep the previous version so you can roll back.
This is prompt optimization in the narrow sense: you start from a prompt that already exists, and you let observed results decide the next edit. It overlaps with prompt engineering, but it is not the same starting point. Engineering is how you design an instruction for a new task. Optimization is how you revise one after you have seen it fail.
Optimization produces a candidate that survived your checks. It does not guarantee that every later answer will be correct, or that the same wording will hold after the model, tools, or context change. When those conditions change, rerun the tests.
Worked example: a log-triage prompt
Suppose a team starts with: βReview this error log.β The request leaves the severity scale, the treatment of multiple incidents, the evidence standard, and the output format undefined. A model may return a reasonable-sounding paragraph that a ticket system cannot parse, or it may invent a root cause the log never states.
A more testable version makes those decisions explicit:
You triage application error logs. Identify each distinct incident using only the log text.
Allowed severity values: critical, warning, info.
If the log is incomplete or the incident is ambiguous, set needs_human_review to true.
Return valid JSON with incidents, severity, evidence, and needs_human_review.
Do not infer causes that the log does not state.
Prepare at least three inputs:
- A clear timeout with a stack frame (should produce a parseable incident and evidence).
- A log that contains both an authentication failure and a separate disk warning (should not collapse them into one label).
- A line such as βsomething looks off in productionβ with no codes or timestamps (should set
needs_human_reviewrather than invent a diagnosis).
Before you keep the rewrite, check all three cases against the criteria. If the model still invents a cause, the next edit should tighten the evidence ruleβnot add an unrelated persona. If the answers are well written but not valid JSON, fix the output contract and leave the severity rules alone.
Choose the right lever when the prompt is not the problem
More wording cannot supply a policy document that was never retrieved, grant a tool the model cannot call, or make an unsupported claim reliable. If the failure is missing facts, fix the context. If the task is impossible with the available model or tools, fix that gap. If one edit repairs a single example and breaks another, the evaluation set is incomplete.
Use a checklist or a pass/fail rubric before you reach for an aggregate score. Length is not a quality signal. Extra instructions can conflict, raise cost, and make a simple task harder to follow. Include a sentence only when it changes a decision or an output requirement.
What you are reading, and what using the guide costs
The public guide above is a written walkthrough of this same practice: it defines the term, separates it from general prompt engineering, and works a comparable example. It is written for people who want a repeatable improvement process, not a one-off rewrite. Reading the guide is free.
If you use the workspace on that site, creating, editing, and copying a local template in the browser does not require an account and costs 0 credits. Saving, copying, and exporting items in the prompt library is also listed at 0 credits. Asking the site to run an AI optimization does require you to sign in. Text optimization is billed by input length, and the interface shows the credit cost before you run the task. On the pricing page last updated 2 December 2026, the listed rates are 1 credit for text up to 2,000 characters, 2 credits for 2,001β6,000 characters, and 3 credits above 6,000 characters. A separate structure score is listed at 1 credit. Actual deduction should match the quote shown in the UI before you confirm a run. Rates can change; believe the pre-run quote if it differs from this summary.
Keep a revision only when it passes the checks
Save the accepted prompt, the test inputs, the model and settings, and the reason you accepted it. That record is what makes the next failure easier to diagnose. If you want a single place that lays out this six-step loop for improving and testing prompts, use it as a checklistβthen keep or discard the candidate based on your own examples, not on how fluent the new wording sounds.
This article was drafted with AI assistance and checked against the official guide and pricing information cited above.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.