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

# GitHub Agent

> Automatically generate and run Spur tests on every pull request with the Spur GitHub App.

## Overview

The Spur GitHub App analyzes every pull request the moment it's opened. It looks at the files changed and the actual code diff, then automatically generates a focused set of browser tests that cover the change. Spur also scans your existing test suite and triggers any relevant saved tests, so every PR gets both fresh, change-aware tests and proven regression coverage.

<Columns cols={2}>
  <Card icon="wand-magic-sparkles" title="Auto-generated tests">
    Spur reads the diff and generates tests targeting exactly what changed — uppercase handling, edge cases, new flows, etc.
  </Card>

  <Card icon="magnifying-glass" title="Relevant existing tests">
    Spur scans your saved tests and runs the ones related to the changed area of your app.
  </Card>

  <Card icon="link" title="Preview-aware">
    Spur picks up the preview deployment URL from your PR (e.g. Vercel) and runs tests against that build.
  </Card>

  <Card icon="comments" title="Re-trigger with context">
    @-mention Spur in a PR comment to re-run with extra context like "log in as an admin user."
  </Card>
</Columns>

<Note>
  Looking for the YAML-based CI/CD setup instead? See the [GitHub CI/CD integration](/running-tests/cicd/github) — that flow runs your existing test plans on every PR via GitHub Actions. The GitHub Agent described here is a separate, AI-driven flow that generates tests on the fly.
</Note>

## How it works

<Steps>
  <Step title="Open a pull request">
    As soon as you open a PR, the Spur GitHub App reads the changed files, the diff, and the PR title and description to understand the change.

    <Frame caption="Spur analyzes the PR diff to understand what changed">
      <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-1.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=04661a89c0cb06832b6372b45e4f1f2e" alt="PR diff being analyzed by Spur" width="1880" height="422" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-1.png" />
    </Frame>
  </Step>

  <Step title="Spur generates new tests and finds relevant existing tests">
    A comment from the Spur app appears on your PR with the set of tests it generated for the change. Each test targets a specific case Spur thinks is worth verifying — for a search-input change, that might be uppercase matching, accented characters, internal whitespace, and case-insensitive matching. Spur also searches your saved tests for ones that touch the same area of the app and kicks those off as part of the same PR run — in the comment, generated tests and existing tests are listed separately so you can tell them apart.

    <Frame caption="Spur posts a comment with generated and existing tests and their statuses">
      <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-2.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=5cb5c8817eb60b3f0b515e8dd2a67155" alt="Spur PR comment with generated and existing tests" width="1892" height="1304" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-2.png" />
    </Frame>
  </Step>

  <Step title="Tests run on the preview deployment">
    Spur automatically detects the preview URL from the PR (for example a Vercel preview) and runs every test against that deployment. No environment configuration is required for the per-PR run.
  </Step>
</Steps>

## Reviewing a test run

Click the **View Generated Tests** link in the Spur PR comment to open the full run on Spur. You get everything a normal Spur test run gives you:

* The full list of steps the agent executed
* Screenshots at each step
* The deployment URL the test ran against
* Pass/fail status and failure reasons

If a test fails, this is the place to dig in — step through the screenshots, read the agent's step descriptions, and figure out whether the failure is a real regression or a flaky expectation in the generated test.

<Frame caption="Deep-dive view of a test run, with steps and screenshots">
  <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-3.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=040fb522b781b04f9e7ba50911f67f9d" alt="Spur test run detail page" width="2886" height="2658" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-3.png" />
</Frame>

## Keeping a generated test

By default, generated tests are **discarded** after the PR run — they're scoped to that PR and don't pollute your suite.

If a generated test is good enough that you want it to keep running on future PRs and as part of your test plans, save it:

<Steps>
  <Step title="Click Keep Test">
    On the test result, click **Keep Test**.

    <Frame caption="Promote a generated test into your saved suite">
      <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-4.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=ec206af8a5b5b0dee056a801945d132f" alt="Keep Test button" width="1538" height="786" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-4.png" />
    </Frame>
  </Step>

  <Step title="Add it to a suite">
    You'll be prompted to add the test to an existing suite or create a new one. Once saved, the test behaves like any other Spur test and will be re-triggered on future PRs that touch the same area of the code.
  </Step>
</Steps>

For tests that came from your existing suite, the test result is identical to a normal Spur run — no extra step needed.

## Re-triggering with extra context

You can ask Spur to re-analyze a PR and apply new context by @-mentioning the app in a PR comment.

```text theme={null}
@spur re-trigger the tests, but let's log in as an admin user instead.
```

When you submit the comment, Spur:

1. Reacts to the comment to confirm it picked up the mention.
2. Re-reads the PR diff and preview URL.
3. Generates a fresh set of tests, applying your extra context (in the example above, logging in as admin instead of a normal user).
4. Posts the new run back to the PR.

This is useful for nudging the agent toward specific user roles, prerequisite states, or operational quirks of your app that aren't obvious from the diff alone.

<Frame caption="Re-trigger a run by @-mentioning Spur with extra context">
  <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-5.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=a3bb4b24b2a7a5223c773f15168ace02" alt="@-mention re-trigger" width="1972" height="798" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-5.png" />
</Frame>

## Setting default context

If you find yourself repeating the same context on every PR ("log in as admin," "the staging env requires this header," etc.), set it once as default context on the integration.

<Steps>
  <Step title="Open the GitHub integration">
    In Spur, go to **Integrations** and open **GitHub**.
  </Step>

  <Step title="Add default context">
    Find the **Default context** section. Enter any prerequisites or operational notes you want Spur to apply on every PR run — for example, admin credentials, normal user credentials, required feature flags, or UI quirks the agent should be aware of.

    <Frame caption="Default context is applied to every PR run">
      <img src="https://mintcdn.com/spur/KO4zCO82tgjeHdPa/images/Integrations/Github/Pr-Agent/spur-github-agent-6.png?fit=max&auto=format&n=KO4zCO82tgjeHdPa&q=85&s=a34104c3308595b9b44470dd4de19d91" alt="Default context settings" width="2034" height="1860" data-path="images/Integrations/Github/Pr-Agent/spur-github-agent-6.png" />
    </Frame>
  </Step>

  <Step title="Save changes">
    Click **Save Changes**. From now on, every PR analysis Spur runs will include this context alongside the PR diff, weighted into how it generates and selects tests.
  </Step>
</Steps>

<Tip>
  Default context is global — it's applied to every PR. Use a PR-comment @-mention when you only want extra context for a single run.
</Tip>

## FAQ

<AccordionGroup>
  <Accordion title="Are generated tests saved automatically?">
    No. Generated tests are discarded by default after the PR closes. Click **Keep Test** on any generated test to promote it into one of your suites.
  </Accordion>

  <Accordion title="How does Spur pick which existing tests to run?">
    Spur scans your saved tests and matches them against the area of the app that changed in the PR. Only tests Spur considers relevant to the diff are triggered — your full suite is not run on every PR.
  </Accordion>

  <Accordion title="What deployment URL does Spur run tests against?">
    Spur extracts the preview deployment URL from the PR automatically. Vercel preview deploys are supported out of the box; other providers that post a preview URL in PR comments also work.
  </Accordion>

  <Accordion title="Can I re-run tests after pushing new commits?">
    Yes. Push new commits and @-mention Spur in a PR comment asking it to re-trigger. Spur will re-analyze the latest diff and preview URL.
  </Accordion>
</AccordionGroup>
