What the agent does
The agent reads how the blog is built and what its pages already say about themselves. In a blog laid out like gatsbyjs/gatsby-starter-blog, posts are Markdown files at content/blog/<slug>/index.md with title, date and description in their frontmatter, gatsby-node.js gives each one a slug field with createFilePath and creates a page from src/templates/blog-post.js, and gatsby-config.js sets siteMetadata.siteUrl, the author's name and a social.twitter handle. src/components/seo.js writes og:title, og:description, og:type and twitter:card set to summary, but no og:image and no og:url, and its static query does not ask for siteUrl. So a shared link shows text and no picture.
Generating the images needs no new plugin. gatsby-plugin-sharp and gatsby-transformer-sharp are already in package.json, which means sharp is installed; the agent adds it as a direct dependency so npm ci keeps it on purpose rather than by accident. In gatsby-node.js it adds an onPostBuild that queries every MarkdownRemark node for its title and slug, renders a card for each as SVG text over a plain background with the post title, the site title and the author from siteMetadata, and rasterizes it with sharp to public/og/<slug>.png. Writing into public after the build is the same pattern gatsby-plugin-feed uses for rss.xml, so the files are served like any other static output.
The tags come next. seo.js gains an image prop and asks its query for siteUrl; when an image is given it writes og:image as an absolute URL, since crawlers do not resolve relative ones, plus og:url and twitter:card as summary_large_image, and without one it keeps summary. The Head export in blog-post.js passes /og/<slug>.png for its post, and src/pages/index.js gets a default card made from the same template with the site title alone. Because the card is drawn with SVG text, the font that renders it is whichever the build machine has; the agent uses a generic family, says so in the pull request, and names embedding a font file as the next step if the team wants the cards to match the site's Merriweather and Montserrat.
In its sandbox the agent runs npm ci and gatsby build, lists public/og/ to show one PNG per post plus the default, and reads the built public/hello-world/index.html to quote the og:image and twitter:card tags with the absolute URL. It opens one card to check the title fits at the longest title in content/blog, and attaches that PNG to the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add social card images to this Gatsby blog. Read gatsby-config.js, gatsby-node.js, src/components/seo.js, src/templates/blog-post.js, src/pages/index.js and package.json first. In gatsby-node.js add an onPostBuild that renders one PNG per Markdown post into public/og/<slug>.png with sharp, drawing the post title, the site title and the author from siteMetadata, plus a default card for the index page. Add sharp as a direct dependency. Give the Seo component an image prop, add siteUrl to its query, and emit og:image as an absolute URL, og:url and twitter:card summary_large_image when an image is given. Pass the post's card from the blog-post Head export and the default from the index page. Run npm ci and gatsby build, list public/og, quote the meta tags from a built post page, and attach one card. Open a pull request.",
"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 changing gatsby-node.js, src/components/seo.js, src/templates/blog-post.js, src/pages/index.js, package.json and package-lock.json. No post is touched and no plugin is added. The description quotes the og:image, og:url and twitter:card tags from a built post page with the absolute URL built from siteUrl, lists the files under public/og/ after the build, and shows one generated card.
The run's record keeps the gatsby build output and the listing, so a reviewer can confirm the images were written during the build rather than committed, and that the index page still carries summary with its default card rather than the large-image card without a picture to show.
Before merging, a reviewer looks at the attached card for the design, checks siteUrl in gatsby-config.js is the production domain, since the tags are only as right as that value, and decides whether to embed a font so the cards match the site.
Run it on every Linear issue labelled agent
Add an automation in the Project with this prompt and a linear trigger on linear.issue.labeled, filtered to the agent label. When someone files "shared links show no preview image" and labels it, the trigger puts the issue after the prompt and starts a run in the blog's repository; the pull request links back to the issue. Only label changes made by a person in your Rush org fire it, never changes made by an app integration.
The same body can be sent from a script with POST /o/{org}/sessions, with the issue's URL in resources beside the repository so the agent reads it through your Linear connection. Send a request_id, a UUID, so a retried call returns the run it already started.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Social cards are a build-time feature that touches four files and one dependency, and the usual way to get them wrong is a relative og:image URL or an image that is generated on a laptop and never in CI. The agent builds the site in its own sandbox, reads the tags out of the built HTML, and attaches a card, so what the pull request claims is what a crawler would fetch.
The build output stays with the run and the pull request quotes it, so the reviewer checks a tag and a picture rather than a diff of code that might work. The same request runs against every Gatsby site a team keeps, in parallel, each reading its own siteMetadata and its own posts.
Frequently asked questions
Why not a Gatsby plugin for Open Graph images?
Because sharp is already installed through gatsby-plugin-sharp, and an onPostBuild in gatsby-node.js is a few dozen lines the team can read and change. A plugin would add a dependency and its own options for the same result.
Why must og:image be absolute?
Crawlers for Twitter, Slack and others fetch the image URL as written and most do not resolve a path against the page. The component builds it from siteMetadata.siteUrl, which is why the query in seo.js now asks for that field.
Will the cards use the site's fonts?
Not by default. The card is SVG text rasterized by sharp, which uses the fonts on the machine that runs the build. The agent picks a generic family so the output is stable, and the pull request names embedding a font file as the follow-up if the look matters.
Are the PNGs committed?
No. They are written into public/og/ during gatsby build, the same way the RSS feed is written, so a new post gets its card on the next build with nothing to commit.