Ai Coding Tools

How to Use GitHub Copilot to Write Your First Five Lines of Code

By BTW Team4 min read

Comparing tools? See the AI tools tested on the show.

In short

A step-by-step tutorial on leveraging GitHub Copilot to effortlessly create your first simple code snippets in less than an hour.

If you're a beginner coder, the thought of writing your first lines of code can be daunting. You might feel overwhelmed by the syntax, the logic, and where to even start. Enter GitHub Copilot, an AI-powered code completion tool that can help you write code faster and with more confidence. In this guide, I'm going to walk you through using GitHub Copilot to write your first five lines of code in 2026.

Time Estimate and Prerequisites

You can finish this in about 30 minutes. Before you start, make sure you have:

  • A GitHub account (free)
  • Visual Studio Code (VS Code) installed on your machine
  • GitHub Copilot extension installed in VS Code (you'll need a subscription)

Step-by-Step Guide to Writing Your First Lines of Code

1. Setting Up GitHub Copilot in VS Code

First, you need to get your environment ready.

  • Install VS Code: If you haven't already, download and install Visual Studio Code from here.
  • Install GitHub Copilot: Go to the Extensions view in VS Code (you can press Ctrl + Shift + X), search for "GitHub Copilot," and click "Install".

2. Creating a New Project

  • Open VS Code.
  • Create a new folder for your project and open it in VS Code.
  • Inside the folder, create a new file called hello.js (or any programming language file you prefer).

3. Writing Your First Line of Code

In the hello.js file, start by typing a comment to describe what you want to do:

// This program prints "Hello, World!" to the console

As you type, GitHub Copilot will suggest completions. You’ll see a greyed-out suggestion appear. To accept it, just hit Tab.

4. Adding More Code

Now, let’s write the code to print "Hello, World!" to the console. You can start typing:

console.log("Hello, World!");

Again, watch for GitHub Copilot's suggestions. If it suggests the line for you, hit Tab to accept.

5. Running Your Code

To run your code, you need to open a terminal in VS Code:

  • Go to the top menu and click on Terminal > New Terminal.
  • In the terminal, type node hello.js and hit Enter. You should see "Hello, World!" printed in the terminal.

6. Expanding Your Code

Now that you’ve written your first line of code, let's add more functionality. You might want to add a simple function. Start typing:

// A function to greet a user
function greet(name) {

GitHub Copilot will likely suggest completing the function. Finish it by accepting the suggestion or typing it yourself.

    console.log("Hello, " + name + "!");
}

7. Calling Your Function

Finally, call your function to see it in action:

greet("Alice");

Repeat the process of running the file in the terminal. Now you should see both greetings in your terminal output.

Troubleshooting Common Issues

  • Copilot Suggestions Not Appearing: Make sure you are signed in to GitHub and that the Copilot extension is enabled.
  • Errors When Running Code: Check your syntax carefully. JavaScript is sensitive to punctuation and spacing.

What's Next?

Now that you’ve successfully written and run your first lines of code, consider exploring more complex features of GitHub Copilot, like generating functions or working with APIs. You can also check out our podcast, Built This Week, where we discuss practical tips for indie hackers and solo founders.

Conclusion

GitHub Copilot can be a fantastic tool for beginners, providing real-time code suggestions and helping you learn as you go. Start with small projects, and over time, you'll find yourself more comfortable writing code.

What We Actually Use

In our experience, we rely on GitHub Copilot for rapid prototyping and learning new programming languages. It's not perfect, but it cuts down the friction of starting from scratch.

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read