Overview
Forge integrates with Visual Studio Code through automatic terminal detection and extension installation. When running Forge in VS Code’s integrated terminal, it can detect the environment and offer to install the official Forge extension for enhanced functionality.Features
- Automatic VS Code terminal detection
- One-click extension installation
- Seamless terminal integration
- Access to Forge commands within VS Code
- Integrated AI assistance in your workflow
Extension Installation
Automatic Installation
Forge automatically detects when running in VS Code and offers to install the extension:Open VS Code Terminal
Open the integrated terminal in VS Code:
- Press Ctrl + ` (Windows/Linux)
- Press Cmd + ` (macOS)
- Or: View → Terminal
Run Forge
Run any Forge command:If the extension isn’t installed, Forge will prompt you to install it.
Automatic Installation
Forge will automatically run:The extension will be installed in the background.
Manual Installation
Via VS Code Extensions
- Open VS Code
- Click the Extensions icon in the sidebar (or press Ctrl/Cmd + Shift + X)
- Search for “Forge”
- Click “Install” on the ForgeCode.forge-vscode extension
Via VS Code Marketplace
Visit the VS Code Marketplace and click “Install”.
Detection Mechanism
Forge detects VS Code by checking for environment variables that are automatically set in VS Code’s integrated terminal.Environment Variables Checked
Fromcrates/forge_main/src/vscode.rs:9:
TERM_PROGRAM=vscode- Primary VS Code terminal identifierVSCODE_PID- VS Code process IDVSCODE_GIT_ASKPASS_NODE- VS Code Git integrationVSCODE_GIT_IPC_HANDLE- VS Code IPC handle
Extension Detection
Fromcrates/forge_main/src/vscode.rs:22:
ForgeCode.forge-vscode appears in the installed extensions list.
Extension Features
The Forge VS Code extension provides:- Integrated terminal commands
- Syntax highlighting for Forge conversations
- Code action suggestions
- Quick fixes powered by AI
- Inline AI assistance
- Context-aware completions
Configuration
Disable Auto-Install Prompt
If you don’t want Forge to prompt for extension installation:~/.zshrc or ~/.bashrc
Extension Settings
Configure the extension in VS Code settings:settings.json
Using Forge in VS Code
Terminal Integration
Once the extension is installed, use Forge commands directly in the integrated terminal:Command Palette
Access Forge commands via Command Palette:- Press Ctrl/Cmd + Shift + P
- Type “Forge”
- Select from available commands:
- Forge: Start Conversation
- Forge: Review Current File
- Forge: Generate Tests
- Forge: Explain Code
- Forge: Fix Issues
Keyboard Shortcuts
Default keybindings (customizable):| Command | Windows/Linux | macOS |
|---|---|---|
| Start Conversation | Ctrl + Shift + F | Cmd + Shift + F |
| Review Current File | Ctrl + Shift + R | Cmd + Shift + R |
| Explain Selection | Ctrl + Shift + E | Cmd + Shift + E |
Troubleshooting
Extension not detected
Extension not detected
Verify the extension is installed:If not listed, install manually:
Auto-install fails
Auto-install fails
Check if the If not found, add VS Code to PATH:macOS:
code command is in PATH:- Open VS Code
- Press Cmd + Shift + P
- Type: “Shell Command: Install ‘code’ command in PATH”
- Press Enter
code command is usually added automatically during installation.Linux:VS Code not detected
VS Code not detected
Forge may not detect VS Code if environment variables aren’t set. Verify:If these are empty, you may be using a non-standard terminal or VS Code fork.
Extension not working after install
Extension not working after install
-
Reload VS Code window:
- Ctrl/Cmd + Shift + P
- Type: “Developer: Reload Window”
-
Check extension is activated:
- View → Extensions
- Search for “Forge”
- Verify it shows “Enabled”
-
Check extension logs:
- View → Output
- Select “Forge” from dropdown
Implementation Details
Extension Installation Function
Fromcrates/forge_main/src/vscode.rs:39:
- Runs
code --install-extension ForgeCode.forge-vscode --force - Returns
Ok(true)if installation succeeds - Returns
Ok(false)if installation fails - Returns
Errif the command can’t be executed
Installation Check
Fromcrates/forge_main/src/vscode.rs:54:
- Only when running in VS Code terminal
- Only when extension is not already installed
Next Steps
ZSH Plugin
Use Forge with enhanced ZSH integration
GitHub Actions
Integrate Forge in CI/CD
Configuration
Configure Forge settings
Quickstart
Get started with Forge