Is it safe to clone GitHub repositories? How to check for malicious code
A practical guide to the real risks of cloning unknown GitHub repositories — install scripts, workspace tasks, AI-agent instructions and MCP servers — and how to check a repo before you run it.
Is GitHub itself safe?
GitHub the platform is safe. Individual repositories on it are not — they are arbitrary code written by anyone. The risk is not downloading a repo, it is what happens the moment you do something with it: npm install, opening the folder in VS Code, or letting Cursor / Claude Code / Copilot read its instruction files.
What can actually execute when you "just clone" a repo?
- Install lifecycle scripts.
preinstall,install,postinstallandprepareinpackage.jsonrun automatically duringnpm install/bun install/yarn install. Same for Python (setup.py, build hooks) and many other ecosystems. - VS Code workspace tasks & devcontainers. Files in
.vscode/and.devcontainer/can auto-run commands when you open the folder, especially in Codespaces or "Reopen in Container". - AI-agent instruction files.
AGENTS.md,.cursorrules,.windsurfrules,CLAUDE.mdand.github/copilot-instructions.mdare read as authoritative instructions by Cursor, Claude Code, Windsurf and Copilot. A hostile repo can prompt-inject your agent into exfiltrating env vars or running scripts. - MCP server configs.
mcp.json/mcp.yamlentries that launch a raw shell give an AI agent shell-level access on your machine. - CI workflows with unpinned actions.
uses: some/action@mainin.github/workflows/ties your CI to a moving target — a classic supply-chain hijack.
How to check a repo before you run it
- Open
package.jsonand read thescriptsblock end-to-end. Anything that pipescurlinto a shell, runsnode -e, or base64-decodes a payload is a red flag. - List
.vscode/and.devcontainer/. Treattasks.json,launch.jsonanddevcontainer.jsonas untrusted scripts. - Read every AI-agent instruction file in the repo before letting Cursor / Claude / Copilot open the folder.
- Check repo maturity — age, number of contributors, releases, and last commit date. Brand-new single-author repos are higher risk than long-lived multi-contributor projects.
- Install with
--ignore-scriptsthe first time, or in a sandboxed container.
How RepoPreflight automates the check
Paste a GitHub URL into RepoPreflight and it pulls the public files above, scores each risk dimension (workspace execution, install scripts, AI-agent risk, MCP risk, CI/CD pinning), and returns a trust report plus a public-reputation summary in seconds. No clone, no install.
Results are heuristic and based only on what is publicly visible — they are a fast pre-clone signal, not a substitute for reading the code yourself for anything you are going to trust with secrets or production access.
Try it
Run a preflight check on any public GitHub repo.