Working with ChatGPT
ChatGPT is versatile for reasoning about code, generating documentation, and brainstorming. It excels at producing structured text outputs, explanations, and design drafts that you can refine.
Responsible usage
- Avoid exposing sensitive data: Redact or abstract confidential code.
- Test all suggestions: Treat outputs as unverified drafts.
- Use in combination with tooling: Pair responses with linters, profilers, and CI tests.
How to ask good questions
- Be specific: Provide context (language, framework, constraints).
- Break problems into smaller steps.
- Show your work (e.g., “Here’s my code + error message” rather than “It doesn’t work”).
đź’ˇ Example:
I’m working in Python 3.11 with FastAPI. This async function throws "RuntimeError: event loop is closed."
Here’s the code: <snippet>. Can you suggest fixes and explain why it fails?
Prompt strategies
Targeted improvements
Act as a senior reviewer. Here is a function. Suggest minimal changes to improve readability and add type hints.
Explaining codebases
Summarize this module in 6 bullet points. Identify assumptions, complexity hotspots, and missing test cases.
Review support
Design assistance
Draft a one-page design doc for <feature>. Include context, goals, trade-offs, and a basic test strategy.
Best practices for developers
- Use ChatGPT to learn patterns (why something works) rather than just solutions.
- Pair it with your IDE’s IntelliSense, type checker, and debugger.
- Always keep a “scratchpad” or test repo for experimenting with generated code.
When to limit usage
- Critical algorithms: AI cannot replace formal verification or proofs.
- Compliance-heavy environments: Code provenance must be clear.
- Opaque suggestions: If you cannot reason about the output, avoid adopting it.
📚 Additional Resources
-
OpenAI ChatGPT Help Center
https://help.openai.com/en/articles/6825453-chatgpt-release-notes -
Prompt Engineering Guide (OpenAI)
https://platform.openai.com/docs/guides/prompt-engineering -
Awesome ChatGPT Prompts (GitHub)
https://github.com/f/awesome-chatgpt-prompts -
Responsible Use of AI
https://openai.com/safety