Ai Coding Tools

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

By BTW Team3 min read

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

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!

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: Which AI Tool Performs Better in 2026?

Cursor vs GitHub Copilot: Which AI Tool Performs Better in 2026? In the everevolving landscape of AI coding tools, two names have frequently emerged: Cursor and GitHub Copilot. As

Aug 11, 20263 min read
Ai Coding Tools

Bolt.new vs GitHub Copilot: A Side-by-Side Comparison for 2026

Bolt.new vs GitHub Copilot: A SidebySide Comparison for 2026 If you're a solo founder or indie hacker trying to speed up your coding process, you might be torn between two popular

Aug 11, 20263 min read
Ai Coding Tools

Cursor AI vs GitHub Copilot: Which is Better for Indie Developers in 2026?

Cursor AI vs GitHub Copilot: Which is Better for Indie Developers in 2026? As an indie developer, choosing the right coding assistant can make or break your productivity. In 2026,

Aug 11, 20263 min read
Ai Coding Tools

Why Most Developers Overrate AI Coding Tools: Busting the Myths

Why Most Developers Overrate AI Coding Tools: Busting the Myths As a solo developer or indie hacker, it's easy to get swept up in the hype surrounding AI coding tools. The promise

Aug 11, 20264 min read
Ai Coding Tools

How to Code Your First AI Application in 30 Minutes

How to Code Your First AI Application in 30 Minutes If you're a solo founder or indie hacker looking to dive into the world of AI, the thought of coding your first AI application c

Aug 11, 20264 min read
Ai Coding Tools

AI Coding Tools Comparison: Cursor vs GitHub Copilot – Which is Better for Beginners?

AI Coding Tools Comparison: Cursor vs GitHub Copilot – Which is Better for Beginners? As a solo founder or indie hacker, diving into coding can feel like an uphill battle, especial

Aug 11, 20264 min read