# Let a coding agent fix failing tests overnight

Scoped permissions, a branch per fix and a pull request for review in the morning.

- Category: Coding
- Runs on: Claude Code
- Level: Advanced
- Setup time: about 60 minutes
- Source: https://crimsonbot.ronskaggs.workers.dev/playbooks/fix-failing-tests-overnight

## You will need

- A repository with a test suite
- Claude Code with a scoped token

## You will end up with

- A pull request per fix, waiting for review

## Steps

### 1. Scope the agent's permissions

Give it a token that can push branches and open pull requests, but not merge or change settings.

### 2. Run the test suite and hand over failures

Have the agent run the tests, pick one failure per branch and fix it with the smallest change.

### 3. Review the pull requests in the morning (human checkpoint)

A person reviews and merges. Close anything that changes a test to make it pass.

## Tools used

- [Claude Code](https://claude.com/claude-code): Coding agent for the terminal, IDE and desktop.
