- Code Generation with Context
Prompt:
âWrite a Python script that reads a CSV file, filters rows where the value in column B is greater than 100, and saves the result to a new file.â
You can modify this with edge cases, comments, or additional features in follow-up prompts.
Â
- Explaining Complex Code Snippets
Perfect for understanding legacy code or onboarding junior devs.
Prompt:
âExplain what this React component does. Use plain English. Assume I have intermediate JavaScript knowledge.â
(Paste your code block below the prompt.)
Â
- Bug Fixing & Error Troubleshooting
Stuck with a stubborn error? Prompt ChatGPT like this:
Prompt:
âIâm getting a âTypeError: Cannot read property X of undefinedâ in this JavaScript function. Can you suggest why and how to fix it?â
ChatGPT will analyze common causes and even suggest logging strategies.
Â
- Refactoring for Best Practices
Need cleaner, more maintainable code?
Prompt:
âRefactor this PHP code to follow PSR-12 coding standards and improve readability.â
You can also ask it to convert between languages (e.g., PHP to Node.js).
Â
- Documentation & Comments
Writing clear documentation is tedious. Prompt GPT to do the heavy lifting.
Prompt:
âAdd inline comments to this Python function and generate a summary docstring.â
This helps in both code reviews and onboarding.
Â
- Learning New Languages or Libraries
Trying out Rust, Go, or Next.js? Let GPT tutor you.
Prompt:
âAct as a tutor. Teach me how to use useEffect in React with examples. Iâm new to React hooks.â
You can also ask for comparisons between two methods or frameworks.