> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bugster.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate with Cursor

> Configure Cursor to be your Bugster test generation assistant

Transform Cursor into a Bugster expert that can both generate comprehensive test specifications and automatically validate your UI changes as you build.

## Three Cursor Use Cases for Bugster

Bugster provides three specialized Cursor rules to enhance your development workflow:

<CardGroup cols={3}>
  <Card title="Test Generation" icon="file-lines" href="#test-generation-rule">
    **Manual activation** - Generate comprehensive test specifications following Bugster's YAML structure and best practices.
  </Card>

  <Card title="Test Update" icon="arrows-rotate" href="#test-update-rule">
    **Manual activation** - Update existing test specifications based on code changes and new requirements.
  </Card>

  <Card title="Quick Validation" icon="bolt" href="#quick-test-rule">
    **Auto-activation** - Automatically validate UI changes after modifying components or pages with a final E2E test.
  </Card>
</CardGroup>

| Rule                 | When to Use          | Activation                   | Purpose                                    |
| :------------------- | :------------------- | :--------------------------- | :----------------------------------------- |
| **Test Generation**  | Building test suites | Manual (`@bugster-generate`) | Create comprehensive test specifications   |
| **Test Update**      | Maintaining tests    | Manual (`@bugster-update`)   | Update existing tests after code changes   |
| **Quick Validation** | After UI changes     | Automatic (on file save)     | Validate implementation meets requirements |

## Using Cursor with Bugster

Cursor rules provide persistent context about your Bugster project, ensuring consistent test generation and automatic validation that follows your standards and best practices.

* **Project rules** are stored in your repository and shared with your team.
* **User rules** apply to your personal Cursor environment.

We recommend creating project rules for your Bugster project so that all contributors generate tests following the same standards.

Create rules files in the `.cursor/rules` directory of your project. See the [Cursor Rules documentation](https://docs.cursor.com/context/rules) for complete setup instructions.

## Test Generation Rule

This rule provides Cursor with context to properly generate Bugster test specifications following the required YAML structure and best practices.

### Installation

Install the official test generation rule using the Bugster CLI:

```bash theme={null}
bugster plugin --agent cursor
```

This installs `bugster-generate.mdc` in your `.cursor/rules/` directory.

<Info>
  View the official rule: [Cursor Test Generation Rule](https://github.com/Bugsterapp/bugster-cli/tree/main/plugins/cursor)
</Info>

### How to Use

Reference the rule in your Cursor chat to activate it:

<CodeGroup>
  ```text Basic Usage theme={null}
  @bugster-generate Create a test for the user login page
  ```

  ```text Specific Feature theme={null}
  @bugster-generate Generate tests for the shopping cart checkout flow
  ```

  ```text Multiple Tests theme={null}
  @bugster-generate Create 3 tests for the dashboard analytics page
  ```
</CodeGroup>

### What It Does

* Generates comprehensive test specifications in proper YAML format
* Follows Bugster naming conventions and file structure
* Creates tests in `.bugster/tests/` with correct hierarchy
* Validates all required fields are present
* Limits generation to avoid test duplication

<Tip>
  The rule automatically checks existing tests to avoid duplicates and follows your project's file structure conventions.
</Tip>

## Test Update Rule

This rule helps you update existing test specifications when your code changes or requirements evolve.

### Installation

Install the official test update rule using the Bugster CLI:

```bash theme={null}
bugster plugin --agent cursor
```

This installs `bugster-update.mdc` in your `.cursor/rules/` directory.

<Info>
  View the official rule: [Cursor Test Update Rule](https://github.com/Bugsterapp/bugster-cli/tree/main/plugins/cursor)
</Info>

### How to Use

Reference the rule in your Cursor chat to activate it:

<CodeGroup>
  ```text Update After Changes theme={null}
  @bugster-update Update tests for the authentication flow based on recent changes
  ```

  ```text Specific File theme={null}
  @bugster-update Refresh tests for app/checkout/page.tsx to match new UI
  ```

  ```text Bulk Update theme={null}
  @bugster-update Update all dashboard tests to reflect new navigation structure
  ```
</CodeGroup>

### What It Does

* Updates existing test specifications to match code changes
* Maintains test structure while adapting to new requirements
* Preserves test intent while updating implementation details
* Ensures tests stay synchronized with your codebase
* Follows the same YAML standards as test generation

<Tip>
  Use this rule after refactoring components or updating user flows to keep your test suite current without starting from scratch.
</Tip>

## Quick Test Rule

This rule automatically validates your UI changes by running a comprehensive E2E test after you modify components or pages. It helps ensure your implementation meets user requirements.

<Info>
  **File name suggestion:** `bugster-quick-test.mdc`
</Info>

<Warning>
  E2E tests are slow (30-300 seconds). This rule is designed to run sparingly - only as final verification after code changes.
</Warning>

Add this rule as a `.mdc` file in the `.cursor/rules` directory of your project:

````mdx theme={null}
---
alwaysApply: true
description: Auto-validate UI changes with quick test after modifying components or pages
globs:
  - "**/*.tsx"
  - "**/*.jsx" 
  - "**/page.tsx"
  - "**/page.jsx"
---
# Bugster Quick Test Rules

## Context
Bugster is an E2E testing agent that executes UI tests in browsers. Tests are slow (30-300 seconds), so use sparingly.

## Use Case
**Validate from the UI that generated code respects user requirements** - use as final verification step after code generation.

## Auto-Trigger Behavior
**This rule should AUTOMATICALLY activate when:**
- Creating new UI components
- Modifying existing React components  
- Implementing user-facing features
- Making changes to pages or layouts

## When to Use
- **Only once at the end** of code generation process
- At the end of every change in the UI
- After implementing features that affect UI behavior
- To verify multiple aspects in a single comprehensive test
- **Never abuse** - execution takes up to 5 minutes

## Command Format
Always use these flags:

```bash
bugster run --prompt "{comprehensive validation description}" --silent --headless --output quick_validation.json
```

Add `--base-url http://localhost:PORT` if you opened the app in a new terminal.

## Prompt Guidelines
- **Be comprehensive** - validate multiple points in one test since you only get one shot
- Focus on core functionality the user requested
- Include key user flows and expected behaviors
- Mention specific UI elements or interactions to verify

## Example
```bash
bugster run --prompt "Test the new user registration form - verify all fields accept input, form submits successfully, validation works for empty fields, and user gets redirected to dashboard after signup" --silent --headless --base-url http://localhost:3000 --output quick_validation.json
```

## Rules
- **Maximum 1 execution per code generation session**
- Always include `--silent --headless --output quick_validation.json`
- Pack multiple validations into single comprehensive prompt
- Use only as final verification step
````

## Combining All Rules

For optimal workflow, use all three rules together:

<Steps>
  <Step title="Setup">
    Install the official rules and add the quick test rule to your `.cursor/rules` directory:

    ```bash theme={null}
    bugster plugin --agent cursor
    ```

    Then add `bugster-quick-test.mdc` (see Quick Test Rule section above) for auto-validation.
  </Step>

  <Step title="Development Flow">
    1. Build your feature as requested
    2. **Quick Test rule** automatically validates the implementation
    3. Use **Test Generation rule** to create comprehensive test suites
    4. Use **Test Update rule** when refactoring or updating features
  </Step>

  <Step title="Team Consistency">
    All three rules ensure team members follow the same Bugster standards and validation processes.
  </Step>
</Steps>

<Tip>
  The plugin command installs both generation and update rules automatically. Add the quick validation rule manually for auto-testing after code changes.
</Tip>
