# Add an RSS Feed to a SvelteKit App

Yes. An agent adds an rss.xml server route to your SvelteKit app that lists the latest articles from the API the pages use, links it from the head and opens a PR.

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

## What the agent does

The agent starts from how the app gets its data. In a SvelteKit 2 app on Svelte 5 shaped like sveltejs/realworld, there is no database: src/lib/api.js wraps fetch against the RealWorld API with get, post, put and del helpers that add a Token header when one is passed, and src/routes/+page.server.js builds the home feed from articles or articles/feed with limit and offset from page_size in src/lib/constants.js, plus the tag list. The article page in src/routes/article/[slug]/+page.server.js turns each body from Markdown to HTML with marked and cleans it with sanitize-html. Those two files give the feed everything it needs: the list call and the exact rendering path the site already trusts for article bodies.

The feed is a server route. The agent adds src/routes/rss.xml/+server.js with a GET handler that calls the global articles endpoint with a fixed limit, no token, since a feed must not depend on a reader's cookie, and builds an RSS 2.0 document by hand: channel title, link from url.origin, description, and one item per article with title, a link to /article/ and the slug, a guid, pubDate from createdAt in RFC 822 form, the author's username, a category per entry of tagList, the description field as the summary, and the Markdown body rendered through the same marked and sanitize-html pair inside a content:encoded element. Every text value passes through an XML escaper, because article titles are user input. The response sets Content-Type to application/xml and a Cache-Control header with a public max-age, and the route exports prerender as false because its content comes from a live API at build time.

The head link is the other half. src/app.html is the shell: it already links a manifest and stylesheets, and the agent adds a link element with rel alternate, type application/rss+xml and href /rss.xml so browsers and readers discover the feed from any page. The home page in src/routes/+page.svelte already reads tab and tag from the query string, and the agent gives the feed route the same optional tag parameter, passing it to the API the way +page.server.js does, so /rss.xml?tag=svelte is a feed of one tag without a second route. static/robots.txt stays as it is.

This repository has no test runner, so proof is the build and the output. package.json has dev, build, preview and a lint script that is prettier --check with the svelte plugin, tabs and single quotes from .prettierrc; the package manager is pnpm 10.20.0 and .npmrc sets engine-strict with Node 20 in .nvmrc. The agent runs pnpm install with the frozen lockfile, pnpm run lint, pnpm run build with the Vercel adapter from svelte.config.js, then pnpm run preview and requests /rss.xml and /rss.xml?tag=svelte, checking the document parses as XML with xmllint and that each item link resolves to an article page the site renders. The raw feed output goes in the pull request.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add an RSS feed to this SvelteKit app. Read package.json, svelte.config.js, src/app.html, src/hooks.server.js, src/lib/api.js, src/lib/constants.js, src/routes/+page.server.js, src/routes/+page.svelte and src/routes/article/[slug]/+page.server.js first. Add src/routes/rss.xml/+server.js with a GET handler that fetches the latest global articles through the existing api helper with no token, supports an optional tag query parameter the way the home page does, and returns RSS 2.0 with title, link, guid, pubDate, author, categories from tagList, description, and the body rendered with marked and sanitize-html in content:encoded, escaping every text value. Set Content-Type application/xml and a Cache-Control header, and export prerender false. Add a rel alternate link to the feed in src/app.html. Run pnpm install --frozen-lockfile, pnpm run lint, pnpm run build and pnpm run preview, request /rss.xml and /rss.xml?tag=svelte, check both parse with xmllint, and open a pull request that explains the choices and quotes the first item of the feed and the lint and build output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

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

What comes back is a pull request on its own branch that adds src/routes/rss.xml/+server.js and one link element in src/app.html. No dependency is added: marked and sanitize-html are already in package.json because the article page uses them, and the XML escaper is a few lines in the route. The description explains the fixed item limit, the tag parameter, the cache header and why the feed ignores the reader's session.

The session read names the repository and the pull request URL. The transcript at GET /o/{org}/sessions/{id}/messages keeps the files the agent read, the pnpm install, lint and build output, the preview server start, and the two curl requests with the feed documents they returned and the xmllint result, so a reviewer can read the first item without running anything.

Before merging, a reviewer pastes the preview feed into a reader or validator, checks that pubDate values are in the RFC 822 form readers expect rather than ISO strings, that titles with ampersands or angle brackets are escaped, and that the rel alternate link shows up in the rendered head of the home page.

## Run it on every feed request

Send this request once per site that should publish a feed, with the repository in resources and a request_id per site so a retried call returns the run already started. Each run gets its own sandbox and its own preview server, so several sites can gain a feed at once. The sandbox parks with the branch and the built output when the turn ends, so a follow-up asking for an Atom version or a per-author feed wakes it where it left off.

Give the key a webhook URL and Rush POSTs run.completed or run.failed with data.session_url when each turn finishes, for the runs that key started. A key runs at most max_concurrent sessions at once, 4 by default, and a feed request past that answers 202 with status "queued" and starts when one of the key's sandboxes ends or parks.

## Why run it on Rush?

A feed that was never fetched is usually wrong in a small way: an unescaped ampersand, a date in the wrong format, a link without the origin. Finding those means building, previewing, requesting the route and parsing the XML, against a live API. The agent does that in its own sandbox with the project's pinned pnpm and Node, and the feed document it fetched is in the transcript.

The record is the proof. Every command and its output, the raw feed, and the xmllint result sit on the session beside the diff, so a reviewer who did not watch can judge the result without a checkout. The result is a branch and a pull request; nothing lands on the default branch without a person.

## Frequently asked questions

### Does the feed show the reader's personal feed?

No. Feed readers do not carry the site's jwt cookie, and a cached response must be the same for everyone, so the route calls the global articles endpoint with no token. The optional tag parameter narrows it the way the home page's tag filter does.

### Why is the route not prerendered?

The articles come from a live API, so a feed rendered at build time would freeze at the moment of the build. The route exports prerender as false and sets a Cache-Control header instead, so the Vercel adapter serves it as a function and caches responses for the max-age it declares.

### Will it add a dependency?

No. The body rendering reuses marked and sanitize-html from the article page, the date and escaping are a few lines in the route, and SvelteKit's +server.js convention needs nothing extra. package.json and pnpm-lock.yaml are unchanged.

### How is it tested when the repository has no test runner?

By building and fetching. The agent runs the lint and build scripts, starts the preview server, requests /rss.xml and the tag variant, parses both with xmllint and quotes the first item in the pull request. A follow-up can add a Vitest case if your fork has one.

## More SvelteKit jobs

- [Add Security Headers to a SvelteKit App](https://getrush.ai/run/add-security-headers/sveltekit/)
- [Add a Sitemap to a SvelteKit App](https://getrush.ai/run/add-sitemap/sveltekit/)
- [Add Structured Data (JSON-LD) to a SvelteKit App](https://getrush.ai/run/add-structured-data/sveltekit/)

## The same job on other stacks

- [Add an RSS Feed to a Wagtail Blog](https://getrush.ai/run/add-rss-feed/wagtail/)
- [Add an RSS Feed to a Contentlayer Blog](https://getrush.ai/run/add-rss-feed/contentlayer/)
- [Add an RSS Feed to a Starlight Docs Site](https://getrush.ai/run/add-rss-feed/starlight/)

## 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/)
