Shadow Script
Run JS/MJS scripts — for example, ones an AI just gave you in its chat — directly in your
workspace, without saving them into the project and without leaving VS Code for a terminal.
Why?
You're chatting with an AI, it hands you a script, and you just want to run it against your
current project. Normally that means: create a file in the project (and remember to delete it
later, or accidentally commit it), or copy it to a terminal by hand. Shadow Script skips both:
the script lives in a temp folder outside your project until you explicitly run it there.
How it works
- Click the status bar button (clipboard → arrow → play) or run
Shadow Script: Paste from Clipboard and Run.
- The clipboard content is validated as real JavaScript (syntax-checked) and classified as
CommonJS (
.js) or ESM (.mjs) based on its content — no package.json involved.
- It's written to a per-workspace temp file under
%TEMP%\shadow-script\<workspace-hash>\current.js|mjs.
- If the workspace has more than one project folder, you're asked which one to run it against.
- It runs in an integrated terminal, with the working directory set to the execution path you
configured for that project.
Want to tweak the script before running it? Use Shadow Script: Edit Current Script to open
it as a normal editor tab. Editing never touches your project's source tree — only the temp
file. When you run it, it's saved automatically first, so you don't need to press Ctrl+S.
Commands (Ctrl+Shift+P)
Shadow Script: Paste from Clipboard and Run — same action as the status bar button.
Shadow Script: Edit Current Script — opens the current temp script as an editable tab.
Shadow Script: Run Current Script — runs whatever is currently open/edited in that tab.
Shadow Script: Set Execution Path for Project — define/update the absolute folder a project
runs in (asked automatically the first time you run a script against a new project).
Shadow Script: Toggle Security Warning — enable/disable the confirmation dialog shown before
every execution.
Shadow Script: Clear Script History — empties the history folder for the current workspace.
Configuration model
Shadow Script does not use settings.json. All configuration (execution paths per project,
last used project, security warning preference) is stored in VS Code's workspace state:
- It persists across closing and reopening the same workspace.
- It's local to your machine only — nothing is written into a file that could end up committed
to the repo.
- There is nothing to "save" manually.
Temp file layout
%TEMP%\shadow-script\<hash-of-workspace>\
current.js | current.mjs <- the active script (only one exists at a time)
history\
2026-07-31T10-22-01_script.js
2026-07-31T11-05-44_script.mjs
... (last 10 executions, oldest pruned automatically)
The hash keeps scripts from different workspaces/projects from mixing. Cleanup of the temp
folder itself is left to Windows — Shadow Script does not delete anything beyond trimming the
history to the last 10 entries.
Requirements
- Node.js must be available on your
PATH (Shadow Script shells out to node).
- Windows + PowerShell is the primary target for the integrated terminal commands used here.
Extension Settings
None — see "Configuration model" above.
Known limitations
- Detection of ESM vs CommonJS is based on simple pattern matching on the script's own content
(
import/export vs require/module.exports). A script that legitimately needs neither
defaults to CommonJS (.js).
- Syntax validation catches parse errors, not runtime errors.
License
MIT