Good AI coding assistant prompts do more than ask for code. They define the task, provide the relevant repository context, state constraints, and make verification part of the response. This practical checklist gives developers reusable prompts for debugging, explaining unfamiliar code, writing tests, refactoring, code review, and documentation—along with a repeatable way to adapt them as projects, models, and development tools change.
Overview
AI coding assistants are most useful when they support a clearly bounded engineering task. A vague request such as “fix this function” leaves important questions unanswered: What behaviour is expected? Which language version and framework are in use? What must not change? How should the result be tested?
A reliable prompt makes those details explicit. Before sending a request, assemble five kinds of context:
- Goal: describe the outcome in one sentence.
- Evidence: include the relevant code, error message, test output, or diff.
- Constraints: specify language versions, interfaces, dependencies, style rules, performance needs, and files that must remain unchanged.
- Output format: say whether you want an explanation, patch, complete function, test cases, or review findings.
- Verification: ask for tests, assumptions, edge cases, or commands you can run to check the result.
Keep context relevant rather than pasting an entire repository by default. Too much unrelated material can make it harder for a model to identify the authoritative code path. If the assistant supports repository indexing or retrieval, still identify the files and symbols that matter and confirm that the retrieved context is current.
For repeatable work, treat prompts as small engineering assets. Store useful versions with your project documentation, record the model or tool context when results matter, and compare outputs against tests rather than judging code by appearance alone. For more dependable machine-readable responses, see structured output prompting and JSON Schema examples.
Checklist by scenario
1. Debugging an error
Debugging prompts work best when they separate observed facts from assumptions. Include the smallest reproducible example, the exact error, the expected result, and what you already tried.
Act as a debugging partner for this [language and framework] issue.
Expected behaviour:
[Describe the result that should occur.]
Observed behaviour:
[Describe what happens instead.]
Error output:
[Paste the complete relevant error and stack trace.]
Relevant code:
[Paste the smallest reproducible section.]
Environment:
[Language version, framework version, runtime, operating system if relevant.]
Please:
1. Identify the most likely root cause and distinguish it from secondary symptoms.
2. Explain your reasoning using the supplied evidence.
3. Propose the smallest safe fix.
4. Provide a patch or replacement code.
5. Suggest tests that reproduce the failure and verify the fix.
6. State any assumptions and any information still needed.Do not ask the assistant to silently rewrite unrelated code while debugging. A minimal fix is easier to review and less likely to conceal the original fault.
2. Explaining unfamiliar code
Use explanation prompts to build understanding before requesting changes. Ask for control flow, inputs, outputs, side effects, dependencies, and risk areas.
Explain this [file, class, or function] for a developer joining the project.
Context:
- Project purpose: [brief description]
- Called by: [caller or entry point, if known]
- Language and framework: [details]
Code:
[Paste code or identify the repository path and symbol.]
Cover:
1. The responsibility of each major section.
2. Inputs, outputs, state changes, and external effects.
3. Important assumptions and error paths.
4. Dependencies on other modules or configuration.
5. Potential maintainability or correctness risks.
6. Three focused questions I should answer by reading the repository.
Do not infer behaviour that is not supported by the code; label uncertainty clearly.3. Generating tests
Ask for tests based on a stated contract, not merely the implementation. Include normal cases, boundaries, invalid inputs, failure handling, and integration assumptions. This is especially useful when creating unit, integration, and edge-case coverage; the AI test case prompt templates guide provides a dedicated checklist.
Generate tests for the following [function, endpoint, or component].
Contract:
[Describe valid inputs, expected outputs, side effects, and error behaviour.]
Implementation:
[Paste code or identify the relevant symbol.]
Test stack and conventions:
[Test framework, language version, naming style, fixtures, and mocking rules.]
Requirements:
- Cover the normal path, boundary values, invalid inputs, and dependency failures.
- Prefer observable behaviour over implementation details.
- Reuse existing project fixtures and helpers where appropriate.
- Do not invent APIs or dependencies.
- For each test, state the behaviour it protects.
- Flag cases that require an integration or end-to-end test rather than a unit test.
Return the test code followed by a short coverage table and any assumptions.4. Refactoring safely
Refactoring prompts should protect behaviour and define the permitted scope. Ask for a plan before asking for a large patch.
Review this code for a behaviour-preserving refactor.
Objective:
[For example: reduce duplication, improve naming, isolate a dependency, or simplify control flow.]
Must preserve:
- Public APIs and data formats
- Existing error semantics
- Performance requirement: [if known]
- Supported language and framework versions
Code and related tests:
[Paste or identify files and symbols.]
First provide:
1. A short refactoring plan.
2. Risks and areas that need tests.
3. A list of files and interfaces that would change.
Then provide a minimal patch. Do not combine the refactor with feature changes, broad formatting, dependency upgrades, or speculative improvements.5. Reviewing a pull request
For code review, give the assistant the diff, surrounding code where necessary, acceptance criteria, and review priorities. Request findings with evidence and severity rather than a general opinion.
Review the following pull request as a cautious maintainer.
Change objective:
[Link or describe the intended behaviour.]
Acceptance criteria:
[List required outcomes.]
Repository constraints:
[Security, compatibility, performance, style, or migration requirements.]
Diff:
[Paste the diff.]
Relevant surrounding code and tests:
[Paste only what is needed.]
Look for:
- Functional defects and unhandled edge cases
- Regressions in existing behaviour
- Security and privacy risks
- Concurrency, resource, and performance problems
- Inadequate tests or misleading documentation
- Compatibility and migration concerns
Return findings only when supported by the diff or supplied context. For each finding, include severity, file or code location, reasoning, and a concrete remediation. End with questions and items that cannot be verified from the provided material.6. Generating documentation
Documentation prompts should distinguish confirmed behaviour from suggestions. Ask for examples that match the actual interface and request a list of missing information.
Write developer documentation for [module, API, command, or workflow].
Audience:
[Who will use it and what they already know.]
Source of truth:
[Code paths, configuration, tests, or existing specification.]
Include:
- Purpose and when to use it
- Inputs, outputs, prerequisites, and failure modes
- A minimal working example
- Configuration and compatibility notes
- Troubleshooting guidance
- Security or operational considerations supported by the source
Use only behaviour confirmed by the supplied material. Mark unknowns as questions rather than inventing details. Finish with a maintenance checklist showing which code or tests should be reviewed when this documentation changes.What to double-check
Before accepting an AI-generated change, run a review loop rather than copying the first plausible answer.
- Context: Are the relevant files, interfaces, tests, and versions included? Is any pasted code stale?
- Scope: Did the assistant change only what the task required? Inspect the complete diff, not just the displayed snippet.
- Correctness: Do tests cover the stated contract, including failure and boundary cases?
- Compatibility: Does the code use APIs, syntax, and configuration supported by the project?
- Security: Check authentication, authorisation, input validation, secrets, logging, deserialisation, and dependency usage manually.
- Operations: Consider error handling, retries, timeouts, resource cleanup, observability, and rollback.
- Evidence: Separate what the model verified from what it merely suggested. Run the relevant formatter, linter, type checker, tests, and build.
For generated pull-request analysis, compare the assistant's findings with human review and project-specific checks. A prompt can improve consistency, but it does not replace ownership of the change. For a broader validation process, use the LLM output validation checklist.
Common mistakes
- Using a one-line request for a multi-step task: Split discovery, planning, implementation, and verification when the change is complex.
- Leaving the expected behaviour implicit: A model can produce internally consistent code that solves the wrong problem.
- Requesting a rewrite before understanding the defect: Start with an explanation or diagnosis when the root cause is uncertain.
- Mixing refactoring and feature work: Separate changes make regressions easier to locate and review.
- Trusting invented repository details: Ask the assistant to identify assumptions and verify names, APIs, and paths against the source.
- Overloading the prompt with irrelevant files: Provide focused context and point to authoritative sources.
- Skipping tests because the patch looks simple: Small changes can affect contracts, edge cases, and integration boundaries.
- Failing to preserve useful prompts: If a prompt repeatedly produces a good result, version it with its assumptions and example inputs.
When to revisit
Revisit these AI prompts whenever the inputs or acceptance criteria change. A useful maintenance schedule is to review them before major planning or release cycles, when the team changes its branching or review process, and when language, framework, dependency, IDE, or coding-assistant versions change.
Also update the prompt library after a recurring failure: a missed edge case, an inaccurate review finding, an unsafe suggestion, or a test that did not protect the intended behaviour. Add the lesson as a concrete constraint or verification step rather than simply making the prompt longer.
When switching models or development tools, run the same representative tasks against the old and new workflow. Compare correctness, scope control, formatting, latency, and the amount of human correction required. The LLM model migration checklist can help structure that comparison, while the LLM evaluation guide offers a repeatable way to test prompt changes.
Before your next AI-assisted task, copy the scenario template that matches the work, replace every bracketed field, add the smallest authoritative context, and define how the result will be verified. That simple checklist turns ad hoc AI coding into a more traceable part of the development process.