CMD Master
Back to Blog
Arnošt Havelka

How to Write Better AI Prompts: The Missing Context That Makes AI Suggestions Actually Useful

Write better AI prompts with the context that changes decisions: scope, assumptions, outcomes, constraints, and evidence.

How to Write Better AI Prompts: The Missing Context That Makes AI Suggestions Actually Useful

Better AI prompts are not necessarily longer. They contain the context an assistant needs to make the right decision instead of merely producing a plausible change. For engineering work, that usually means naming the scope, the assumption, the desired outcome, the constraints, and the reason the change matters.

That is the difference between a response that compiles and a change that helps the product.

Why otherwise capable AI suggestions fail

An assistant can write valid code from a short instruction, but a short instruction often hides the product decision. “Remove the sidebar on mobile” tells the assistant what to change. It does not tell it whether desktop behavior must stay intact, why the current behavior hurts people, or how to judge success.

When that context is missing, the assistant has to guess. It may make a technically tidy change that removes a useful desktop workflow, changes an unrelated layout, or solves a symptom rather than the problem.

Use a prompt as a compact engineering brief, not as a command.

Include the context that changes the decision

Start with these six pieces of information:

  1. Scope: Which screen, files, flow, or behavior are in scope?
  2. Problem: What is difficult, broken, slow, or confusing for a person using the product?
  3. Assumption: What do you think is causing the problem?
  4. Desired outcome: What should be true when the work is done?
  5. Constraints: What must remain unchanged, and what approaches are off limits?
  6. Evidence request: Ask the assistant to challenge the assumption and explain what it would verify first.

You do not need every item for a one-line question. You do need them when the assistant could make a product or architecture decision on your behalf.

Example: preserve desktop behavior while fixing mobile navigation

Here is a weak prompt:

Make mobile navigation more consistent and remove the sidebar.

It gives an action but no decision boundary. The assistant could remove the sidebar everywhere because it does not know that desktop users depend on it.

Here is a better prompt:

Problem: The desktop sidebar is difficult to use on mobile because it takes
too much horizontal space and competes with lesson content.

Assumption: A mobile-specific navigation pattern would make lesson switching
easier without changing the desktop workflow.

Outcome: On small screens, learners can switch lessons and return to the
current exercise without losing context. Desktop users keep the existing
sidebar and keyboard workflow.

Constraints: Do not remove the desktop sidebar. Preserve existing route
behavior, accessibility labels, and progress state. Avoid adding a second
source of truth for the selected lesson.

Before implementing, inspect the current navigation ownership and challenge
the assumption if a smaller layout change would solve the problem.

The better prompt gives the assistant room to investigate, but it makes the important boundaries explicit: mobile is the scope, desktop behavior is protected, and a single state owner is non-negotiable.

Example: move a topic switcher for a reason

A placement request can have the same problem:

Move the topic button to the sidebar and make it fit.

That instruction treats the existing layout as decoration. It does not explain why topic switching belongs somewhere else or how users should find it after the move.

Try this instead:

Problem: The topic switcher in the navbar competes with global navigation,
but people use it while comparing lessons within the current course.

Desired outcome: Place topic switching beside the course navigation so its
purpose is clear and it remains easy to reach while browsing a lesson.

Constraints: Keep global navbar actions unchanged, preserve the selected topic
across navigation, and do not make the sidebar the only way to switch topics
on narrow screens.

First inspect the current route and state model. Explain whether the sidebar
is the right destination before changing the layout.

The central change is not “more detail.” It is a better definition of success.

Ask the assistant to challenge the plan

AI is most useful when it can point out a bad premise before it writes a patch. Add one direct question:

What evidence would disprove this assumption, and what smaller change should
we consider first?

For a bug, ask for reproduction steps and competing hypotheses. For a refactor, ask which behavior could regress. For an architecture change, ask which existing owner, boundary, or contract would be duplicated.

That shifts the work from “produce code now” to “make a defensible decision, then implement.”

A reusable prompt template

Use this template when a task needs product and technical context:

Task: [Describe the change in one sentence.]

Problem: [Who is affected and what is going wrong?]
Scope: [Files, screens, workflow, or subsystem in scope.]
Assumption: [What you believe is causing the issue or what solution may help.]
Desired outcome: [Observable result for the user and the system.]
Constraints: [Behavior to preserve, compatibility, performance, accessibility,
security, rollout, and non-goals.]
Relevant context: [Architecture, data flow, recent changes, logs, or examples.]
Acceptance criteria: [How we know the work is complete.]
Validation: [Tests, manual checks, or measurements to run.]

Before changing code, inspect the relevant area. Challenge the assumption if
the evidence suggests a safer or smaller solution.

The template also makes review easier: a teammate can see the intended result and decide whether the proposed implementation satisfies it.

Give context, not a repository dump

Relevant context is selective. Include a failing test, an error message, the current component boundary, a request payload, or a short user journey. Do not paste thousands of unrelated lines and hope the assistant finds the important part.

For a focused coding workflow, see how to prompt ChatGPT for coding. For reusable patterns across implementation, debugging, and review work, read prompt engineering for developers.

Choose the next guide for your task

Use a tool-specific guide when repository context changes the prompt: Cursor AI prompting, GitHub Copilot prompting best practices, or getting better results from Claude Code.

Use a task-specific guide when you need ready-to-adapt wording: prompt engineering examples for software engineers, prompt templates for refactoring code, or prompt templates for debugging production issues.

Use a decision guide when the risk is process rather than syntax: AI coding assistant mistakes and how to avoid them and how senior developers use AI differently.

Turn prompt quality into engineering practice

The same habits that make AI prompts useful make tickets, pull requests, and incident notes clearer: explain the problem, define the outcome, preserve important behavior, and validate the result.

When a task involves a shell command or terminal output, make the behavior concrete before asking an assistant to change it. Practice command-line workflows in the browser so you can recognize the input, output, and failure mode you want the implementation to handle.

References

These documentation links provide authoritative details for the commands used in this article.