How I use ChatGPT as a Software Developer
Maximizing Productivity w/ChatGPT: A Guide to Using AI for Code Generation, Documentation, and More
This is my very first newsletter post, and I must admit, it's pretty daunting! The thought of sending my thoughts and insights directly into your inbox feels both exciting and nerve-wracking. Thank you for subscribing. 🙌
I went back and forth on many topics. I have several half-baked drafts that will most probably never make it to a live URL. Only after having all my Twitter feed covered in ChatGPT, the advanced language model developed by OpenAI, it was obvious to me that it's the topic on a golden plate. Especially as I've been using ChatGPT in my daily life, trying to convince my family and friends to use it, having conversations with developers on how they're using AI tools and following the recent announcements with ChatGPT plugins, GitHub Copilot X. So, I decided to put together a post on how it's been helping my life.
My Journey with ChatGPT
For the past months, I've been using ChatGPT for various tasks, such as generating code, writing documentation, summarizing text, and answering technical questions. It helps me work better and produce higher-quality work. While I acknowledge some limitations - for example, with new tools and products, it sometimes gives me the wrong answers - there are many use cases, including many for programming, where it's a great fit.
The Art of Prompt Engineering
I think the key to using ChatGPT is to ask the right questions or, in other words, the correct prompts. In fact, finding good use cases and their relevant prompts can even help you land a job(!) This emerging trend has led to the rise of "prompt engineers" - How do I explain this to my grandma?
It's already becoming a thing and can open many opportunities.
The thing is - learn how to write good prompts. This means clear, specific and detailed instructions. Make sure to provide enough context; the more, the better.
Here’s a slightly modified response to ChatGPT’s response to a good and bad prompt:
🚫 Bad: Teach me how to code.
✅ Good: How do I create a responsive navigation bar using HTML and CSS?
Ok so, let's get to some use cases and the prompts themselves.
How I use ChatGPT & the Prompts
⚠️ Please note: I'd highly suggest double-checking the responses and using chatGPT as a helper instead of taking everything for given. Additionally, you can always ask follow-up questions if you're not satisfied with the answer.
Generate boiler template code: I give it clear instructions, and it gives me the code I need. (the more instructions, the better)
“Can you create a xx using xx, xx and xx?” E.g.: Can you create an ERC20 smart contract in solidity where the token name is EDA, the symbol is E, and the total supply is 20. It should extend from openzepplin smart contracts.
Here’s a cool post by Rakshitlodha on using ChatGPT to build a Twitter Bot without knowing any programming language.
Check out this tweet by Jake Browatzke on building a Google Chrome extension with no-programming experience in a few hours!
Add comments to the code: I use ChatGPT to add comments. I can specify a specific comment format too.
“Can you add comments to the following code in xx format” E.g.: Can you add comments to the following code in Natspec format?
Explaining the code/function
“Can you explain this code/function: xx”
Answering Technical Questions: Super helpful for research. I can ask it to compare different frameworks or give me a quick answer to a technical question. However, it's important to remember that there are limitations to ChatGPT, and it may not always provide the correct answers. Proceed with caution.
"Should I use xx or xx for a platform that xx?" E.g.: Why does this function include “payable”? Should I use Nextra docs or Docusaururus for a platform that has Ethereum content for developers to get started building? (shocked by how good the answer was)
“Can you explain the steps to xx using xx?” E.g.: Can you explain how to create an ERC20 smart contract in Solidity using Foundry and OpenZeppelin smart contracts; and then I also want to deploy it to Optimism Testnet.
I also simply copy-paste my README and ask chatGPT to give me some tips to improve it.
Finding security vulnerabilities: Although other tools are available specifically for this purpose, I've discovered that ChatGPT can be helpful for a quick run-through of my code to identify any potential security vulnerabilities.
“Can you help me review the code and identify any security vulnerabilities”
Finding Errors: copy-paste your error and see if ChatGPT knows what’s going wrong.
“Why am I getting the error xx? Here is my code: xx” E.g.: Here’s the error with increment counter func: xx, how can I fix it?
Writing test cases
“Write the unit tests for the following code xx”
Summarizing: Give it an article or paragraph and ask it to summarize. For example, you can specify the simplicity of a seven-year-old.
“Can you summarize this in bullet points for a 7 yo to understand”
🙌 I hope these prompts will be helpful for you in using ChatGPT. I want to highlight once again that ChatGPT has its limitations and may not always provide accurate or complete responses.
GitHub Copilot X
Most of the features I use for programming will be available with GitHub Copilot X. GitHub Copilot X is a new tool that is based on the same technology as ChatGPT; it’s designed to provide developers with an AI assistant, which can help generate code and provide suggestions in real-time.
Here's a well-detailed thread by Jim Fan on what to expect with GitHub Copilot-X.
Lastly, I need to mention ChatGPT Plugins before ending this post. These are tools or add-ons that can be used with ChatGPT; developers will soon be able to build their own plugins as well.
For example, the Expedia plugin is an example of how ChatGPT plugins can automate travel tasks. Users could use this plugin to plan their travels. By typing prompts like 'book a flight to Tokyo on the 10th of April, ' the plugin would use ChatGPT to generate a list of flight and hotel options, with the prices and reviews.
Something else to keep an eye out for. 👀
Building in Public
I want to take a moment to mention that I'm a fan of OpenAI for building in public. They release their work, allow people to test it, and collect feedback on a much larger scale. Of course, publishing an imperfect and biased model has a tradeoff, but they learn from their mistakes and improve it. Many critics of ChatGPT3 are surprised to see how ChatGPT4 has improved (it should still be used carefully).
This fits in with my trial-error way of doing things, and it's very impressive to see such large companies, in the eyes of the public, follow such an ethos.
I truly enjoy coding and learning by trial and error. ChatGPT isn't taking over my job (at least for now); it's making some of my tasks easier while I continue to learn. I'm excited to see where it goes and how we can use ChatGPT, as well as other AI tools. Trust me - you don’t want to miss out.
I hope these examples will help you in the world of AI tools as a developer. Thanks for reading! If I'm missing any cool prompts, or if you have any feedback/comments, please feel free to reach out to me. 👋
Thanks for reading Eda's Substack! Subscribe for free to receive new posts & support my work.