Cloud GPU instances with Jupyter kernels for AI/ML workloads

Cloud GPU machines with Jupyter kernels for AI/ML workloads — on RunPod, vast.ai, or Kubernetes.
This plugin decouples the agent from the execution environment, in the same spirit as Anthropic's managed agents architecture: Claude and your session stay on your machine (the "brain"), while cloud GPUs are interchangeable "hands" it attaches, uses, and discards. Running Claude Code inside a cloud container couples the two outright; piping SSH commands at a long-lived dev box decouples them only awkwardly. Doing it properly buys:
.ipynb notebook per kernel. A later session reconnects and picks up where it left off; the machine itself is safe to lose.Three runtimes, one interface — RunPod (managed pods, reliable stop/resume), vast.ai (cheapest marketplace GPUs — Claude can search offers and pick hosts, or take the cheapest qualifying automatically; VM mode runs Docker inside, e.g. for UK AISI Inspect's sandboxed evals), and Kubernetes (lab clusters: pods from a lab-owned template, Kueue queue/priority aware). Configure via remote-kernels.toml; switch per machine with start(runtime=...).
Multiple concurrent machines — Every start() provisions a fresh machine with a unique id. A restarted server picks its own session's running machines back up automatically; resuming a stopped machine or adopting another session's is an explicit attach(machine_id), with kernel state and output recovered across sessions. Machines start in parallel, each with its own kernels, and kernel calls route automatically — no instance bookkeeping.
Jupyter kernel execution — Run code on remote GPUs through persistent Jupyter kernels. Claude can execute cells, inspect outputs (plots included, as images), and iterate — all within the conversation. Kernel activity is saved as .ipynb files.
File sync — Sync local project files to a machine (.gitignore-aware) and download results back, both rooted at the project directory.
Budget controls — Set a spending limit once and each Claude session gets its own cap, covering all the machines that session pays for — including storage that keeps billing on stopped ones. On exhaustion, that session's machines get a grace window to save their work before being stopped or terminated — enforced on the machine itself, so it holds even if your laptop dies.
Automatic cleanup — When a session disconnects (background sessions, closed laptops, crashes), the machine waits for its running work, runs your configured command to save results, and then cleans itself up the way you chose: stop, terminate, or leave it running. If saving fails, the machine is kept rather than deleted. A later session reattaches and picks up where you left off.
RUNPOD_API_KEY and/or VAST_API_KEY (a plain console key; vast accounts with 2FA enabled reject API writes — the setup skill explains the options, disabling 2FA being the supported one), or a kubeconfig for Kubernetes.setup skill to configure interactively.hooks/register.tsx 62 lines1// remote-kernels as a mod: scripts/check.sh's rows (wrong platform variant, not configured) in the
2// band above the prompt, checked at startup and /clear; a row's button runs /remote-kernels:setup.
3import { atom, read, update } from 'claude-code'
4import type { EngineInterface, Register } from 'claude-code'
5
6import { noticeRows } from './notice-band'
7import type { Notice, NoticeAction } from './notice-band'
8
9const PLUGIN = 'remote-kernels'
10const notices = atom({ plugin: 'remote-kernels', key: 'notices' } as const, [] as Notice[])
11// Rows dismissed this session; the script itself shows `updated` once per binary version.
12const dismissed = atom({ plugin: 'remote-kernels', key: 'dismissed' } as const, [] as string[])
13
14/** Runs the plugin's session-start check and keeps its rows; none when it fails. */
15async function check($: EngineInterface, projectDir: string): Promise<void> {
16 try {
17 const { exitCode, stdout } = await $.process.run(['bash', `${$.plugin.root}/scripts/check.sh`], {
18 env: { CLAUDE_PLUGIN_ROOT: $.plugin.root, CLAUDE_PROJECT_DIR: projectDir },
19 })
20 const found = exitCode === 0 && stdout.trim() ? (JSON.parse(stdout) as { notices: Notice[] }).notices : []
21 await update($, notices, () => found)
22 } catch {
23 // A check that fails shows nothing rather than a wrong row.
24 }
25}
26
27export const register: Register = on => {
28 // The SessionStart hook's lifecycle: startup and /clear, awaited.
29 on('classic.SessionStart', async ($, e, next) => {
30 if (e.source === 'startup' || e.source === 'clear') await check($, e.cwd)
31 return next(e)
32 })
33
34 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
35 const [below, found, hidden] = await Promise.all([next(e), read($, notices), read($, dismissed)])
36 if (e.props.hasSurvey) return below
37
38 const rows = (found as Notice[]).filter(notice => !hidden.includes(notice.id))
39 if (rows.length === 0) return below
40
41 const onAction = async (notice: Notice, action: NoticeAction) => {
42 // Running setup dismisses the row for this session; the next session's check
43 // decides whether it comes back.
44 await update($, dismissed, list => [...list, notice.id])
45 if (action.kind === 'command' && action.command) {
46 await $.command.run({ command: action.command.slice(1) }).catch(() => $.ui.toast(`Could not run ${action.command}`))
47 }
48 }
49 const onDismiss = (notice: Notice) => update($, dismissed, list => [...list, notice.id])
50
51 const ui = $.ui.resolve(e)
52 const drawn = noticeRows(ui, PLUGIN, rows, { onAction, onDismiss })
53
54 return (
55 <ui.Box flexDirection="column">
56 {drawn}
57 {below}
58 </ui.Box>
59 )
60 })
61}
62hooks/notice-band.tsx 92 lines1// One plugin's rows in the band above the prompt, drawn without `$`: each
2// plugin's own `ui.render` hook reads its state and stacks this over what the
3// plugins beneath drew, so third-party plugins on the band keep working.
4//
5// A plugin cannot import another's files, so each plugin that shows notices
6// carries this file; plugins/notice-band.test.ts keeps the copies identical.
7// The `notices` its check prints are this file's `Notice` as JSON.
8import type { EngineInterface, RenderElement } from 'claude-code'
9
10export type Severity = 'urgent' | 'problem' | 'action' | 'info'
11
12export type NoticeAction = {
13 id: string
14 label: string
15 // command: a slash command; copy: `command` goes on the clipboard, for a
16 // terminal command that is interactive; plugin: the plugin's own handler decides.
17 kind: 'command' | 'copy' | 'plugin'
18 command?: string
19}
20
21export type Notice = {
22 id: string
23 severity: Severity
24 // The whole message: rows wrap rather than hide what the person needs to act.
25 text: string
26 actions?: NoticeAction[]
27 // Set on "updated" notices: a dismissal holds until the plugin's next
28 // version. Without it, a dismissal holds for this session only.
29 version?: string
30 // What a pressed button is doing ("restarting…"): drawn after the text in
31 // place of the buttons, so the row never looks inert. Set by the plugin.
32 busy?: string
33}
34
35export type NoticeHandlers = {
36 onAction: (notice: Notice, action: NoticeAction) => unknown
37 onDismiss: (notice: Notice) => unknown
38}
39
40const MARK: Record<Severity, { rank: number; glyph: string; color: string }> = {
41 urgent: { rank: 0, glyph: '✖', color: 'error' },
42 problem: { rank: 1, glyph: '!', color: 'warning' },
43 action: { rank: 2, glyph: '›', color: 'suggestion' },
44 info: { rank: 3, glyph: '↑', color: 'ide' },
45}
46
47/** Draws `notices` as band rows, most severe first, each keyed and labeled by `plugin`. */
48export function noticeRows(
49 ui: ReturnType<EngineInterface['ui']['resolve']>,
50 plugin: string,
51 notices: Notice[],
52 { onAction, onDismiss }: NoticeHandlers,
53): RenderElement[] {
54 const { Box, Button, Text } = ui
55
56 return [...notices]
57 .sort((a, b) => MARK[a.severity].rank - MARK[b.severity].rank)
58 .map(notice => {
59 const mark = MARK[notice.severity]
60 const key = `${plugin}:${notice.id}`
61
62 const buttons = (notice.busy ? [] : (notice.actions ?? [])).map((action, index) => (
63 <Button
64 key={`${key}:${action.id}`}
65 label={action.label}
66 variant={index === 0 ? 'primary' : 'secondary'}
67 onPress={() => onAction(notice, action)}
68 />
69 ))
70 // An info row is a state, not a request: the band's own collapse hides it.
71 if (notice.severity !== 'info' && !notice.busy) {
72 buttons.push(<Button key={`${key}:dismiss`} label="Dismiss" dimColor onPress={() => onDismiss(notice)} />)
73 }
74
75 // The buttons wrap under the text where the row does not fit.
76 return (
77 <Box key={key} flexDirection="row" flexWrap="wrap" justifyContent="space-between" columnGap={2}>
78 <Text>
79 <Text color={mark.color} weight="semibold">
80 {mark.glyph}{' '}
81 </Text>
82 <Text weight="semibold">{plugin}</Text> {notice.busy ? `${notice.text} · ${notice.busy}` : notice.text}
83 </Text>
84 {/* Grows to fill its line, so the buttons stay right-aligned when they wrap. */}
85 <Box flexDirection="row" flexGrow={1} justifyContent="flex-end" columnGap={1}>
86 {buttons}
87 </Box>
88 </Box>
89 )
90 })
91}
92types/index.d.ts 7 lines1declare module 'claude-code' {
2 interface PluginState {
3 // `notices`: the check's rows, hooks/notice-band.tsx's Notice as parsed JSON.
4 'remote-kernels': { notices: unknown[]; dismissed: string[] }
5 }
6}
7