AI Best Practices for Development
Many developers use AI tools in their work. AI can help developers solve problems faster, better understand business processes in a project, and spend less time writing code. Let’s take a look at what can make developer-AI collaboration more effective. Formulate your request to AI as if you are writing a technical task, to enhance […]
Technologies
Many developers use AI tools in their work. AI can help developers solve problems faster, better understand business processes in a project, and spend less time writing code. Let’s take a look at what can make developer-AI collaboration more effective.
Formulate your request to AI as if you are writing a technical task, to enhance collaboration.
AI tools are more effective when they understand the task’s context and task’s goals.
Bad example: “Write me code for user search.”
Good example: “Create new method in UserService that will find users by birthday date.”
Useful phrases: “Create implementation for method that will find user by name”, “Create new class that will extend User.java …”.
Also, give AI more details about technologies, databases, and tools that you use on the project. For example, you have a project with OracleSql, Spring Boot, Mockito, Hibernate, or Maven.
If you can, provide short examples of input and output data.
Provide some project context to the AI assistant, before giving instructions.
AI assistants in IDE could understand the current file, imports, classes and unit tests. It is better to add all necessary files manually.
Example: “Add method to UserService class that will create a new user with role and an email validation.”
Try asking for a step-by-step plan instead of immediately asking for a solution to the task.
AI tools are more effective at creating a plan of action before generating code. You can manage AI like tech-lead: get a plan, specify details, after it request code solution.

Example:
- “Create a step-by-step plan how to add new field email to User and update all related services.”
- “Ok, execute points 1-3”.
This approach enhances precision and control over the final output by allowing for iterative refinement. And many chat assistants better adapt the solution to the problem after several refinements.
If the solution plan is lengthy, consider documenting it into .md file, for example plan.md. After, request AI assistant execute point number x from file plan.md. Your chat history will be more readable in consequence of it.
Try using prompt patterns when making requests.
Prompt patterns are typical ways for AI tools to achieve quality and stable results. These patterns help AI assistants better understand tasks from the first request without additional specification and increase the quality of code, solution, and the code style of the project.
Example:
Refactoring: “Refactor the authenticateUser method to Java 17.”
Explanation: “Explain how the UserAuthentication class works and what each method is doing.”
Testing: “Generate unit tests using Mockito for the new sendSmsVerification method.”
Documentation: “Write Javadoc for all methods from the UserAuthenticationService class.”
Optimization: “Analyze the UserAuthenticationService class and provide for improving the authenticateUser method.”
Code review: “Review the UserAuthenticationService class, identify code style errors and propose fixes.”
Build your communication with AI like mini-iterations.
AI tools can work better with iteration:
- Get first variant of solution.
- Clarify improvements, add details.
- Do one more interaction if solution is not satisfactory.
It’s similar to working with junior developers: you have to manage many details manually.
Try using the pattern: “You are my pair programmer” to enhance collaboration.
AI models work better with the concrete role. For example: “You are my pair programmer”. I’ll be describing my new idea how to improve my project, and you will help me analyze how to apply it to the project”. This pattern improves the quality of argumentation and gives the model a ton of cooperation.
Ask AI assistant to generate tests not only code.
GitHub Copilot, Claude and Cody can generate unit tests. For example: “Write Mockito unit test for a new method findUsersByName in UserService. Focus on error handling.” Unit tests are a good way to review logic generated by AI.
Combine AI with lint tool and static analysis.

AI often fails to follow lint rules or code style which usually depend on the project. After code solving your task, execute check style command. Also AI tools are good in explanation, illustrative case: “Explain how to fix this ESLint error: ‘ServicesFactory’ is assigned a value but never used”.
By implementing these strategies, developers can enhance their collaboration with AI tools, leading to more efficient workflows and higher quality code. I hope this information will be useful to you, help you understand AI faster, and make your future work with AI a pleasure.
At Swan Software Solutions, our team is always excited to improve their skills and explore the possibilities in the latest technologies. To discover more about how our team could help your company with its technology needs, schedule a free assessment.