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

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