Cursor Environment Manager
Perfect environment variable management for Cursor AI - Manage API keys and environment variables seamlessly.
English | 中文
🚀 Features
- 🤖 Cursor AI Integration - Cursor can directly help you set/manage environment variables
- 🔑 Smart Detection - Automatically detects API Keys needed in your code
- 💾 Persistent Storage - Environment variables are permanently saved in the system
- 🔄 Auto Sync - Keeps in sync with system environment variables
- 🎯 Quick Setup - Use keyboard shortcuts to quickly set environment variables
- 📊 Visual Management - Sidebar TreeView displays all environment variables
- 🔒 Security - Supports encrypted storage (optional)
- 🌍 Universal Support - Set any environment variable, not limited to API Keys
📦 Installation
Method 1: From VS Code Marketplace (Coming Soon)
1. Open VS Code/Cursor
2. Press Ctrl+Shift+X to open Extensions
3. Search for "Cursor Environment Manager"
4. Click Install
Method 2: Build from Source
# 1. Clone the repository
git clone https://github.com/vicentidoc/cursor-env-manager
# 2. Enter project directory
cd cursor-env-manager
# 3. Install dependencies
npm install
# 4. Compile TypeScript
npm run compile
# 5. Package Extension
npm run package
🎯 Usage
1. Keyboard Shortcuts
Ctrl+Alt+K
- Set environment variable
Ctrl+Alt+L
- List all environment variables
2. Set Any Environment Variable (Important Feature!)
When you press Ctrl+Alt+K
, besides the default API Keys, you can select "$(add) Other..." to set any environment variable:
Select environment variable to set:
> OPENAI_API_KEY OpenAI API Key
ANTHROPIC_API_KEY Anthropic Claude API Key
GOOGLE_API_KEY Google API Key
AZURE_API_KEY Azure API Key
$(add) Other... Enter custom environment variable name ← Choose this!
For example, you can set:
- DATABASE_URL
- REDIS_URL
- NODE_ENV
- PORT
- SECRET_KEY
- Any environment variable you need!
3. Command Palette
Press Ctrl+Shift+P
and type:
Cursor Env: Set Environment Variable
- Set environment variable
Cursor Env: List All Environment Variables
- List all environment variables
Cursor Env: Delete Environment Variable
- Delete environment variable
Cursor Env: Sync with System
- Sync system environment variables
Cursor Env: Open GUI Manager
- Open GUI manager
4. Cursor AI Integration
In Cursor Chat, you can directly say:
"set my openai key to sk-proj-xxx"
"delete anthropic key"
"list all environment variables"
"check if openai key is set"
"export to .env file"
Cursor will automatically execute the corresponding commands!
- Click the key icon 🔑 in the activity bar
- View all environment variables grouped by service
- Click to edit or right-click for options
6. Auto Detection
When you type in your code:
import openai
The extension will automatically detect and prompt you to set OPENAI_API_KEY
!
📝 Examples
Set OpenAI API Key
- Method 1: Press
Ctrl+Alt+K
- Method 2: In Cursor Chat type "set openai key to sk-xxx"
- Method 3: Right-click on
OPENAI_API_KEY
in code → Quick Set API Key
Batch Set Multiple Keys
In Cursor Chat:
set these keys:
- openai: sk-proj-xxx
- anthropic: sk-ant-xxx
- google: AIza...
Check Environment Variable Status
check my api keys status
🔧 Configuration
Search for "Cursor Env" in VS Code settings:
cursorEnv.autoDetect
- Auto-detect needed API Keys (Default: true)
cursorEnv.encryption
- Encrypt stored API Keys (Default: false)
cursorEnv.showInStatusBar
- Show key count in status bar (Default: true)
cursorEnv.syncOnStartup
- Sync system environment variables on startup (Default: true)
cursorEnv.pythonPath
- Python executable path (Default: python)
🎨 Interface Preview
🔑 CURSOR ENV MANAGER
├── 📁 OPENAI (1/1 active)
│ └── 🔑 OPENAI_API_KEY ✅
├── 📁 ANTHROPIC (1/1 active)
│ └── 🔑 ANTHROPIC_API_KEY ✅
└── 📁 GOOGLE (0/1 active)
└── 🔑 GOOGLE_API_KEY ❌
Quick Pick Interface
Select environment variable to set:
> OPENAI_API_KEY OpenAI API Key
ANTHROPIC_API_KEY Anthropic Claude API Key
GOOGLE_API_KEY Google API Key
AZURE_API_KEY Azure API Key
$(add) Other... Enter custom environment variable name
🛠️ Advanced Features
1. Export to .env File
# In Cursor Chat
export to .env
2. Restore Deleted Keys
Deleted environment variables are still stored and can be restored:
# List all keys (including deleted)
list all keys including inactive
3. Batch Operations
// Cursor can perform batch operations
await vscode.commands.executeCommand('cursorEnv.batchSet', {
'OPENAI_API_KEY': 'sk-xxx',
'ANTHROPIC_API_KEY': 'sk-ant-xxx'
});
❓ FAQ
Q: Where are environment variables stored?
A:
- Windows: Stored in registry
HKEY_CURRENT_USER\Environment
- Config File:
~/.keymanager/keys.json
- VS Code: Also updates terminal environment settings
Q: Do I need to restart for changes to take effect?
A: No! New terminals will immediately have the environment variables. But already running applications need to be restarted.
Q: How to use in Cursor?
A: Cursor will automatically load this extension, you can:
- Manage environment variables directly in Chat
- Use keyboard shortcuts
- Use command palette
Q: What API Keys are supported?
A: All environment variables are supported! Common ones include:
- OPENAI_API_KEY
- ANTHROPIC_API_KEY
- GOOGLE_API_KEY
- AZURE_API_KEY
- GITHUB_TOKEN
- Any custom environment variable
🤝 Contributing
Issues and Pull Requests are welcome!
📄 License
MIT License
Made with ❤️ for Cursor users