Tools
Scripts
Author, run, save, and reuse bounded TypeScript automation against a connected Redis or Valkey server.
Scripts is Varc’s on-demand TypeScript workbench for Redis and Valkey automation. Use it for one-off investigations, repeatable maintenance, data fixes, reports, and operator actions that need more structure than a Console command.
| Task | Action |
|---|---|
| Run the active script | Choose Run or press Mod+Enter |
| Cancel an active run | Choose Cancel on its Run output entry |
| Format TypeScript | Choose Format in the editor header |
| Save the active script | Choose Save or press Mod+S |
| Open a saved script | Choose Open script in the tab bar |
| Create another draft | Choose the plus button in the tab bar |
| Open the macro palette | Press Mod+Shift+K |
Mod means Command on macOS and Ctrl on Windows and Linux.
Open Scripts
Connect to a Redis or Valkey profile, then choose Automate → Scripts in the Dock. A script needs an active connection before it can run. The root redis object targets the workspace’s selected logical database.
The first tab is an unsaved Untitled-1 draft. You can run it immediately; saving is required only when you want a library entry, a command macro, or optional host permissions.
Run your first script
Paste this into the editor:
import { formatISO } from "date-fns";
const keyCount = await redis.dbsize();
const checkedAt = formatISO(new Date());
console.info(`Found ${keyCount} keys`);
return { database: redis.database, keyCount, checkedAt };
Choose Run. The lower Run output pane shows captured console messages, the explicit return value, Redis-operation metadata, and the terminal state. A long run can be cancelled from its pending entry. Choose Clear output to remove the current transcript from the workspace.
Three source rules explain most scripts:
- Top-level
awaitis available; do not add an extra async wrapper. - Only an explicit
returnbecomes the run result. A trailing expression is ignored. - Return a Promise with
return await promiseso it resolves before the run ends.
The editor provides diagnostics, hover details, signature help, completion for the active execution class and Script environment, and static imports from Varc’s embedded module catalog.
Read and change data deliberately
Scripts can issue ordinary reads and writes:
const key = "feature:checkout";
const previous = await redis.get(key);
await redis.set(key, "enabled");
return { key, previous, current: "enabled" };
Run executes the current buffer, so review write-capable source before launching it. The central command policy still blocks administrative, connection-affine, and server-side scripting commands.
Use redis.db(n) when a non-cluster connection must target another logical database without changing the workspace:
const waiting = await redis.db(2).llen("jobs:waiting");
return { database: 2, waiting };
Cluster connections support database 0 only. Varc performs standalone, Sentinel, and cluster routing outside the script; code never receives a raw connection handle.
Work with tabs and drafts
Each tab owns an independent source buffer. Tabs can be opened, reordered, and closed; edited tabs display a dirty indicator. Closing a dirty tab offers Save, Don’t Save, and Cancel.
Typing also updates a device-local recovery draft after a short pause. That draft protects unsaved work across a tool move, renderer reload, app restart, or crash, but it is not a named library script. Saving publishes the current source as a reusable record and clears the corresponding recovery draft.
Run output belongs to the current workspace session. It is not stored in the saved script and is not restored with a draft.
Save and reopen a script
Choose Save or press Mod+S. The first save asks for a name; later saves update the same script. Choose Open script to search the local library, open a script in its own tab, reorder entries, or delete one.
Saved scripts are stored on this machine and can run against compatible connections. The plan’s saved-script allowance applies across manual scripts, macros, and transformers because they share one library. Varc reports an upgrade path if a save would exceed the active allowance.
If the same saved script changes elsewhere, Varc refuses to overwrite the newer revision. Reload it from the library or save the current source under another name.
Turn a script into a macro
After saving, change Run mode from Manual to Macro. A macro has the same source, Redis policy, limits, environment, and optional permissions as a manual script; the difference is how it is launched.
You can:
- run any macro from the macro palette with
Mod+Shift+K; or - assign it to one of nine macro slots, then configure a shortcut for that slot in Settings.
Macro slots do not receive default shortcuts. Turning Macro off also removes the script’s slot assignment. Macros are user-triggered actions, not background schedules.
Select an environment and permissions
The workspace status bar’s Script environment selector controls the frozen env values available to the run. Plain variables may sync with their environment; secret declarations may sync, but their values remain in this device’s keyring or session overlay. Script output is not redacted, so do not log or return a secret.
Saved manual scripts and macros can be granted four denied-by-default permissions from the editor:
- Clipboard — write bounded text or bytes;
- Dialogs — show bounded informational dialogs;
- Notifications — post bounded OS notifications; and
- Network — make bounded HTTP or HTTPS requests with
fetch.
An unsaved draft has no permission identity and runs with these host capabilities denied. See Environments and permissions for the exact boundaries.
Runtime limits and unavailable APIs
Manual scripts and macros run in Varc’s bounded JavaScript and TypeScript engine. The default class has a 5-second deadline, 64 MiB memory limit, 1 MiB source limit, bounded Redis operations and scans, bounded console capture, cancellation, and an 8 MiB returned-value limit.
This is not Node.js, a browser page, or Redis-hosted Lua. There is no filesystem access, arbitrary npm installation, ambient browser state, or direct socket API. EVAL, EVALSHA, SCRIPT, FCALL, and FUNCTION remain policy-denied.
What to read next
- TypeScript API reference documents every
redishelper and scripting global. - Built-in TypeScript modules lists the embedded packages available to static imports.
- Execution classes compares scripts, macros, transformers, and dashboard scripts.
- Fetch API covers Network permission behavior and request limits.
- Transformers explains how to turn exact value bytes into safe viewer output.