# Turn Linear Issues Into Pull Requests for a Flask App

An agent flashes flaskbb moderators and admins a notice when a post on the page is by an author with exactly one post, and adds 4 pytest tests.

[Run this on Rush](https://cloud.getrush.ai/run/linear-issue-to-pr/flask/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The issue was flaskbb/flaskbb #544, a real GitHub issue appended in place of a Linear one, and it is one line: a flash message for admins and mods on new users' first posts. The agent found no hook at post creation that reaches a moderator, so it put the notice where a moderator sees the post: `ViewTopic.get` in `flaskbb/forum/views.py`.

When `Permission(can_moderate(topic.forum))` holds, it collects the authors on the page whose `post_count == 1` and flashes `"%(username)s is a new user and this is their first post."` as `info`. `tests/unit/forum/test_new_user_first_post_notice.py` uses the existing `admin_user`, `moderator_user`, `user` and `topic` fixtures.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Implement the Linear issue given as a resource in this Flask codebase. Read the issue and its comments first. Make the change in the forum or user blueprint the issue concerns, including its form, model, service or permission check, and keep the diff small. Add pytest tests under tests/unit using the fixtures in tests/fixtures. Run `uv sync --group dev`, then `uv run pytest` and `uv run ruff check` on the files you touched, and fix what fails. Open a pull request whose description links the issue, explains the change and quotes the test result. Do not merge.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    },
    {
      "url": "https://linear.app/your-org/issue/ENG-42"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on flaskbb/flaskbb at 737d76f1: issue #544, 2 files changed, 59 insertions(+). `uv run pytest` went from 800 to `804 passed, 90 warnings in 92.95s`, and after a final `ruff format` the forum unit tests ended `108 passed in 22.15s`. `uv run ruff check` on the two files ended `All checks passed!` after an unused import and a long line were fixed. `uv sync --group dev` failed on the untouched clone because the sandbox's uv 0.5.11 could not parse `uv.lock`; the agent installed uv 0.13.6 outside the repo.

For the reviewer: whether a flash on topic view is the right trigger, rather than a notification when the post is created, which needs a new mechanism. The notice repeats on every view while the author has one post, and the message is not yet in the translation catalogs.

## Run it on every Linear issue labelled agent

An automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` runs the recipe's prompt with the issue as its context. That prompt asks on the issue when the description is not enough, so a one-line issue like #544 may get a question instead of this trial's reading, an author with exactly one post.

## Why run it on Rush?

#544 is a note-to-self with a link and no acceptance criteria. Instead of building a notification system, the run found where moderators already see posts, made a 17-line change there, and listed what it misses: authors on other pages of the topic, and hidden or deleted posts changing the count.

## Frequently asked questions

### Does a regular user see the notice?

No. One of the four tests checks that a regular user sees no flash, and another that the notice stops once the author has two posts.

### Why not notify when the post is created?

flaskbb has no hook at post creation that reaches a moderator, so that would need a new mechanism. The run kept the change to `ViewTopic.get` and left the choice to the reviewer.

## More Flask jobs

- [Migrate a Flask Project to uv](https://getrush.ai/run/migrate-to-uv/flask/)
- [Review Database Migrations in a Flask App](https://getrush.ai/run/review-database-migrations/flask/)
- [Review Pull Requests Automatically in a Flask App](https://getrush.ai/run/review-pull-requests/flask/)

## The same job on other stacks

- [Turn Linear Issues Into Pull Requests for a Go Service](https://getrush.ai/run/linear-issue-to-pr/go/)
- [Turn Linear Issues Into Pull Requests for a Laravel App](https://getrush.ai/run/linear-issue-to-pr/laravel/)
- [Turn Linear Issues Into Pull Requests for a NestJS API](https://getrush.ai/run/linear-issue-to-pr/nestjs/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
