Ai Coding Tools

How to Use GitHub Copilot to Write Your First 5 Scripts

By BTW Team4 min read

How to Use GitHub Copilot to Write Your First 5 Scripts

If you're a beginner diving into coding, the prospect of writing your first scripts can feel daunting. But what if I told you that there’s a tool that can help you write code faster and more efficiently? Enter GitHub Copilot. This AI-powered coding assistant can help you generate code snippets, suggest functions, and even debug your scripts. In this guide, I’m going to walk you through how to use GitHub Copilot to write your first five scripts, so you can get started on your coding journey in 2026.

Time Estimate and Prerequisites

You can finish this entire process in about 2-3 hours, depending on your familiarity with coding concepts. Before you start, make sure you have:

  • A GitHub account (Free tier available)
  • Visual Studio Code installed (Free)
  • GitHub Copilot subscription (Pricing: $10/month for individuals, $19/month for businesses)

Step-by-Step Guide to Writing Your First 5 Scripts

1. Setting Up GitHub Copilot

To use GitHub Copilot, you first need to install the extension in Visual Studio Code:

  1. Open Visual Studio Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side.
  3. Search for “GitHub Copilot” and click "Install."
  4. Sign in to your GitHub account and authorize Copilot.

2. Writing Your First Script: Hello World

Let’s start simple. Open a new file and type the following comment:

// Create a simple Hello World script in JavaScript

Now, hit the “Tab” key or “Enter” after the comment. GitHub Copilot will suggest a “Hello World” script. Accept the suggestion, and you’ll have your first script ready!

3. Writing a Basic Calculator

Next, let’s create a basic calculator that adds two numbers. Type this comment:

// Create a simple calculator function that adds two numbers

Again, hit “Tab” or “Enter” to see Copilot’s suggestion. You should have a function that looks something like this:

function add(a, b) {
    return a + b;
}

4. Writing a Script to Fetch Data from an API

Now, let’s make a script that fetches data from a public API. Type:

// Fetch data from a public API and log the response

After hitting “Tab,” you should see a suggestion that includes a fetch request. It might look like this:

fetch('https://api.example.com/data')
    .then(response => response.json())
    .then(data => console.log(data));

5. Writing a Script to Iterate Over an Array

Next, let’s create a script that iterates over an array and logs each item. Type:

// Iterate over an array and log each item

Copilot should suggest a loop that looks like this:

const items = ['item1', 'item2', 'item3'];
items.forEach(item => {
    console.log(item);
});

6. Writing a Script to Handle Errors

Finally, let’s write a script that handles errors when fetching data from an API. Type:

// Fetch data from an API with error handling

Copilot will suggest a structure that includes error handling, similar to:

fetch('https://api.example.com/data')
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }
        return response.json();
    })
    .then(data => console.log(data))
    .catch(error => console.error('Fetch error:', error));

Troubleshooting Common Issues

  • Copilot Isn't Suggesting Code: Ensure that you're connected to the internet and logged into GitHub. Sometimes, restarting Visual Studio Code can help too.
  • Suggestions Aren't Relevant: If you find that Copilot is consistently missing the mark, try rephrasing your comments or providing more context.

What's Next?

Now that you’ve created your first five scripts, consider exploring more complex projects. You can start building small applications or even contribute to open-source projects on GitHub.

Conclusion

GitHub Copilot can be a game-changer for beginners looking to write scripts quickly and efficiently. By following this guide, you should have a solid foundation for writing your own scripts. If you're just starting, I recommend experimenting with these scripts and gradually increasing their complexity.

Start here: Get your GitHub account set up and install Visual Studio Code. Then, dive in and start creating!

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time As a developer, whether you're just starting out or have years of experience, debugging can feel like a neverend

Oct 16, 20265 min read
Ai Coding Tools

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow As developers, we’re always on the lookout for ways to streamline our workflow and boost productivity. Enter

Oct 14, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools That Could Hurt Your Development Process

5 Myths About AI Coding Tools That Could Hurt Your Development Process As a solo founder or indie hacker, you might be lured by the promises of AI coding tools that claim to simpli

Oct 13, 20264 min read
Ai Coding Tools

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026 As AI coding tools have become an integral part of a developer's toolkit in 2026, many are still stumbling over

Oct 12, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026 As we dive into 2026, the landscape of AI coding tools has evolved significantly, yet many developers still

Oct 11, 20263 min read
Ai Coding Tools

Why AI Coding Assistants Are Overrated for Beginners in 2026

Why AI Coding Assistants Are Overrated for Beginners in 2026 As a solo founder or indie hacker, it’s tempting to think that AI coding assistants are the silver bullet to jumpstart

Oct 10, 20263 min read