> ## 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.

# Update

> Keep your tests synchronized with code changes using bugster update

The `bugster update` command automatically maintains your test specifications by analyzing code changes and updating, creating, or deleting tests accordingly to keep them synchronized with your evolving codebase.

## Basic Usage

```bash theme={null}
bugster update
```

## Command Overview

Analyzes git changes in your codebase and intelligently updates your test suite to reflect modifications, additions, and deletions in your application code.

### When to Use

* **After modifying existing features** to keep tests in sync
* **In Pull Request workflows** to automate test maintenance
* When you've added new pages or components
* After deleting or refactoring code sections

### Key Features

* Compares against git changes to determine updates needed
* Creates new tests, modifies existing ones, or deletes obsolete tests
* Saves current state for future incremental comparisons
* Works with both staged and unstaged changes
* Intelligent selective updating of relevant test sections

<Note>
  The update command requires a git repository with committed changes for comparison and automatically saves update state after successful runs.
</Note>

<Warning>
  Automatic test synchronization is currently available for Next.js and React applications. For other frameworks, you can still update tests using [coding agents](/guides/coding-agents/cursor) (Cursor or Claude Code) with the plugin rules.
</Warning>

## Command Syntax

```bash theme={null}
bugster update [options]
```

## How It Works

The update command:

1. **Change Analysis**: Compares current code against git history or saved state
2. **Impact Assessment**: Identifies which tests are affected by code changes
3. **Test Maintenance**: Updates, creates, or deletes test specifications as needed
4. **State Saving**: Records current state for future incremental updates
5. **Validation**: Ensures test specifications remain valid and executable

## Update Types

<Tabs>
  <Tab title="Modified Files">
    Updates existing test specs when code changes:

    * Function signature changes → updated test steps
    * UI modifications → adjusted interaction flows
    * Logic updates → revised assertion patterns
  </Tab>

  <Tab title="New Files">
    Suggests new test specs for added code:

    * New components → generates component test files
    * New pages → creates page-specific test scenarios
    * New features → develops feature test coverage
  </Tab>

  <Tab title="Deleted Files">
    Removes obsolete test specs:

    * Removed pages → deletes corresponding tests
    * Deleted components → removes component tests
    * Refactored code → cleans up outdated specs
  </Tab>
</Tabs>

## Scope Options

<ParamField query="--update-only" type="boolean">
  Only update existing test specifications. No new test suggestions or deletions will be performed.
</ParamField>

<ParamField query="--suggest-only" type="boolean">
  Only suggest new test specifications for added files. No updates to existing tests or deletions.
</ParamField>

<ParamField query="--delete-only" type="boolean">
  Only delete obsolete test specifications for removed files. No updates or new suggestions.
</ParamField>

## Comparison Options

<ParamField query="--against-default" type="boolean">
  Compare against the default branch (main/master) instead of HEAD. Perfect for Pull Request workflows.
</ParamField>

<ParamField query="--against-last-update" type="boolean">
  Compare against the commit from the last update run. Enables incremental updates for active development.
</ParamField>

<ParamField query="--show-logs" type="boolean">
  Show detailed logs during analysis. (Deprecated - use --debug instead)
</ParamField>

## Examples

### Complete Test Maintenance

```bash theme={null}
bugster update
```

Handles all types of changes: updates, additions, and deletions.

### Safe Updates Only

```bash theme={null}
bugster update --update-only
```

Only modifies existing tests without creating new ones or deleting any.

### New Feature Testing

```bash theme={null}
bugster update --suggest-only
```

Generates tests only for newly added code and features.

### Post-refactor Cleanup

```bash theme={null}
bugster update --delete-only
```

Removes obsolete tests after code refactoring or deletion.

### Branch Comparison

```bash theme={null}
bugster update --against-default
```

Compares against main/master branch to catch all changes in feature branch.

### Incremental Updates

```bash theme={null}
bugster update --against-last-update
```

Only processes changes since the last update run for efficient maintenance.

## Workflow Integration

<CardGroup cols={2}>
  <Card title="Pre-commit Hook" icon="code-commit">
    ```bash theme={null}
    bugster update --update-only
    ```

    Ensure tests stay current before committing changes.
  </Card>

  <Card title="PR Automation" icon="code-pull-request">
    ```bash theme={null}
    bugster update --against-default
    ```

    Automate test maintenance in GitHub Actions/CI.
  </Card>

  <Card title="Feature Development" icon="code">
    ```bash theme={null}
    bugster update
    ```

    Complete maintenance after feature development.
  </Card>

  <Card title="Daily Maintenance" icon="clock">
    ```bash theme={null}
    bugster update --against-last-update
    ```

    Regular incremental test maintenance.
  </Card>
</CardGroup>

## Update Scenarios

<AccordionGroup>
  <Accordion title="Feature Branch Workflow">
    ```bash theme={null}
    # After completing feature development
    bugster update

    # For PR review
    bugster update --against-default
    ```

    Maintains tests throughout feature development lifecycle.
  </Accordion>

  <Accordion title="Continuous Integration">
    ```bash theme={null}
    # In GitHub Actions
    bugster update --against-default --update-only
    ```

    Automated test maintenance in CI/CD pipelines.
  </Accordion>

  <Accordion title="Refactoring Projects">
    ```bash theme={null}
    # After major refactoring
    bugster update --delete-only

    # Then update remaining tests
    bugster update --update-only
    ```

    Systematic test cleanup after code restructuring.
  </Accordion>
</AccordionGroup>

## Validation Workflow

After running update, follow this validation process:

1. **Review Changes**: Examine generated test modifications
2. **Run Tests**: Execute updated tests with `bugster run --only-affected`
3. **Validate Coverage**: Ensure new features have adequate test coverage
4. **Commit Updates**: Add updated test specifications to version control

## Limitations

<Warning>
  Cannot use both `--against-default` and `--against-last-update` simultaneously. Choose one comparison method per execution.
</Warning>

## Best Practices

<Tip>
  Use `--against-last-update` for incremental updates during active development. Combine with `bugster run --only-affected` for complete change validation workflow.
</Tip>

<Note>
  Always review generated changes before committing to your repository. The `--against-default` flag is perfect for PR workflows to catch all branch changes comprehensively.
</Note>
