forkguarddocs

Automatic protection

Protect yourself every day without thinking about it.

On this page

`forkguard setup` adds a small, clearly marked block to your shell profile. It wraps npm, pnpm, yarn, bun and git. For package managers it checks before the command runs, and can stop it. For git it checks after, and warns you.

  1. You type npm install.
  2. Your shell runs forkguard first.
  3. Clean, or only MED: the command runs. HIGH: it is stopped, with the reason.

#Turn it on

npm install -g forkguard
forkguard setup

Press Enter to also stop VS Code from running tasks by itself. Then close your terminal and open a new one.

#Which commands are checked

ToolSubcommands that trigger a check
npminstall, i, ci, add, run, run-script, dev, start, build, test, exec, x, rebuild
pnpminstall, i, add, run, dev, start, build, test, exec, dlx
yarnplain yarn, install, add, run, dev, start, build, test, dlx
buninstall, i, add, run, dev, start, build, test, x
gitclone, pull, merge, checkout, switch (checked afterwards; warns, never stops)

Anything else, such as npm --version, npm publish or git status, runs normally with no check. npx is not wrapped.

#What you see

Project stateWhat happens
CleanNothing. No output at all.
Only MED findingsA one-line note: “forkguard: N thing(s) worth a look in my-app. Run "forkguard" for details.” The command runs.
Something HIGHThe findings are printed and the command is stopped: “Stopped "npm install" so nothing in this project runs.”
After git clone or pull, something HIGHThe findings are printed with “The code you just pulled in is infected. Clean it before you open or install it.” The git command had already finished.

#When the check is skipped

#It checks the project you mean

Options that take a value are understood, so they are not mistaken for the subcommand, and options that choose the project are followed:

npm --prefix ./app install      # checks ./app
pnpm -C ./app install            # checks ./app
yarn --cwd ./app install         # checks ./app

#It fails open

The hook never breaks your tools. Only an explicit “infected” answer (exit code 1) stops a command. If forkguard is missing (you switched Node version with nvm, or uninstalled it) or crashes, your command runs anyway.

#Run something anyway, once

FORKGUARD_SKIP=1 npm install
$env:FORKGUARD_SKIP='1'; npm install

#Turn it off

forkguard setup --remove

Open a new terminal and it is gone. The hook is plain shell code between # >>> forkguard >>> and # <<< forkguard <<< in your profile, so you can read it or delete it by hand.

Where to next

Edit this page on GitHub View as Markdown

Type to search. Use the arrow keys and Enter.