How To Use ChatGPT To 10x Your Coding

Alex Hyett
Alex Hyett
hero image

Yes, it’s true. ChatGPT really can write code, fix bugs, and help explain things you don’t understand.

The real question of course, is how do you actually use it to help with your projects without getting random, broken, or unusable results?

  • Is it just about asking the right question, or is there more to it?
  • And if this tool is really that powerful, do you still need to learn how to code at all?

In this guide, I’ll break all of that down. What ChatGPT is great at and where it fails, how developers go wrong when using it for code, and how to get real value with the right mindset and better prompting.

Speaking of which…

Sidenote: If you want to dive deep into Prompt Engineering, then check out ZTMs Prompt Engineering Bootcamp:

learn prompt engineering

This is the most comprehensive, up-to-date, and best prompt engineering bootcamp course online, and includes everything you need to learn the skills needed to be in the top 10% of those using AI in the real world.

Learn how Large Language Models (LLMs) actually work and how to use them effectively!

With that out of the way, let’s get into this guide.

Can ChatGPT write code for you?

Yes and no.

So here’s the thing - ChatGPT is incredibly useful, but it’s only as good as the person using it. The quality of your inputs (prompts) is key to getting the output you want.

However, because the interface seems so smart, people will often take the information it gives as being true without understanding what it's actually doing.

For example

You see this all the time with people trying to build tools without any real dev knowledge and then can’t figure out why their database gets hacked. The UI looks ok, but the backend is hammered together with no thought for best practices, and it’s kind of crazy.

The thing is, you could actually build apps with these tools to some extent, just as long as you know how to code already.

The trick is to add expertise + AI assistance

That’s the key difference that a lot of devs miss, in that ChatGPT can help write code, but you’ll get far better results if you pair it with topical knowledge and experience.

Why?

Because it’s a tool. And like all tools, the better you understand what you’re trying to build and its goals and limitations, the more likely you are to get your desired end result.

For example

Let’s say you want to build a function that filters a list of users by whether they’ve verified their email.

Now, if you understand the logic, you can describe what you need, give ChatGPT an example input, and get a useful result. If your prompt is clear, the code it gives you will probably do the job.

However, if you don’t understand how arrays, conditionals, or booleans work yet, you won’t even know how to describe the task. And worse, you might not recognize when the answer is completely wrong.

Because that’s the real risk:

  • ChatGPT doesn’t run your code
  • It doesn’t know which files are in your project
  • It doesn’t know if you’re using a specific version of a library
  • And it definitely doesn’t know if changing a variable name is going to break everything else in your app

That’s all your job, and you need to know all this so you can steer it to the right answer.

This is why understanding the fundamentals of programming still matters. You need that foundation not just to write code, but to review what ChatGPT gives you and decide whether to keep it, improve it, or toss it out completely.

I know it’s not the one click solution that you might have wanted, and it's definitely more effort than some people might make out. However, if you learn to use it alongside building coding skills, then you’ll be amazed at how much it can improve your workflow.

How ChatGPT can actually help with your coding

We ran a survey a few years back of how devs were using AI tools, and as you could imagine we tracked usage across different skill levels.

Our initial thoughts when putting the questions together, was that the biggest adopters would be beginner devs and that was true. However, what really shocked us was the answers from senior devs and how much it impacted their work.

percentage of devs work that they are speeding up with ai tools

I know we don’t separate the experience range here, but when we looked at the responses, it was all seniors in the top 5 usage.

Even more shocking, they were using AI to help them with anywhere from 50-90% of their daily work! Not because they were cutting corners, but because they had so much experience. They saw how they could take those repetitive or time consuming tasks, and figured out ways to get the AI to help.

What like?

Obviously this isn’t definitive, but here’s a few examples to help you get some ideas for improving your own workflow.

Example #1. Use ChatGPT to explain regular expressions for you

Regular expressions are notoriously difficult to understand yet they are used a lot in programming.

Take this example. Any ideas for what this is used for?

/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i

Let’s ask ChatGPT:

Use chatgpt to learn what code means

The response is mind-blowing 🤯.

the code breakdown

Not only does it now that this is a regular expression for validating email addresses, but it also goes on to tell you what each piece of the expression is doing!

This is just one example but the next time you feel stuck on a topic, ask ChatGPT to explain it to you and provide you examples. You'll be amazed at how convenient and helpful having this private little tutor is.

Example #2. Use ChatGPT to write SQL commands for you

Knowing how to query a database is an essential skill that all developers need to know but sometimes it can be difficult to come up with the right query.

However, if you give ChatGPT enough information about the structure of the database it can write the query for you instead!

Using chatgpt to solve sql coding issues

From the information provided ChatGPT managed to work out the correct foreign keys to match and write the correct query for me.

the code solution but does it work?

💡 Reminder: Remember what I said earlier though about domain level knowledge and giving good prompts.

Here you can see that the type of database above is clearly for MySQL instead of MS SQL. This could be down to my own prompt quality, but without the domain knowledge, I wouldn't have spotted this issue.

Example #3. Use ChatGPT to save yourself from Git headaches

We've all been there. You're asked to make a one line code fix and end up committing it directly to the master branch without creating a feature or hotfix branch.

Gah!

All is not lost though as you haven’t pushed it up to GitHub yet. So how do you roll back this mistake? Sure, you could start panicking and searching Google, but don’t worry, ChatGPT has your back!

GIT commit issue

The response from ChatGPT even made me feel a bit better about my mistake too and gave me advice had I pushed my changes up to the server, with a very important warning as well.

GIT commit solution

And we're just scratching the surface with these examples!

ChatGPT is also capable of giving you book recommendations, generating learning roadmaps, helping you write Linux commands and bash scripts, and can even tell you why your code isn’t working.

But here’s the catch: It only works that well if you know how to ask for what you need.

And that’s the part most people miss. It’s not just about using ChatGPT. It’s about knowing how to guide it. So before you dive in and expect magic, let’s take a minute to walk through how to actually write better prompts.

Because when you get that right, everything else gets easier too.

How to write better prompts

Most people’s first experience using ChatGPT for coding goes something like this. They open it up, type something vague like “fix this function” or “write a Python script,” and then wonder why the answer is generic or flat-out wrong.

It’s kind of like asking a teammate to fix some code, but with no explanation of the issue, no input data, no error message, and no clue what the code is even supposed to do.

They’d look at you like, “Fix what, exactly?

Well ChatGPT is the same. It needs enough information to understand the job.

For example

Let’s say that you want to filter emails in JavaScript

But more specifically, you want a function that filters an array of users to only return those with verified emails.

Here’s a typical beginner prompt:

Write a function to get verified users

Not very detailed right? And so ChatGPT will probably give you something like:

function getVerifiedUsers(users) {
  return users.filter(user => user.verified);
}

Which looks fine, except:

  • What’s the structure of users?
  • Is verified a boolean, a string, or missing sometimes?
  • What if the users array is undefined or empty?

You didn’t tell it any of that, so it just guessed, and probably got it wrong.

So let’s look at some techniques to improve our prompting process, and get the actual result we want.

Method #1. Give your prompt more structure and constraints

When we give the tool more information, it’s more likely to give us the right result.

For example

Write a JavaScript function that takes an array of user objects and returns only the users where isVerified is true. Each user has name, email, and isVerified fields. Include input validation for undefined or empty arrays.

That’s way more specific, so now ChatGPT might give you:

function getVerifiedUsers(users) {
  if (!Array.isArray(users) || users.length === 0) return [];

  return users.filter(user => user.isVerified === true);
}

Much better. It’s the same AI, but a completely different result, just because you gave it more details.

This also brings us back to why topic knowledge matters, because you can only give good prompts if you understand what you're asking for.

If you don’t know how filter() works, or what your data should look like, or whether isVerified is a boolean, you won’t know how to frame your question, or how to tell if the answer is wrong.

Speaking of which, what if the answer is almost correct but not quite what you need? Well that’s where the next method comes in, and it's key to success with prompting.

Method #2. Break the task into smaller steps

We call this technique “tree of thought” prompting.

Basically, instead of trying to get everything in one go, you guide ChatGPT step-by-step, adding detail, correcting issues, and refining the output along the way.

It’s like growing branches on a tree. You start with the trunk (your general task), then build on it by adding smaller branches (clarifications, refinements, improvements) until you get the fruit (the result you actually want).

What’s great about this technique is that can use it for two goals:

  • Either to help you solve larger problems that are too complex to tackle with a single prompt
  • Or you can use it to work toward the kind of structured, detailed prompt a more experienced developer might ask. Just by building it up one step at a time

For example

Imagine if we didn’t know all the specific details earlier in that first method. Perhaps we knew some of it, but we wanted the same end result - we just didn’t know enough to give it everything up front.

Well we could build it up piece by piece, see what works and test and come back again each time to refine it further.

So let’s start with a basic end goal prompt:

Help me design a function to return only users who have verified their email.”

ChatGPT might start with:

function getVerifiedUsers(users) {
  return users.filter(user => user.isVerified);
}

Notice how simple the answer from ChatGPT is, because we haven’t given it anywhere near the same depth of details.

So let's improve it. Maybe we test this and it’s not quite right (or perhaps we know its not right from experience), and so we take that further and continue prompting in the same chat window:

Great. Now add validation to check that users is a non-empty array

function getVerifiedUsers(users) {
  if (!Array.isArray(users) || users.length === 0) return [];

  return users.filter(user => user.isVerified);
}

We can even take it further than the first example by getting even more specific:

Update the function so that it returns a JSON object with a success key and the filtered users list.

function getVerifiedUsers(users) {
  if (!Array.isArray(users) || users.length === 0) {
	return { success: false, users: [] };
  }

  const verifiedUsers = users.filter(user => user.isVerified);
  return { success: true, users: verifiedUsers };
}

And then:

Now add a fallback in case a user doesn’t have the isVerified field at all.”

function getVerifiedUsers(users) {
  if (!Array.isArray(users) || users.length === 0) {
	return { success: false, users: [] };
  }

  const verifiedUsers = users.filter(user => user.isVerified === true);
  return { success: true, users: verifiedUsers };
}

Honestly, this is probably one of the best techniques you can use, but it gets even better if you also use the next method alongside it.

Method #3. Iterate like you would with a human

One of the really cool things about using ChatGPT for coding (or any tasks) is that you can keep refining and asking it as if you’re talking to a person.

You give it feedback and let it know where it failed or what you need to help further refine it. This interface makes it so easy to use - but it also allows for changes you might think you couldn’t do.

For example

Let’s say we’ve already got our function returning verified users, but now you realize that they also need to be active.

The good news is that instead of starting from scratch, you just follow up like you would with a teammate:

This is almost right, but I also need it to check if the user is active before returning them.”

ChatGPT will take the last answer and build on it:

function getVerifiedUsers(users) {
  if (!Array.isArray(users) || users.length === 0) {
	return { success: false, users: [] };
  }

  const verifiedUsers = users.filter(user => user.isVerified === true && user.isActive === true);
  return { success: true, users: verifiedUsers };
}

Simple right?

No need to re-explain everything. No need to re-type your whole prompt. Heck, you can even open up old tabs inside ChatGPT and continue prompts that you had closed days ago!

Give it a try yourself!

Like I said earlier, ChatGPT isn’t a replacement for learning how to code. It’s a tool that helps you go further, faster. Once you know how to prompt it properly, it becomes a powerful assistant that can help you debug problems, explain confusing topics, refactor messy code, or even build out early versions of a new feature.

But you won’t really understand how helpful it is until you use it for something real.

So here’s your next step:

  • Pick a task from your current project. Maybe something repetitive, frustrating, or unfamiliar, and ask ChatGPT for help
  • Take what you’ve learned here and try writing a solid prompt. See what it gives you, refine it if needed, and build from there

That’s when it all starts to click.

P.S.

Remember, if you want to dive into all things Prompt Engineering, then check out ZTMs Prompt Engineering course:

learn prompt engineering

Once you take this, you can stop memorizing random prompts, and instead, learn how Large Language Models (LLMs) actually work and how to use them effectively. This course will take you from being a complete beginner to the forefront of the AI world.

Plus, once you join, you'll have the opportunity to ask questions in our private Discord community from the course creator, other students, and working tech professionals and Prompt Engineers!


Check it out today.

About the author

Alex is a Software Developer and Engineering Manager with over 12 years of professional experience in backend development. Most of his career has been spent creating large-scale solutions for the finance industry from banks to payments startups. Alex has extensive experience with .NET, AWS and Terraform to name a few.

He is now using his experience to teach other developers about complex engineering topics and to help them have successful careers in tech.

Alex goes beyond just writing code and teaches developers the skills they need to break down large problems, communicate effectively with the business and work their way up the career ladder.

He regularly posts software development content on his YouTube channel as well as writes a weekly newsletter called The Curious Engineer to help engineers level-up their careers.

We highly recommend you check out both!

When not working, Alex likes playing guitar, reading, drawing and spending time with his wife and children.

Come say hi and welcome Alex in the ZTM Community!

More from Zero To Mastery

Will AI Replace Programmers? No! But Something Else Will preview
Will AI Replace Programmers? No! But Something Else Will
19 min read

The better question is: "How do I NOT get replaced by AI?". I'll show you what could replace you and how you can thrive as a developer in this new AI era 🤖.

The State Of AI Tools And Coding: 2023 Edition preview
The State Of AI Tools And Coding: 2023 Edition
24 min read

We surveyed 3,240 Developers, Programmers, and Engineers (biggest AI survey to date) to find out what's really going on with AI tools and programming. Here are the stats you need to know.

How to Become an AI Engineer & Get Hired in 2025 preview
How to Become an AI Engineer & Get Hired in 2025
25 min read

Learn everything you need to know to become an AI Engineer, as well as how to get hired as one in 2025 with this step-by-step guide!