Review generated UI components and pasted text before running them
You will check AI-generated or pasted UI component code for hidden instructions and risky code before it runs in your project. This reduces risk from prompt injection, where text in a component or a prompt tries to make your assistant do something you did not ask for.
- Verify sourceConfirm the official package and project page
- Read full outputCheck imports, network calls, shell commands
- Check secretsLook for env vars, tokens, local file reads
- Test in sandboxRun on a scratch branch, not production
- Commit reviewed codeKeep the approved version separate
Why it matters
Magic MCP brings AI-powered UI generation into editors like Cursor and Claude Code, and it can search a library of 10,000+ components. The project's own setup notes warn that generated components and user inputs "could be crafted to inject malicious code" and that output should be validated before use (magic-mcp on GitHub (opens external site)). Treat every generated component as untrusted input, not as finished code.
Steps
-
Before you install anything, check the project page first. The directory suggests running
npx -y magic-mcp, but also says to follow the official instructions on the npm package page. Confirm you are looking at the official package before you run it. -
Read generated or pasted code in full before saving it. Look for imports you did not expect, network calls to unfamiliar domains,
eval-style execution, shell commands, and comments that address the assistant directly (for example, text asking it to ignore rules or to read files). -
Check for secrets and data leaving the machine. Make sure the component does not read environment variables, tokens, or local files it does not need, and that it does not send form data or project content to external endpoints.
-
Run the component in an isolated place first, such as a scratch branch or a sandbox route, not in your main app with production credentials.
-
Keep the assistant's permissions narrow while you review. Limit what it can run without confirmation, and do not let it execute commands copied from generated text without reading them.
-
Commit the reviewed version separately, so a later regeneration cannot quietly replace what you approved.
Common mistakes
- Pasting a generated component straight into the project and trusting that it only renders UI.
- Skimming the first screen of code and missing a payload further down the file.
- Running install commands from a snippet without checking the package name.
- Giving the editor's assistant broad permissions while you are still reviewing outside text.
Notes
This review lowers risk but does not catch everything. Keep dependencies pinned, rotate any token that may have been exposed, and review the privacy policy for what search and generation queries are sent to remote servers.
Checklist
0 of 8 done