Ai Coding Tools

How to Use GitHub Copilot to Write a Function in 10 Minutes

By BTW Team3 min read

How to Use GitHub Copilot to Write a Function in 10 Minutes

If you're a solo founder or indie hacker, you know that time is money. The faster you can get features out the door, the better. Enter GitHub Copilot, an AI-powered code completion tool that can help you write functions in record time. In this guide, I'm going to show you how to leverage GitHub Copilot to write a function in about 10 minutes.

Prerequisites

Before we dive in, make sure you have the following:

  • A GitHub account (Free or Pro)
  • Visual Studio Code (VS Code) installed
  • GitHub Copilot extension for VS Code (Free trial available, then $10/month)

Step 1: Install GitHub Copilot

First, you need to install the GitHub Copilot extension in VS Code. Here’s how:

  1. Open VS Code.
  2. Go to Extensions (or press Ctrl + Shift + X).
  3. Search for "GitHub Copilot" and click "Install."
  4. Sign in with your GitHub account.

Expected Output: You should see a small Copilot icon in the bottom-right corner of your VS Code.

Step 2: Create a New File

Create a new file in your desired programming language (e.g., JavaScript, Python). For this example, let’s create a simple addNumbers function in JavaScript.

  1. Click on File > New File.
  2. Save it as addNumbers.js.

Expected Output: A blank JavaScript file.

Step 3: Write a Comment for Your Function

Start by writing a comment that describes what you want the function to do. For example:

// This function adds two numbers and returns the sum.

Expected Output: Copilot should recognize the comment and suggest code.

Step 4: Accept the Suggestion

Once you write the comment, GitHub Copilot will automatically suggest a function implementation. It might look something like this:

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

Simply press Tab to accept the suggestion.

Expected Output: The addNumbers function is now written in your file.

Step 5: Test the Function

Now, let’s test the function by calling it and logging the result:

console.log(addNumbers(5, 10)); // Expected output: 15

Expected Output: You should see 15 in the console when you run the file.

Troubleshooting: What Could Go Wrong

  1. No Suggestions: If Copilot doesn’t suggest anything, make sure the extension is enabled and that you’re connected to the internet.
  2. Incorrect Code: Sometimes the suggestions may not be accurate. Always validate and test the code.

What's Next

Now that you know how to use GitHub Copilot to write a simple function, you can explore more complex functionalities. Try writing functions that handle arrays or objects. The more specific you are in your comments, the better the suggestions will be.

Conclusion: Start Here

In our experience, GitHub Copilot is a fantastic tool for accelerating coding tasks. It's particularly useful for solo founders who need to produce code quickly without getting bogged down in syntax. If you’re looking to save time while coding, I recommend giving it a shot.

Pricing Breakdown

| Feature | Pricing | Best For | Limitations | Our Take | |---------------------|-----------------------|---------------------------------|----------------------------------|-------------------------------| | GitHub Copilot | Free trial, then $10/mo | Quick function writing | May generate incorrect code | We use this for rapid prototyping |

What We Actually Use

We primarily use GitHub Copilot for generating boilerplate code and quick functions, especially when we're on tight deadlines. If you're looking for alternatives, tools like TabNine ($12/mo) or Codeium (Free) might be worth exploring, but Copilot has been the most reliable in our experience.

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

How to Automate Your Development Workflow with AI in 3 Easy Steps

How to Automate Your Development Workflow with AI in 3 Easy Steps (2026) As indie hackers and solo founders, we often find ourselves buried under a mountain of repetitive tasks tha

Sep 3, 20264 min read
Ai Coding Tools

How to Boost Your Coding Velocity with AI in 30 Minutes

How to Boost Your Coding Velocity with AI in 30 Minutes As a solo founder or indie hacker, you know that time is your most precious resource. The idea of boosting your coding veloc

Sep 3, 20264 min read
Ai Coding Tools

Why Most Developers Get GitHub Copilot Wrong: 5 Myths Busted

Why Most Developers Get GitHub Copilot Wrong: 5 Myths Busted As we dive into 2026, GitHub Copilot has become a staple in many developers' toolkits. However, despite its popularity,

Sep 3, 20263 min read
Ai Coding Tools

How to Use AI Coding Tools to Boost Productivity in Under 2 Hours

How to Use AI Coding Tools to Boost Productivity in Under 2 Hours As indie hackers, we all know the struggle of trying to stay productive while juggling multiple projects. The prom

Sep 3, 20265 min read
Ai Coding Tools

Vercel vs GitHub Copilot: Which AI Tool is Right for Your Project?

Vercel vs GitHub Copilot: Which AI Tool is Right for Your Project? As a solo founder or indie hacker, choosing the right tools can be a makeorbreak decision for your project. With

Sep 3, 20263 min read
Ai Coding Tools

Why GitHub Copilot is Not the Magic Bullet for Every Programmer: Debunking the Myths

Why GitHub Copilot is Not the Magic Bullet for Every Programmer: Debunking the Myths As a programmer, I’ve been there: staring at a blank screen, hoping for a burst of inspiration

Sep 3, 20264 min read