What the agent does
The agent reads how authentication and email already work before it adds a flow. In a project shaped like HackSoftware/Django-Styleguide-Example, requirements/base.txt pins Django 5.2.7, djangorestframework 3.16.1, drf-jwt 1.19.2 and celery 5.5.3, and requirements/local.txt adds pytest 8.4.2 with pytest-django, mypy 1.18.2 with the Django and DRF stubs, and ruff 0.14.0. styleguide_example/api/urls.py mounts auth/, users/, errors/ and files/; authentication/urls.py has session/login/, session/logout/, jwt/login/, jwt/logout/ and me/, and nothing for a forgotten password. authentication/apis.py shows the house style: an APIView with a nested InputSerializer, a call into a service, a plain Response. users/models.py defines BaseUser with email as USERNAME_FIELD and a jwt_key UUID that authentication/services.py rotates in auth_logout, because JWT_GET_USER_SECRET_KEY signs each user's tokens with it. The emails app has an Email model with READY, SENDING, SENT and FAILED states and an email_send_all service that flips rows to SENDING and queues the Celery task on commit. config/settings/cors.py defines BASE_FRONTEND_URL, default http://localhost:3000.
It adds two services to authentication/services.py. password_reset_request(*, email) looks the user up, and for an unknown or inactive address returns without doing anything, so the endpoint cannot be used to learn which emails exist. For a known user it builds a token with Django's PasswordResetTokenGenerator and a urlsafe_base64_encode of the primary key, composes the link as BASE_FRONTEND_URL plus /reset-password/<uid>/<token>, creates an Email row with a subject, HTML and plain text, and hands it to email_send_all, so delivery goes through the same Celery task and retry the project already has. password_reset_confirm(*, uid, token, new_password) decodes the uid, checks the token, runs validate_password against the AUTH_PASSWORD_VALIDATORS in config/django/base.py, sets the password, and rotates jwt_key through auth_logout so every JWT issued before the reset stops working. A bad uid or token raises the project's ApplicationError, which api/exception_handlers.py already turns into a 400.
The APIs follow apis.py: PasswordResetRequestApi with an InputSerializer of one EmailField that always answers 200, and PasswordResetConfirmApi with uid, token and new_password. They mount under auth/password-reset/request/ and auth/password-reset/confirm/ with a password-reset namespace, so reverse("api:authentication:password-reset:request") works the way the login tests use reverse. Type hints are complete so mypy --config mypy.ini styleguide_example/ passes with the stubs.
Tests go in authentication/tests/apis/test_password_reset.py in the style of test_user_login.py: TestCase with APIClient, a user from user_create. One test posts a known email, asserts 200 and exactly one Email row, pulls the uid and token out of its plain_text, posts them with a new password to the confirm URL, then logs in through session/login/ with the new password and asserts the old one is refused. Another posts an unknown email and asserts 200 with no Email created. Others cover a tampered token, a password the validators reject, and that a JWT obtained before the reset is refused on me/ afterwards. Before pushing, the agent runs ruff check ., mypy --config mypy.ini styleguide_example/ and pytest, the three commands in django.yml, and pastes the results into the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a password reset API to this Django REST Framework project and open a pull request. Read styleguide_example/api/urls.py, authentication/urls.py, authentication/apis.py, authentication/services.py, authentication/tests/apis/test_user_login.py, users/models.py, users/services.py, users/selectors.py, emails/models.py, emails/services.py, api/exception_handlers.py, config/settings/cors.py, config/django/base.py, mypy.ini and .github/workflows/django.yml first. Add password_reset_request(*, email) and password_reset_confirm(*, uid, token, new_password) to authentication/services.py: use PasswordResetTokenGenerator and urlsafe_base64_encode, build the link from BASE_FRONTEND_URL plus /reset-password/<uid>/<token>, create an Email row and send it through email_send_all, do nothing for an unknown or inactive email, validate the new password with validate_password, set it, and rotate jwt_key through auth_logout; raise ApplicationError for a bad uid or token. Add PasswordResetRequestApi and PasswordResetConfirmApi in the existing APIView style with nested InputSerializers, mounted at auth/password-reset/request/ and auth/password-reset/confirm/ under a password-reset namespace; the request endpoint always answers 200. Write authentication/tests/apis/test_password_reset.py covering the full flow with login after reset, an unknown email, a tampered token, a rejected password and an old JWT refused on me/. Run ruff check ., mypy --config mypy.ini styleguide_example/ and pytest, and paste the results in the pull request. Do not change the login endpoints or the Email model.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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
What comes back is a pull request that edits authentication/services.py, authentication/apis.py and authentication/urls.py, adds authentication/tests/apis/test_password_reset.py, and touches nothing in users or emails. The description lists the two URLs and their bodies, explains the always-200 request endpoint, and pastes the ruff, mypy and pytest output.
On a repository with the Django application workflow, the pull request builds the Docker image and runs ruff check, mypy and py.test inside it, then runs the same three against a Postgres service, so a missing type hint or a failing flow test shows in both jobs.
A reviewer checks that an unknown email leaks nothing, that the link uses BASE_FRONTEND_URL so the frontend owns the reset page, that jwt_key rotates on confirm, that the token lifetime is Django's PASSWORD_RESET_TIMEOUT and acceptable to them, and that the email text reads well. Then they add the frontend page at /reset-password/<uid>/<token>.
Run it on every Django project without a reset flow
A team with several Django REST Framework services sends one POST /o/{org}/sessions per repository with this prompt and that repository in resources. Each run reads its own user model and email path, so a project that sends mail directly gets send_mail instead of an Email row, and each run opens its own pull request with tests in that project's style.
Give the API key a webhook_url and Rush POSTs run.completed when each turn ends, with the session_url to read the pull request and the test output from.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A password reset is security code with a user-visible failure mode: a leaky request endpoint tells an attacker which accounts exist, and a confirm that forgets to invalidate old sessions leaves a stolen token working after the reset. In a Rush sandbox the agent runs the project's own pytest with the full flow, including a login with the new password and an old JWT refused, and keeps the output in the run's record, so the pull request shows those properties checked rather than asserted.
The change reuses what the project already has, Django's token generator, the Email model and its Celery task, the ApplicationError handler, so there is no new dependency and nothing for a reviewer to learn. The same request works on any Django REST Framework project with a custom user model.
Frequently asked questions
Why does the request endpoint return 200 for an unknown email?
So the response does not say whether an account exists. The service returns early for an unknown or inactive address and creates no Email row; the test for that case asserts both the 200 and the empty table.
Does the reset log the user out everywhere?
Yes for JWTs: password_reset_confirm calls auth_logout, which rotates jwt_key, the per-user secret JWT_GET_USER_SECRET_KEY signs tokens with, so every earlier token fails verification. Django sessions are invalidated by the password change itself through the session hash.
Is a new dependency added?
No. The token comes from django.contrib.auth.tokens.PasswordResetTokenGenerator, the uid from django.utils.http, validation from django.contrib.auth.password_validation, and the email goes through the project's emails app.
Where does the link point?
To BASE_FRONTEND_URL plus /reset-password/<uid>/<token>, the setting already used for CORS, so the frontend renders the form and posts to auth/password-reset/confirm/. Change the path in one place in password_reset_request if your frontend uses another route.
More Django REST Framework jobs
The same job on other stacks
- Add Password Reset to a Fastify API (Fastify)
- Add Password Reset to a Filament Admin Panel (Filament)
- Add a Password Reset Flow to a Symfony App (Symfony)