Ai Coding Tools

How to Build a Simple GitHub Bot with Cursor in 1 Hour

By BTW Team3 min read

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

In short

A step-by-step tutorial on utilizing Cursor to create a functional GitHub bot in just one hour, perfect for enhancing your workflow.

If you’re like me, you’ve probably found yourself wishing for a way to automate those repetitive tasks on GitHub. Maybe you want to label issues automatically, respond to pull requests, or even send reminders for code reviews. Building a GitHub bot can sound daunting, but with the right tools, it can be done in just one hour. In this guide, I’ll walk you through how to create a simple GitHub bot using Cursor—an AI coding tool that has been making waves for its ease of use and efficiency.

Why Use Cursor for Your GitHub Bot?

Cursor is an AI coding assistant that helps you write and debug code faster. It’s particularly good for automating tasks and can integrate directly with your development environment. Here’s why I recommend it:

  • Time Efficiency: Cursor can generate code snippets, which saves you time writing boilerplate code.
  • Error Reduction: It helps catch bugs early, especially useful when working with GitHub APIs.
  • User-Friendly: Even if you’re not a coding expert, Cursor makes it easier to implement complex logic.

Prerequisites

Before diving in, make sure you have the following:

  1. GitHub Account: You’ll need access to create a repository.
  2. Node.js Installed: Download from nodejs.org if you don’t have it.
  3. Cursor Account: Sign up at cursor.so.
  4. Basic JavaScript Knowledge: Familiarity with JavaScript will help, but I’ll guide you through the tricky parts.

Step-by-Step Guide to Building Your GitHub Bot

Step 1: Set Up Your GitHub Repository

  1. Go to GitHub and create a new repository.
  2. Name it something like github-bot-example.
  3. Initialize it with a README file.

Step 2: Create Your Bot Script

  1. Open your terminal and navigate to your repository folder.
  2. Run npm init -y to create a package.json file.
  3. Install the required packages:
    npm install axios dotenv
    
  4. Create a new file named bot.js.

Step 3: Write Your Bot Logic

Here’s a simple bot that labels issues based on keywords in the title:

require('dotenv').config();
const axios = require('axios');

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
const REPO_OWNER = 'your-github-username';
const REPO_NAME = 'github-bot-example';

async function labelIssues() {
    const response = await axios.get(`https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues`, {
        headers: {
            Authorization: `token ${GITHUB_TOKEN}`
        }
    });

    const issues = response.data;

    for (let issue of issues) {
        if (issue.title.includes('bug')) {
            await axios.post(`https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${issue.number}/labels`, {
                labels: ['bug']
            }, {
                headers: {
                    Authorization: `token ${GITHUB_TOKEN}`
                }
            });
        }
    }
}

labelIssues();

Step 4: Configure Your Environment Variables

  1. Create a .env file in your project directory.
  2. Add your GitHub token:
    GITHUB_TOKEN=your_github_token
    

Step 5: Run Your Bot

  1. In your terminal, run:
    node bot.js
    
  2. Check your GitHub issues to see if the labels were applied correctly.

Troubleshooting Common Issues

  • Invalid Token Error: Make sure your GitHub token has the correct permissions (repo access).
  • Network Issues: Ensure that your internet connection is stable.
  • API Rate Limiting: GitHub APIs have rate limits. If you hit a limit, you’ll need to wait before making more requests.

What's Next?

Now that you have a basic GitHub bot, consider expanding its functionality. You could add features like:

  • Responding to pull requests with comments.
  • Automatically closing issues after a certain period.
  • Integrating with Slack for notifications.

Conclusion: Start Here

Building a GitHub bot using Cursor is a practical way to automate your workflows. This guide should take you about an hour to complete. Remember, while this bot is simple, the potential for automation is vast.

If you’re looking to dive deeper into AI coding tools, check out our podcast, Built This Week, where we discuss more tools and techniques for builders like you!

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