TanStack AI’s Sandbox API TanStack AI's Sandbox API lets developers drive Claude Code in a remote cloud sandbox to clone a GitHub repository, branch it, add a requested feature and open a pull request, according to a tutorial published on the Master.dev blog. The walkthrough configures a GitHub personal access token with read/write access to Contents and Pull requests, an Anthropic API key, and provider credentials for Vercel (VERCEL_TOKEN, VERCEL_TEAM_ID, VERCEL_PROJECT_ID) or Railway (project and environment IDs). The author positions the approach as a slower, paid alternative to pairing a laptop with a phone via tools like T3 and Codex, suited to occasional use when no always-on machine is available. TanStack AI is a fantastic SDK for integrating AI features into software. I’ve written about it here https://blog.master.dev/unlocking-ai-in-your-apps-with-tanstack-ai/ and here https://blog.master.dev/structured-output-with-tanstack-ai/ . Those posts covered basic prompt-based requests; we provided context and asked AI to generate some workouts for us. We went through streaming, persistence, and structured output. This post is about doing actual agentic work through TanStack AI, via their Sandbox API. Specifically, we’ll use TanStack AI to drive Claude Code in a remote sandbox, make changes to a GitHub repo, and open a pull request. Why would you want to do this? Sometimes you’re away from your computer with some downtime and nothing better to do than get a few tasks done. I want to be clear: this is already possible with tools like T3, Codex, etc. You can pair your laptop and your phone, and drive the former from the latter. But your laptop needs to be up and running for that to work. Ideally, you’d have a PC set up and always on, running a simple Linux distro, for this very purpose. But if you don’t have that set up, and don’t care to, what I’ll show you here is a decent next-best alternative. It won’t be nearly as fast, and you’ll have to pay a small amount to providers like Vercel or Railway to use the remote sandboxes. But as an occasional fill-in, it’s more than good enough in my opinion. I have a dirt-simple web app here https://github.com/arackaf/tanstack-ai-sandboxes-blog-post . It has pages for different programming languages, with brief descriptions of each. I also have some admin pages that let me add features by prompting Claude Code in a remote sandbox with GitHub access. The app has admin pages for Vercel and Railway, and both providers can clone our repo, branch, add the requested feature, and open a PR. Let’s take a look You’ll need a few tokens. We’ll use Claude Code in our sandbox and connect it to GitHub so we can clone the repo and create PRs. Let’s set up GitHub first. Go over to https://github.com/settings/personal-access-tokens https://github.com/settings/personal-access-tokens and generate a new token. Make sure you select either “All Repositories” or “Only select repositories” and select the repositories you want to provide access to . Then, for permissions, choose “Contents” and “Pull requests” with read/write access, and Metadata should auto-populate. Generate the token and copy it into this environment var: GH TOKEN="github pat abc xyz" Next, head over to the Anthropic console https://platform.claude.com/settings/keys , generate an API key, and copy it into a new env var: ANTHROPIC API KEY="sk-ant-xyz-abc" We’ll be running code in a cloud sandbox. TanStack AI supports a lot of different options https://tanstack.com/ai/latest/docs/sandbox/providers set-up-a-provider . We’ll cover Vercel and Railway here, but of course check the docs if you want to use something else. If you want to use Vercel, we’ll need three new env vars. First, head over to your account settings page, which you can access from the bottom left. Click that top section with your name and email, then click the tokens link in the left nav. Create your token, and add it into this env var: VERCEL TOKEN="vcp abc xyz" Next, go to your Vercel team in the top left, then click on Settings, and grab your team ID. Copy it into a new env var: VERCEL TEAM ID="team xyz" Lastly, create the Vercel project you want to associate with this work, click Settings, and copy the project ID. Then add it: VERCEL PROJECT ID="prj kBL24CmynuMNcclr4k5s55lqg2xf" If you want to use Railway, you’ll need two values. First, for the environment ID, go to the project settings page and click Environments . It should look something like this: It’s a little wonky, but look at the URL, and you should see something like this: ?environmentId=abcd-efgh-ijkl Grab that environmentId and put it in a new env var: RAILWAY ENVIRONMENT ID="abcd-efgh-ijkl" Then, hit the tokens link on the same page in the left navigation list, create yourself a token, and, as always, add it as a new env var: RAILWAY TOKEN="c0903fad-4336-4f0f-a0bf-3edc7abcfc51" If you’ve read my prior posts on TanStack AI, almost everything is the same. Persistence, resumability with a memory stream, etc., are all the same. The main difference is that, rather than routing our request through something like Vercel’s AI Gateway, we’ll provide a sandbox where the chat function can execute our request. That sandbox will have access to Claude Code and GitHub via the setup we did above . This allows it to clone our repo, do work, and open pull requests. We’ll review Vercel and Railway sandboxes, then put them to work. Here’s my code for creating a Vercel sandbox: js import { createSecrets, defineSandbox, defineWorkspace, githubRepo } from "@tanstack/ai-sandbox"; import { vercelSandbox } from "@tanstack/ai-sandbox-vercel"; export const sandboxVercel = defineSandbox { id: "repo-agent", provider: vercelSandbox {} , workspace: defineWorkspace { source: githubRepo { repo: "arackaf/tanstack-ai-sandboxes-blog-post" } , setup: "sudo npm install -g @anthropic-ai/claude-code", "sudo dnf install -y 'dnf-command config-manager '", "sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo", "sudo dnf install -y gh", "npm install", , secrets: createSecrets { ANTHROPIC API KEY: process.env.ANTHROPIC API KEY ?? "", GH TOKEN: process.env.GH TOKEN ?? "", } , instructions: "Accomplish the user's request and create a pull request. To publish work: run gh auth setup-git once, then git push -u origin