Code Generation: Define the programming language, desired functionality, and any specific libraries or frameworks. Provide clear input/output examples. Request specific code snippets or full functions. Specify constraints like performance or security. Review, test, and integrate the generated code.
Debugging: Copy the error message verbatim from your console or log. Paste the problematic code section. Ask ChatGPT to identify the error and suggest solutions. Provide context about the program's intended behavior. Implement the suggested fix and retest your code.
Code Explanation: Paste the code snippet you need to understand. Ask for a line-by-line explanation or a high-level overview. Request clarification on specific functions, variables, or algorithms. Ask for examples of how the code might be used.
Code Refactoring: Identify the section of code needing improvement (e.g., for readability, performance, or maintainability). Paste the code and explain the desired outcome (e.g., 'make this more Pythonic,' 'improve this SQL query performance'). Review the refactored code and apply changes cautiously after thorough testing.
Unit Test Generation: Provide the function or module you want to test. Specify the testing framework (e.g., Jest, Pytest). Ask ChatGPT to generate unit tests covering various scenarios, including edge cases. Review and integrate the generated tests into your test suite.