1. Code Debugging Prompt
Use this prompt to identify issues in your code:
"I am facing an issue with the following code in [programming language]. The code is [insert code here]. I am receiving the following error message: [insert error message]. Can you help me identify the problem and suggest a fix?"
2. Function Refactoring
Refactor your complex code with this prompt:
"I have a function that performs [describe the function]. It’s getting too complex and difficult to maintain. Can you refactor it to improve readability and performance?"
3. Code Optimization
Optimize your function with the following prompt:
"Here's a function that performs [insert task]. Can you help me optimize it for performance or memory usage?"
4. Explain Code Logic
Get a detailed explanation of your code:
"Can you explain the logic behind the following code? [insert code here]. I want to better understand how it works."
5. Unit Testing Assistance
Ask for unit testing help for your function:
"Here’s the code for my function [insert code]. Can you help me write unit tests for this function to ensure it works correctly?"
6. Refactoring for Maintainability
Improve code maintainability with this prompt:
"Can you help me make this code more maintainable? Here is the code: [insert code]. Specifically, I want to improve its modularity and reduce duplication."
7. Code Comments and Documentation
Request for comments and documentation for your code:
"I want to add comments and documentation to this code [insert code]. Can you help me write clear comments and document the purpose of each function and variable?"
8. Code Explanation for a Beginner
Get a beginner-friendly explanation for your code:
"I’m a beginner in [programming language]. Can you explain the following code in simple terms: [insert code]?"
9. Algorithm Suggestions
Get help in finding an efficient algorithm:
"I need an efficient algorithm for [describe problem]. Can you suggest an approach or help me improve my existing algorithm?"
10. Generate Code Snippets
Request a code snippet for a specific task:
"I need a Python function that does [insert task]. Can you generate a code snippet that performs this function efficiently?"