---
spec_name: "Cursor AI Agent for Automated Bug Fixes"
author: "Mike Kwal"
version: "1.0"
date: "2026-07-13"
description: "A spec for Claude Code to understand and help implement a Cursor Automation that automatically fixes bugs based on new GitHub issues."
---

# Overview

This spec outlines how to configure a Cursor Automation to create an always-on AI agent. The agent's task is to monitor a specific GitHub repository for new issues, attempt to write a code fix for each issue, and then open a pull request with the proposed fix for human review.

## Core Task: The `/automate` Command

The entire workflow is created using a single plain-English command in the Cursor editor. This is the prompt to use.

```plaintext
/automate "When a new issue is opened in the 'your-repo-name' repository, do the following:
1. Read the full issue title and body to understand the problem.
2. Identify the most likely file or files that need to be changed.
3. Write the code to fix the issue.
4. Create a new branch named 'fix/issue-<issue_number>'.
5. Commit the changes with a message: 'fix: address issue #<issue_number>'.
6. Open a pull request back to the 'main' branch, summarizing the fix in the PR description."
```

## Implementation Steps

Here is the step-by-step process to deploy this agent:

1.  **Open Cursor**: Launch the Cursor editor.
2.  **Invoke the Skill**: Type `/automate` and press enter.
3.  **Provide the Prompt**: Paste the command from the section above into the input field.
4.  **Configure the Trigger**:
    *   Cursor will generate a visual representation of the workflow.
    *   Click on the "Trigger" block.
    *   Select "GitHub" as the source.
    *   Authenticate your GitHub account.
    *   Choose the target repository from the dropdown list.
    *   Select the event: `Issues` -> `Opened`.
5.  **Activate the Automation**: Save and enable the automation. It is now live.

## Post-Launch Monitoring

1.  **Create a Test Issue**: Go to the selected GitHub repository and create a new issue with a clear, simple bug report (e.g., "Homepage title has a typo").
2.  **Check Automation Logs**: In Cursor, navigate to the Automations tab to see the log of the agent running.
3.  **Review the Pull Request**: You should receive a notification from GitHub that a new PR has been opened. Review the code changes proposed by the agent.
4.  **Use the iOS App**: Download and log into the Cursor iOS app to monitor notifications, review diffs, and merge PRs from your phone.

## Best Practices

*   **Start with a Test Repo**: Never point a new agent at a critical production codebase on the first run. Use a staging or test repository to validate its behavior.
*   **Use Labels**: For production repos, consider configuring the trigger to only fire on issues with a specific label (e.g., `agent-approved`) to maintain tight control.
*   **Clear Issue Descriptions**: The agent's success depends heavily on the quality of the bug report. Encourage clear, specific, and actionable issue titles and descriptions.