/boxel-skills:source-code-editingfrom boxel-skills
Use the run-realm-code tool to create and edit source files in a Boxel realm.
Ships in boxel-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use the run-realm-code tool for every source-file creation or edit. Do not emit file edits as prose. The tool executes JavaScript in the isolated realm runner. Each realm.fs call goes to the host, which reads files in the given realm and saves each write before the call returns.
The script runs in a small QuickJS sandbox, not in Node.js or a browser. The script is the body of an async function, so you can use await and return at the top level. The only globals that the sandbox adds are realm and room. Never declare a variable named realm or room: it hides the API, and the next realm.fs… call fails with cannot read property … of undefined; name a URL catalogUrl or workspaceUrl instead; the standard JavaScript built-ins (JSON, Math, Date, RegExp, Promise, and so on) also work. There is no console, print, nodeRepl, process, require, import, fetch, setTimeout, DOM or Node API. A call to one of these stops the script with a ReferenceError. The tool result shows only the value that the script returns, as JSON, and nothing else. To see a value, return it, for example return { files: await realm.fs.list() };. A script that does not return a value gives a result with no value.
Before editing, read the current contents of every target file with await realm.fs.readText(path) in the script. To see what a folder holds, call await realm.fs.list(path); with no path it lists the realm root. It returns one { name, path, kind } entry for each file and folder directly in that folder, where kind is 'file' or 'directory' and path is relative to the realm root (a folder's path ends with /). To read a card instance as data, call await realm.cards.get(path), where path is the instance with or without .json (Person/sample). It returns { id, path, type, attributes, relationships }: type is { module, name } of the card's definition, attributes holds the field values, computed fields included, and relationships maps each link's field path to the linked card's URL (field.0, field.1, … for a linksToMany field). Every URL is absolute. It reads the indexed card, so a card you just wrote can take a moment to index. While the workspace is indexing, it fails with Card is not indexed yet, and you read it again; if a few reads later it is still not indexed, index the file as below. When it fails with Card is not indexed and says the workspace is not indexing, no index pass is coming for that file and reading it again will not find it: index the file with realm.index.invalidate and the .json path the error names (realm.index.invalidate('Person/sample.json')), then read the card again. Never edit a card's data (a summary, a title, any field) to make the workspace index it: that changes the user's card, and realm.index.invalidate indexes the file without a change. A card whose index entry is an error fails with Card failed to index and the error's text; reading it again gives the same error, so fix the cause in the card's file, the definition it adopts from or a card it links to. It also fails for a card that is not found, and with Not a card for a path that names a file rather than a card instance. To read or list without writing, return the result from the script, for example return await realm.fs.readText('person.gts');, and read it in the tool result. Pass the workspace realm URL and room ID supplied by the host. Use await realm.fs.replace(path, exactCurrentText, replacement) for an existing file. Use await realm.fs.writeText(path, content) for a new file; it refuses a file that already exists. To duplicate a file, call await realm.fs.copy(fromPath, toPath). Both paths are in the run's realm. It refuses a toPath that already exists and a binary file, and it needs write access. It copies the content as it is: relative imports, adoptsFrom modules and card links are not changed, so they stay correct only when the copy is at the same folder depth as the original. To change the copy, call realm.fs.replace on toPath in the same script. To copy a file to another realm, use two runs: read it with realm.fs.readText in a run in the source realm, then write it with realm.fs.writeText in a run in the target realm, with each relative module and link path changed to an absolute URL in the source realm. path is relative to the realm root, such as person.gts; a full file URL inside the realm also works. File content often contains backticks and ${, for example a BXL fx expression or a template string in a computed field. If you put such content inside a JavaScript template literal, escape each backslash in it as \\ first, then each backtick as \` and each ${ as \${. Without this, the script does not parse, or it saves different text without an error: /\d+/ becomes /d+/, and ${name} is replaced with a value. Escape the exactCurrentText argument of realm.fs.replace the same way, or it does not match the file. Use await realm.fs.writeBytes(path, base64) for a new binary file, such as an image: base64 is the file's bytes as a base64 string, or a data: URL with base64 content. It refuses a file that already exists, a file larger than 2,000,000 bytes, and more than 5,000,000 bytes in one call. readText and replace refuse a binary file. Use await realm.fs.delete(path) to delete a file: one that this run created, such as a file the script wrote by mistake, or one that was there before the run, such as a file an earlier run wrote by mistake. It returns { path, deleted: true }, the tool result lists the file with the status deleted, and the file does not exist. A delete cannot be undone, so delete only a file that you are sure is wrong, and tell the user which file you delete and why. First read a text file with realm.fs.readText in the same script: if someone changes the file after that read, the delete is refused with File changed while the script ran and the file stays. It refuses a folder and a file that does not exist. Write the call exactly as realm.fs.delete(...) in the script. A run whose code contains that text always waits for the user to approve it, also in act mode. A run that gets to the delete in a different way is refused. After the delete, the same script can write the path again with writeText or writeBytes; the tool result then lists the file as saved. A path counts once toward the 20-file limit, however many calls use it, so a delete and a new write to the same path count as one file. To fix a file instead of deleting it, change its content with realm.fs.replace. To move a file, copy it to the new path with realm.fs.copy and delete the old one with realm.fs.delete. Use await realm.fs.exists(path) to check whether a file exists. Await every call. Write all files of a build in one call, within the limits of one call: at most 20 files (each file path given to readText, exists, replace, writeText, copy, writeBytes, delete, images.generate or download counts; list and cards.get do not; a path counts once, however many calls use it, and each image counts once, as the path it is saved at), a script of at most 100,000 characters, and 55 seconds. Split a larger build across calls. To show the user a card when the run ends, return { show: path } with the instance path, for example return { show: 'Pet/mango' };, from the call that writes it; there is no separate call to show it. The host opens it after it checks that the card is an instance in this realm; if it cannot, the result's showError says why and the files stay saved. A .gts or .ts write with lint errors that autofix cannot repair is refused, and the script stops there. Each write is saved when its call returns, so if the script fails partway, the files written before the failure stay saved; the error names them. The error names in separate lists the files that the run created and then deleted before the failure, and the files from before the run that it deleted; those files do not exist. To fix a file the failed run saved, change it with realm.fs.replace in the next run, or delete it with realm.fs.delete.
To find cards in the realm, call await realm.cards.search(query). query is a card query: a filter built from on/type, eq, contains, range, in, any, every, not and full-text matches, an optional sort, and an optional page ({ size, number }, where number starts at 0). The query syntax is in boxel-environment/references/searching-and-querying.md. It answers { cards, total, truncated }. Each card is { id, path, type, attributes, relationships }: id is the card's URL; path is its .json file relative to the realm root, which realm.cards.update and realm.fs.readText take; type is { module, name } with a full module URL, so you can pass it back as a query's type or on; relationships maps each link field's path to the URL of the card it links to; a linksToMany field's links are keyed field.0, field.1, and so on. The data comes from the realm's index, not from the file: attributes include computed fields, and a card saved a moment ago can still show its old values. To change a card, pass only the fields you change to realm.cards.update, never all of attributes back. A card that failed to index is not in the results. A page holds page.size cards, 50 when the query names none, and never more than 100; truncated is true while more cards match past this page, so ask for the next page.number until it is false. A page too large to return fails with the page.size that fits. A search searches only the realm the script runs in; to search another realm, run another script in that realm. A search does not count toward the 20-file limit.
To change field values of a card instance, call await realm.cards.update(path, attributes). path is the instance with or without .json (Recipe/pasta), or card.path from a search. attributes holds only the fields you change, as plain JSON: a nested object merges into the field's current value, and an array or any other value replaces it. It changes attributes only, not links; to change a link, edit the .json with realm.fs.replace. Use it instead of realm.fs.replace for every change to an instance's field values, because it needs no JSON escaping and no exact search text. It returns { path, fields, saves }. Nothing is saved while the script runs: when the script finishes, the host saves every update in one request, all or none. If the script fails, or a card changed while the script ran, no update is saved. In the same run, realm.fs cannot read or change a card that has an update waiting, and realm.cards.get returns the card without the update. A run updates at most 200 cards, and they do not count toward the 20-file limit; more calls on one card count once. To change many cards, search, update and report in one script:
const updated = [];
let more = true;
for (let number = 0; more && updated.length < 200; number++) {
const { cards, truncated } = await realm.cards.search({
filter: { on: { module: realm.current.url + 'recipe', name: 'Recipe' }, eq: { cuisine: 'unknown' } },
page: { size: 100, number },
});
const room = 200 - updated.length;
for (const card of cards.slice(0, room)) {
await realm.cards.update(card.path, { cuisine: 'Italian' });
updated.push(card.path);
}
more = truncated || cards.length > room;
}
return { updated, more };
Page inside this one script, as above, until truncated is false or the run reaches 200 updates. The index does not change while the script runs, because nothing is saved until it ends, so each page continues where the last one stopped. Run the script again only when it returns more: true. A later run starts again at page.number: 0 when the filter selects on a field the script changes, as cuisine above: the cards the first run saved no longer match, so the next page.number would skip cards that still need the change. When the filter does not select on a changed field, the later run starts at the next page.number instead (2 after a run of 200 cards). A card the realm has not reindexed yet can match again; updating it again changes nothing.
Return only what you need from a search, such as the paths or a few attributes; the whole result goes into the tool result.
To reshape JSON the script holds, call await realm.transform(input, program, { params, spelling }) instead of writing the loop in JavaScript. Reshaping means filtering, grouping, summing, sorting, renaming or picking fields across a list of more than a few dozen items; picking a field from a handful of search results is a plain map in the script. The JSON can be an API response from realm.operations.invoke, a JSON file read with realm.fs.readText and JSON.parse, or the cards a search found. program is a BXL expression. It runs over input in a worker beside the script, at full JavaScript speed, while the script's own loops run in QuickJS, which interprets each step slowly and spends the run's 55 seconds doing it. The call returns the value the program produces, as plain JSON. The program reads only input and params: it cannot read a file, a card or the network, so read the data first, transform it, then write the result with realm.cards.update or realm.fs. Keep the data in the script: to learn its shape, return its size and one item, never the whole of it, since a returned value goes into the conversation and every later turn pays for it again:
const { orders } = JSON.parse(await realm.fs.readText('api/orders.json'));
const byCategory = await realm.transform(
orders,
'map(select(.status == params("status"))) | [.[].lines[]] | group_by(.category) | map({category: .[0].category, units: map(.qty) | add, revenue: ROUND(map(.qty * .price) | add; 2)}) | sort_by(-.revenue)',
{ params: { status: 'paid' } },
);
return byCategory;
jq, is jq with the Excel functions (ROUND, SUM, IF, TEXT, …) callable by name, their arguments separated by ;. A , between them makes two values in jq, so ROUND(.price * .qty, 2) fails with BXL evaluation exceeded the 1 output runtime limit; write ROUND(.price * .qty; 2). Inside a JavaScript string, write jq's string interpolation with a doubled backslash, "\\(.name)": a single one is dropped without an error, and the program returns the text (.name). spelling: 'readable' takes readable BXL, the formula spelling bxl-authoring describes: a PascalCase label reads the input's camelCase key (UnitPrice reads .unitPrice), = compares, and , separates arguments (ROUND(UnitPrice * Quantity, 2)). Use readable for a formula over one object's fields, and jq to map over, filter or group an array.params("name") reads the value named name from params, an object of named values. Pass a value from the script that way, never by putting it into the program text..[] produces one per item and fails with BXL evaluation exceeded the 1 output runtime limit, so collect them, [.[] | …], or use map(…). A program that produces no value, such as a select on one object that doesn't match, fails with a transform produces one value, and this program produced 0. Filter with map(select(…)); empty is refused.reduce and foreach (transform-loop-banned: use map, group_by, add or SUM), def helpers (transform-def-banned), try/catch and the ? operator, .a? included (transform-try-banned: write a fallback with //, as in .a // 0), recursive descent .. (transform-recursive-descent-banned), assignment such as |=, += and the jq = (transform-assignment-banned), label/break (transform-control-flow-banned), format filters such as @csv and @base64 (transform-format-banned), and the calls that read the runtime or have a side effect, such as input, input_filename, debug, env, error, halt, stderr and builtins, and empty (transform-call-banned), and the mutation-plan context roots @User, @Env, $new, $old and Record (transform-context-banned: a program reads only its input and params). The error starts realm.transform: the program uses what a transform may not and names each code. A program that does not parse fails with realm.transform: the program does not parse, and one that fails on its input fails with realm.transform: the program failed, the reason, and the input's top-level shape (The input is an object with keys "orders" (an array of 420 items), "page_info" (an object).), which shows when the program was handed the response rather than the array inside it. Fix the program and run the script again; do not switch to a JavaScript loop.realm.transform at most 100 times, so transform a whole array in one call, never one call per item. A call over a limit throws and names the limit; split a larger input into parts under 1,000,000 bytes, one call each, or have the program return less.To look at what the script made, call await realm.capture(target, options) after the write. target is a path in this realm (Pet/mango for a card, brand/guide.html for a file), or a card id or file URL in any workspace the user can read, such as a catalog card or a file in another workspace; a target in no readable workspace is refused, and so is every boxel-local:// URL, which names a file the user attached from their computer or an image a capture took. options is optional: format (isolated, the default, or embedded; fitted cannot be captured), viewportWidth/viewportHeight (default 1280×800, a laptop screen), fullPage, and target, a CSS selector read from the card's template ('.pricing'): the capture is of the first element it matches, scrolled into view and cropped to it. target works on cards only (a file renders in its own frame) and cannot be combined with fullPage. A capture more than twice as tall as it is wide and taller than 4096px is cut to its top, and the result says so; any other capture too large to show is scaled down whole. To see a card, view an instance (Person/sample or Person/sample.json); viewing a .gts path shows the module's source file, not the card it defines. It attaches the image to the tool result, so you see it alongside the result; the script gets back only { path, kind, format, viewportWidth, viewportHeight, target, width, height, attached } (target only when given), never the image. A capture shows nothing to the user; to put a card on screen, return { show: path } or ask for a realm.ui action (below). A run can capture at most 3 times, and each capture spends the run's 55 seconds; a fourth capture, or one with too little time left in the run, is refused: capture the rest in another run. A card you just wrote can take a moment to index; if its capture fails, capture it again in your next run.
Capture what the conversation is about, not only the top of a laptop-width page:
target, or capture with fullPage when you need the whole page.Capture freely, without asking first, also in a run that writes nothing. You cannot judge visual work from source alone:
You see an image in the turn it arrives. In later turns the conversation lists it by name, URL, type and size, without the image. To look at a capture again, capture its card or file again, never the image's own boxel-local:// URL. viewAttachment shows only files the user attached, not captures. At most 8 images reach you per turn, the newest first; view only what you need for the step you are on.
What you can and cannot see:
realm.capture, as often as you need.boxel-local://, so realm.capture refuses it; do not try. To look at it again later, call viewAttachment with its URL. If you have no viewAttachment tool, or it can't show the file, ask them to attach it again, or to upload it into the workspace so you can capture it whenever you need.room.setModel).To find what exists across realms and the catalog — Specs, cards, files, listings — call await realm.entries.search(query, { realms, scope, limit }). query is a card query, without page: a filter built from on/type, eq, contains, range, in, any, every, not and full-text matches, and an optional sort; the syntax is in boxel-environment/references/searching-and-querying.md. A query with page is refused. realms is an array of realm URLs and defaults to every realm the user can read, the catalog included; scope is 'cards', 'files' or 'all' (the default); limit is how many entries to return, 20 when missing and never more than 50. It answers { entries, total, truncated, incomplete }. Each entry is { url, kind, ref, specType, cardTitle, cardDescription, name, readMe }, where a Spec's ref is the export it describes and readMe is its full readMe. truncated is true when more entries match than the answer holds: narrow the query rather than ask for more. incomplete is true when a realm did not answer. The search does not write and does not count toward the 20-file limit. Run all the searches a task needs in one script and return only what you will use; see boxel-ui-component-discovery for a loop. The tool row shows the user what the run's searches found: each entry once, best match first, with how well it fits, the best three in view and the rest behind a "more matches" toggle. So in your reply, name the entry you chose and why, and do not list the matches again. realm.cards.search does not add to that list.
To ask the user a question and go on with the answer, call await realm.ask({ question, options, kind, allowOther }). Use it for any question whose answer is one of a set you can name: before the work starts, a script may do nothing but ask and return the answers; while the work runs, ask when the script finds something only the user can decide, for example which of several matches to use. question is required, up to 300 characters. options is 1 to 8 options, each { label, value, cardId, color, detail, confidence } with only label required; value is the label when it is missing. kind is 'options' (the default), 'cards' (set cardId to a card URL), 'swatches' (set color to a CSS color) or 'recommend' (your pick first, with its detail as the reason and a confidence of 'high', 'medium' or 'low'). allowOther: true lets the user type an answer of their own. The run pauses on the question in its own row and answers { answer, label } when the user picks; answer is the option's value, or the text the user typed. The time the user takes to pick does not count toward the run's 55 seconds. When the run ends before a pick (the user stops it), the call throws The run has ended; realm.ask got no answer. The row records each question and its answer as Asked: <question> · <label>.
To make an image, call await realm.images.generate({ prompt, path, sourceImageUrl, llmModel }). prompt and path are required; sourceImageUrl (an image to start from: a data: URL, or a file in this run's workspace, as a path or a full URL; any other URL, such as a public http(s) image, is refused) and llmModel (an image model id) are optional. The host asks the model for the image and saves it as a new file at path; the file extension follows the image type the model returns, so Pet/mango.png can be saved as Pet/mango.jpg. Before it asks the model, it refuses a path where a file already exists, also with another image extension (Pet/mango.jpg blocks Pet/mango.png), so no credit is spent on an image that cannot be saved. It returns { path, contentType, size, saved: true }, never the image: link the returned path in the card JSON in the same script. path is relative to the realm root, so a link from an instance in a folder needs ../ in front of it (sample-images.md in boxel-file-def has the steps). Each image spends the user's credit, so a run whose code contains realm.images.generate always waits for the user to approve it, also in act mode; write the call exactly by that name, because a run that gets to it in a different way is refused. A run can generate at most 4 images, and a run that generates images gets 120 seconds for them on top of its 55 seconds, at most 60 seconds for each image. The realm calls of a run go one at a time, also in Promise.all, so the images are made one after another within those 120 seconds; when the time is used, the next call is refused before it asks the model.
To save a file from the web into the realm, call await realm.fs.download(sourceUrl, path). sourceUrl is an absolute http or https URL. path must have a file extension, because the realm infers the file type from it. The host fetches the file from the browser and saves it; the bytes never enter the script. Because the fetch runs in the browser, the source must allow CORS. It refuses a file that already exists, an empty response and a failed fetch, a file larger than 10,000,000 bytes, and more than 25,000,000 bytes in one run. Each download may take 20 seconds, and it counts toward the run's 55 seconds. It returns { path, size, saved: true }; link the returned path in the card JSON in the same script. A run whose code contains realm.fs.download always waits for the user to approve it, also in act mode; write the call exactly by that name, because a run that gets to it in a different way is refused.
To refresh the index of this realm, call realm.index. await realm.index.invalidate(paths) indexes specific files again (a path, or an array of 1 to 100 paths); await realm.index.reindex() reindexes the realm; await realm.index.fullReindex() rebuilds the whole index from scratch; await realm.index.cancelJob() cancels the running indexing job. Each call needs write access. One run may call realm.index.invalidate at most 10 times, and realm.index.reindex and realm.index.fullReindex at most once each; a call over its limit throws Realm code may call realm.index.<call> at most … per run and starts nothing, so put all the paths a run must index into one realm.index.invalidate call. realm.index.invalidate returns once the realm has indexed the files, so a read after it in the same script sees them; the other calls start the work on the realm server and return at once, with no wait for the indexing to finish. Use them when a card shows old data or an index error after an edit and the user asks to refresh it. realm.index.invalidate needs no request from the user when realm.cards.get says a card is not indexed and the workspace is not indexing: that file gets no index pass otherwise. In a workspace the user can only read, the error says so instead; tell the user the card needs indexing again. Each call returns a small object when the realm server accepted the request ({ invalidated: [paths] }, { reindex: 'started' }, { fullReindex: 'started' } or { cancelled: true }) and throws with the server's error when it did not. A cancel stops the indexing jobs the realm is running; jobs that wait in the queue stay there and run after it. A full reindex is slow and a cancel leaves the index without the work it stopped, so use them only when the user asks. A run whose code contains realm.index.fullReindex or realm.index.cancelJob always waits for the user to approve it, also in act mode; write these calls exactly by that name, because a run that gets to one in a different way is refused.
To create a workspace for the user, call await realm.workspaces.create({ name, endpoint }). Both options are optional: a random name is made when name is missing, and endpoint, the URL path segment, is made from the name when it is missing. It returns { url, name }. Report the URL to the user. When the run ends, the host opens the new workspace. A run works in one realm only, so the script cannot write to the new workspace. To add files to it, run run-realm-code again with the new URL as realm. One run can create at most 5 workspaces.
To delete a workspace that the user owns, with all of its cards and files, call await realm.workspaces.delete(url). It returns { url, deleted: true }. A delete cannot be undone, so confirm with the user before you call it. Write the call exactly as realm.workspaces.delete(...) in the script. A run whose code contains that text always waits for the user to approve it, also in act mode. A run that gets to the delete in a different way is refused.
To change this chat room, call room in the script. await room.enableSkills([id, ...]) turns skills on and await room.disableSkills([id, ...]) turns them off; an id is a skill card id or a skill markdown file URL, at most 20 in one call. await room.setModel(modelId) switches the room to another model, such as anthropic/claude-sonnet-4.5; a model the room cannot use is refused with the list of models it can use. Change the room's skills only when the user asks for it; to use a skill yourself, read its SKILL.md with readRealmFile instead. These calls change only the room the tool was called from. Each call checks its input and records the change; the host makes the changes after the script finishes, and only when it finishes without an error. An error the script catches itself does not count: when a try/catch around the call returns normally, the changes are made. The tool result lists each change that was made. A skill you enable is available from your next step. await room.credits() reads instead of changing: it answers at once with the signed-in user's plan (a name, or null), creditsLeft, monthlyCreditsLeft and monthlyCreditsIncluded (null on a plan without a monthly allowance), extraCredits, nextDailyGrant ({ at, topsUpTo } while the balance is below what the daily grant tops it up to, else null), and session: { replies, replyCredits }: the model replies in this room that reported their usage (one per tool round, the reply making the call included) and the credits they reported. replyCredits is null when one of them reported no cost. It is not everything the session spent: image generation, history compaction and stopped replies are charged to the balance without appearing in it. The balance is read fresh from the server; when it can't be read the call throws.
To show the user what the script made, end the script with return { show: path } (the instance path, such as Pet/mango), or ask for UI actions with realm.ui in the same script: await realm.ui.switchSubmode('code') (or 'interact'), await realm.ui.openFile(path) to open a file in code mode, await realm.ui.previewFormat(cardPath, format) to open a card's definition with a preview of that card (format is isolated, embedded, fitted, atom or edit; cardPath is the instance path, such as Pet/mango), and await realm.ui.openWorkspace() to open the workspace the script runs in. Each realm.ui call checks its input when the script makes it, so a missing file fails at once. The host does the actions in order after the script finishes, and only when it finishes without an error; a run can ask for at most 10. The result's uiActions gives the status of each action; shownCard, or showError, says whether the show worked. This replaces a separate switch-submode, preview-format or open-workspace call after a build. Each tool result's context.submode and context.codeMode.currentFile tell you where the user is; do not ask for an action that changes nothing. To open a file or a workspace in another realm, run the script in that realm.
run-realm-code also runs in a workspace the user can only read, such as a catalog. There, reads, lists and captures work, and each write is refused with You can only read this workspace. Do not retry a refused write in the same workspace: tell the user, or write to a workspace the user owns.
Keep the script deterministic and narrowly scoped. Do not access browser globals, network services (other than through realm.fs.download), credentials, or files outside the given realm (other than through realm.entries.search and realm.capture). After the tool returns, inspect its result and address any correctness errors with another tool call.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
boxel-skills@cardstack-boxel is listed by cardstack/boxel — review the source before installing
npx claudepluginhub cardstack/boxel --plugin boxel-skills27 skills in this plugin
/api-integrationsUse when a card needs data from, or sends data to, a third-party API — "show my GitHub pull requests in a card", "pull my open issues", "a card that calls the weather API with my key", "integrate with Stripe/Twilio/OpenAI", "how often can this card poll", "build a PR inbox". Takes a card author from "I want data from this vendor" to a working card: classifying the integration (no key, a key the workspace shares, the user's own key, a key that can write), choosing a live card or a scheduled pipeline (and why private data takes the pipeline), declaring the `callApi` operations with labels and credential slots, estimating polling cost, and recipes for GitHub (GraphQL, a GitHub App or a read-only fine-grained token, the PR inbox as a pipeline and as a live card), for a plain API key sent in a header, and for images from an AI vendor called with the user's own key (an automation run's own AI requests carry text only). Activates on "third-party API", "vendor API", "integration", "pipeline", "live card", "On a schedule and when the card is opened", "poll", "GitHub API", "GraphQL", `callApi`, `{{userKey}}`, `{{apiKey}}`, "image generation", "AI vendor key", "automation image"./api-keysUse when a card or the AI assistant needs a user's API key, or a key shared into a workspace — "this card needs my GitHub token", "the forecast operation was refused binding-not-approved", "let the user add their key", "share my key with this workspace", "add a key button". Also "sign in to GitHub from this card", "connect my account", "the operation was refused credential-rejected", "the service rejected my key", "should I register a GitHub App or an OAuth App". Covers getting a key from the user only through Boxel's secure window, with the open-secure-window tool: opening it from a card through `@context.toolContext` or from the assistant, its modes (enter a key, replace the key an operation sends, share a key, connect an account through OAuth, approve a card's requests for scheduled pipelines or also for when the card is opened, review what changed in them), passing only the operation the card is blocked on and letting the window gather the card's other operations into one approval, what the tool answers, the blocked-popup fallback, telling the user to check the address bar, what to do when the service rejects a key (stop polling, offer Try again, and Reconnect, which opens the window to replace the key), OAuth clients and connections (when to use a connection rather than a static key, what the card declares, opening connect mode, `credential-rejected` and its reasons, sharing a client into a workspace, and why GitHub takes a GitHub App), and never asking for a credential in the chat or building a form for one. Also covers asking first with `@context.keyReadiness` — the answers (`ready`, `needs-connect`, `needs-approval`, `needs-reapproval`, `needs-admin`, `needs-sign-in`, `rate-limited`, `over-budget`), what a card shows for each and what the secure window can fix, and treating `undefined` as "not known yet" so prerendered HTML never shows Connect. Also covers a call refused for the key owner's limits (`rate-limited`, `over-budget`, `rate-limit-unavailable`): backing off by `retryAfterSeconds` and saying the limit is reached without naming a budget. Activates on "approve", "Allow", "review changes", `needs-approval`, `needs-reapproval`, `open-secure-window`, `OpenSecureWindowTool`, `keyReadiness`, "secure window", "API key", "enter a key", "replace a key", "share a key", "OAuth", "connect", "Reconnect", "GitHub App", `{{userKey}}`, `{{apiKey}}`, `binding-not-approved`, `interactive-use-not-approved`, `anonymous-use-not-approved`, "On a schedule and when the card is opened", "people who aren't signed in", "anonymous cap", `credential-rejected`, `rate-limited`, `over-budget`.