What the agent does
The agent reads how posts are defined and listed before it writes the feed. In a Next.js site laid out like shadcn-ui/taxonomy, contentlayer.config.js defines a Post type for blog/**/*.mdx with a required title, date and image, an optional description, a published flag that defaults to true and an authors list of strings, plus computed slug (/blog/<file>) and slugAsParams fields. app/(marketing)/blog/page.tsx reads allPosts from contentlayer/generated, filters on published and sorts with compareDesc on date; the post page builds its Open Graph image through /api/og and its canonical URL with absoluteUrl from lib/utils.ts, which prefixes env.NEXT_PUBLIC_APP_URL. config/site.ts holds the site's name, description and url, and app/robots.ts already answers a metadata route with a plain object. The project runs on Next 13.3, Contentlayer 0.3 through next-contentlayer, and pnpm.
It adds the feed as a route handler, the same shape app/api/posts/route.ts already uses: app/feed.xml/route.ts exports a GET that builds an RSS 2.0 document from the same filtered and sorted list the blog page shows, so the two can never disagree about what is published. Each item carries the post's title, its description when there is one, a link and guid from absoluteUrl(post.slug), a pubDate from the post's date in RFC 822 form, and one author line per name in authors, matched against allAuthors for the display name where one exists. The channel takes the site's name, description and url from config/site.ts. Every value goes through an escaper for the five XML characters, because a title with an ampersand is the first thing that breaks a feed, and the response sets Content-Type: application/rss+xml; charset=utf-8.
Then it makes the feed discoverable. app/layout.tsx exports a metadata object with a title template and Open Graph fields; the agent adds alternates.types with the application/rss+xml link to /feed.xml, which Next renders as the <link rel="alternate"> tag feed readers look for, and adds a small RSS icon link beside the blog heading. It does not touch robots.ts, since feeds are meant to be crawled.
The repository has no test runner, so the agent proves the route against a build. It runs pnpm build, which runs contentlayer build and then next build, starts the site, fetches /feed.xml, and checks it with a strict XML parser; it installs libxml2-utils in its sandbox if xmllint is not there. It also checks that the item count equals the number of posts with published: true, that the newest post is first, and that each link resolves on the running site, and keeps all of that output for the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add an RSS feed for the blog. Read contentlayer.config.js, app/(marketing)/blog/page.tsx, app/(marketing)/blog/[...slug]/page.tsx, lib/utils.ts, config/site.ts, app/layout.tsx, app/robots.ts and app/api/posts/route.ts first. Add app/feed.xml/route.ts with a GET handler that builds an RSS 2.0 document from allPosts, using the same published filter and date sort as the blog page, with title, description, link and guid from absoluteUrl(post.slug), pubDate in RFC 822 form, and one author per entry in authors; escape every XML special character and serve it as application/rss+xml. Add the feed to the root metadata's alternates.types so the alternate link tag is rendered, and a link to it from the blog index. Run pnpm build, start the site, fetch /feed.xml, validate it with xmllint, check the item count against the published posts and that each link resolves, and open a pull request with that output.",
"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 adds app/feed.xml/route.ts, changes app/layout.tsx and the blog index, and nothing else. The description shows the generated feed's channel and first item, the xmllint result, the item count against the published post count and the link checks from the agent's run.
The run's record keeps the build output and every fetch, so a reviewer can read the raw XML the route returned rather than a description of it. A reviewer checks the escaping on a post title with punctuation, confirms the date in pubDate matches the post's front matter, and opens the feed in a reader once the preview deploy exists.
Run it on every site that publishes posts
A company with several Next.js sites on Contentlayer starts one run per repository with one POST /o/{org}/sessions each, this prompt as input and the repository in resources. Each run reads its own document types, so a site whose posts live under a different path or carry a different date field gets a feed built from that, and a site that already has a feed gets a description saying so and no pull request.
Send a request_id that is a UUID v5 of the repository's full name so a retried call returns the run it already started. The key's webhook_url reports when each run finishes, with session_url to read the pull request from.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A feed is forty lines of code and one escaping bug away from being silently broken, and nobody notices until a reader reports that the last six posts never arrived. The useful part of the job is building the feed from exactly the list the site already renders and then proving the output parses, has every published post, and links where it says. The agent does that against a real build in its sandbox and keeps the fetched XML as evidence.
The pull request is one route and two small edits, so review is reading the escaper and one item. A company with several content sites runs them all at once, each in its own sandbox with its own pull request.
Frequently asked questions
Why a route handler and not a file generated at build time?
Because the project already serves computed documents from route handlers and a build-time file would need a second script and a place to write it. The handler reads allPosts, which Contentlayer generates at build, so the response is the same for every request and Next can serve it statically.
Does the feed include the full post body?
Not in this pull request. It carries the description, which is what the blog index shows. Contentlayer exposes the post's raw and compiled body, so a later run can add a content:encoded element with the rendered HTML; the agent notes in the description what that needs, mainly absolute image URLs.
What about drafts?
The feed uses the same published filter as the blog page, so a post with published: false is left out of both. The agent's check compares the item count with the number of published posts so a filter mismatch would fail the run.
Will it work on a site without NEXT_PUBLIC_APP_URL?
No, and neither does the existing Open Graph markup, which uses the same absoluteUrl helper. The environment schema in env.mjs already requires it, so a missing value fails the build before the feed is reached.
The same job on other stacks
- Add an RSS Feed to a Starlight Docs Site (Starlight)
- Add an RSS Feed to a SvelteKit App (SvelteKit)
- Add an RSS Feed to a Wagtail Blog (Wagtail)