Ai Coding Tools

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

By BTW Team4 min read

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

Getting started with coding can feel daunting, especially if you’re a solo founder or indie hacker trying to ship your first project. You might be wondering, “Can AI really help me write code?” The answer is yes, and GitHub Copilot is a powerful tool that can guide you through your first lines of code. In this guide, I'll show you how to leverage Copilot effectively in 2026.

Time Estimate and Prerequisites

Time to complete: You can finish this in about 30 minutes.

Prerequisites:

  • A GitHub account (free)
  • Visual Studio Code (free)
  • GitHub Copilot subscription ($10/month, free trial available)

Step 1: Install GitHub Copilot

  1. Set up Visual Studio Code: If you don’t have it installed, download it from Visual Studio Code.
  2. Install GitHub Copilot:
    • Open Visual Studio Code.
    • Go to Extensions (Ctrl+Shift+X).
    • Search for “GitHub Copilot” and click on “Install.”
  3. Authenticate Your GitHub Account: After installation, you’ll be prompted to sign in to your GitHub account to activate Copilot.

Step 2: Create a New File

  1. Open a New File: Go to File > New File in Visual Studio Code.
  2. Choose a Language: Start with JavaScript or Python for simplicity. Type // This is a simple calculator for JavaScript or # This is a simple calculator for Python to indicate your intent.

Step 3: Start Coding with Copilot

  1. Write Your First Line: Begin with a comment that describes what you want to do. For example, // Function to add two numbers.
  2. Trigger Copilot Suggestions: After typing your comment, you should see a suggestion pop up from Copilot. Press Tab to accept the suggestion.
  3. Iterate on Functions: Continue writing comments for each function you want to create. For example:
    // Function to subtract two numbers
    // Function to multiply two numbers
    // Function to divide two numbers
    
    Copilot will provide code for each function as you type.

Expected Outputs

By the end of this step, you should have a simple calculator with functions to add, subtract, multiply, and divide. Here’s what it might look like in JavaScript:

// Function to add two numbers
function add(a, b) {
    return a + b;
}

// Function to subtract two numbers
function subtract(a, b) {
    return a - b;
}

// Function to multiply two numbers
function multiply(a, b) {
    return a * b;
}

// Function to divide two numbers
function divide(a, b) {
    return a / b;
}

Troubleshooting Common Issues

  • No Suggestions from Copilot: If you’re not getting suggestions, make sure you’re connected to the internet and check that Copilot is enabled in your settings.
  • Suggestions are Off-Topic: Sometimes, Copilot doesn’t understand your context. Try rephrasing your comments or be more specific about what you want.
  • Errors in Generated Code: Always review the code Copilot generates. It’s not perfect and may require adjustments.

What's Next?

Now that you have your first lines of code, consider expanding your project. You can:

  • Implement a user interface using HTML/CSS.
  • Add error handling to your functions.
  • Explore integrating your calculator into a web app using frameworks like React or Flask.

Conclusion

Using GitHub Copilot can drastically reduce the learning curve for new coders. Start with clear comments, let Copilot do the heavy lifting, and refine the code to fit your needs. This approach not only helps you write your first 5 lines of code but also builds confidence as you see your project come together.

What We Actually Use: For simple projects, we rely heavily on GitHub Copilot for drafting code quickly. However, we always review and refine the output to ensure it meets our standards.

If you’re ready to dive into coding with GitHub Copilot, start today and see how it can help you ship your next project faster.

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

Cursor vs GitHub Copilot: An In-Depth Comparison for Developers

Cursor vs GitHub Copilot: An InDepth Comparison for Developers As a developer, choosing the right AI coding tool can feel like navigating a minefield. Cursor and GitHub Copilot hav

May 9, 20263 min read
Ai Coding Tools

AI Coding Tools: Bolt.new vs GitHub Copilot - Which is Better?

AI Coding Tools: Bolt.new vs GitHub Copilot Which is Better? As a solo founder or indie hacker, finding the right coding tool can feel like searching for a needle in a haystack. W

May 9, 20263 min read
Ai Coding Tools

How to Write Your First Program with AI Tools in Under 1 Hour

How to Write Your First Program with AI Tools in Under 1 Hour Ever felt overwhelmed by the idea of writing your first program? You’re not alone. Many aspiring developers think codi

May 9, 20264 min read
Ai Coding Tools

7 Game-Changing AI Coding Tools for Senior Developers 2026

7 GameChanging AI Coding Tools for Senior Developers 2026 As senior developers, we often find ourselves buried under layers of complexity—code reviews, debugging, and the constant

May 9, 20264 min read
Ai Coding Tools

Cursor vs GitHub Copilot: Which AI Tool Will Save You More Time?

Cursor vs GitHub Copilot: Which AI Tool Will Save You More Time? As indie hackers and solo founders, we’re all looking for ways to maximize productivity without breaking the bank.

May 9, 20263 min read
Ai Coding Tools

How to Build a Simple Web App Using AI Tools in Just 4 Hours

How to Build a Simple Web App Using AI Tools in Just 4 Hours Building a web app can feel like an insurmountable task, especially for indie hackers and solo founders juggling multip

May 9, 20264 min read