Start your code prompt with one clear task
A coding assistant cannot see the project you have in your head. If you ask it to “build a login system,” it must guess the framework, storage method, security requirements, and expected behavior. Those guesses can produce code that looks convincing but does not belong in your application.
A better prompt works like a small task brief. Explain what should change, provide the relevant context, and describe how you will check the result. You do not need special terminology. You need enough detail to make the task understandable.
Start with one useful outcome: “Add email validation to the registration form.” Keep unrelated work, such as redesigning the page or changing the database, out of that first request.
Give the assistant the project facts it needs
Before requesting code, name your language, framework, and relevant versions. Include the existing function or component when possible. If the assistant can inspect your repository, point it toward the files that matter instead of assuming it will find them.
- Environment: State the language, runtime, framework, and test runner.
- Existing code: Share the relevant function, its callers, and any types it depends on.
- Boundaries: Identify files or public interfaces that must stay unchanged.
- Dependencies: Say whether adding packages is allowed.
Only include information that helps solve the task. Remove passwords, access tokens, customer records, and other sensitive data. Replace them with clearly labeled sample values.
Replace vague requests with observable behavior
Words such as “clean,” “robust,” and “production-ready” leave room for interpretation. Describe what the code should actually do instead.
For example, replace “Make this search better” with: “Update the product search function to ignore leading and trailing spaces, match names without case sensitivity, and return an empty list when the query is blank. Keep the current return type.”
Examples make your intent easier to check. If a query containing “ apple ” should match “Apple Juice,” say so. Also describe an unsuccessful case, such as a query with no matching products. These details become useful test cases later.
Use this task brief for your next coding request
You can reuse the following structure without treating it as a magic formula. Replace each detail with facts from your project.
Goal: Update the existing product search function to normalize search queries.
Context: This project uses TypeScript with strict checking and Vitest. I will provide the current function and its tests below.
Required behavior: Trim surrounding whitespace and match product names without case sensitivity. Return an empty list for blank queries. Preserve the input array and keep the existing return type.
Constraints: Do not add dependencies, rename exports, or change unrelated files.
Deliverable: Show the proposed patch and tests for whitespace, mixed case, blank input, and no matches. Explain any assumptions. If a requirement is unclear, ask before changing the code.
Check the patch before expanding the task
Generated code is a proposal, not proof that the problem is solved. Read the changes, run your tests, and use your normal type checks or lint checks. Check that the tests verify your requirements rather than simply repeating the implementation’s assumptions.
If something fails, provide the exact error, the command you ran, and the relevant output. “The test expected an empty list but received all products” gives the assistant more to work with than “It is broken.” Request a focused correction instead of restarting with a larger prompt.
Keep the same prompt when trying another model
Once your task brief is clear, you can reuse it across coding tools. SwiftRelay is a practical option for accessing different models through tools such as Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs, with pay-as-you-go token billing. Sign up for SwiftRelay to try your first task brief with a small gift credit.
Keep your requirements and checks consistent when reviewing another model’s output. The goal is not the most impressive explanation; it is a small, understandable change that passes the checks you specified.