Skip the Copy-Paste: Reference Any Code Instantly
Tired of manually typing file paths and copying code snippets when asking Forge for help? This VS Code extension lets you reference any code with a single keystroke and start Forge sessions directly from your editor.
What This Extension Does
The problem: Describing code problems is slow and unclear
- "That function around line 50 something..."
- Copy-pasting code snippets manually
- Typing out long file paths
The solution: Show Forge exactly what you mean
- Select any code → Press
Ctrl+U→ Get a perfect reference - Works with single lines, code blocks, or entire files
This extension works with Forge CLI. Install that first if you haven't already.
See It in Action

What you just saw: Select code → Press Ctrl+U → Reference copied and ready to use with Forge.
Installation
What You Need
- VS Code: Version 1.102.0 or higher
- Forge CLI: Install it first if you haven't already
Install the Extension
Option 1: VS Code Marketplace (Recommended)
- Open VS Code
- Press
Ctrl+Shift+Xto open Extensions panel - Search for "Forge Code"
- Click Install on the official ForgeCode extension
Option 2: Command Line
code --install-extension ForgeCode.forge-vscode
Test that it works: Open any code file, select some text, press Ctrl+U. If a file reference gets copied to your clipboard, you're ready to go!
Official extension: VS Code Marketplace
Basic Usage
The Core Workflow
- Select code (or don't select anything for whole file)
- Press
Ctrl+U - Paste into Forge conversation
That's it. No typing, no manual copying.
What gets copied:
Format: @[<filepath>:<line start>:<line end>]
How selection works:
- No selection:
@[path/to/file.js]→ References entire file - Single line:
@[path/to/file.js:42:42]→ References line 42 only - Multiple lines:
@[path/to/file.js:15:28]→ References lines 15-28
Power Move: Multi-File References
Here's the real power move. You can reference multiple files in a single Forge prompt by copying and pasting references one at a time:
Example:
> Compare these approaches @[src/utils/oldMethod.js:15:45] @[src/utils/newMethod.js:20:50]
> Review this component and its styles @[components/Button.tsx] @[styles/button.css:12:34]
Now Forge can see exactly what code you're talking about, with full context and precise line numbers. No more "that function around line 50 something" conversations.
Alternative ways to copy:
- Command Palette:
Ctrl+Shift+P→ type "Copy File Reference" - Right-click Menu: Select code → right-click → "Copy File Reference"
Start New Forge Session
Start a Forge terminal directly in VS Code without switching windows.
How to use:
- Command Palette:
Ctrl+Shift+P→ type "Start New Forge Session" - Right-click Menu: Right-click in any file → "Start New Forge Session"
- Editor Toolbar: Click the Forge icon in the top-right of the editor
The extension will:
- Create a new integrated terminal in VS Code
- Navigate to your workspace directory
- Start Forge automatically
- Auto-paste any file reference from the current editor (if open)
Real-World Examples
Debugging Issues
Scenario: Authentication fails in production but works locally.
> Help me debug this auth function @[src/auth/AuthService.ts:45:67] - works locally but fails in production
Forge sees the exact code and can suggest environment-specific issues to check.
Code Reviews
Scenario: You spot a component that could be improved.
> Can you refactor this component to use hooks? @[components/UserProfile.tsx:12:89] Also suggest performance optimizations
Instead of generic advice, Forge sees your specific component and suggests targeted improvements.
Type Mismatches
Scenario: API data doesn't match your TypeScript types.
> @[src/api/users.js:156:203] @[src/types/User.ts] have a type mismatch - API returns 'user_id' but type expects 'userId'
Forge compares both files simultaneously and suggests proper fixes.
Feature Implementation
Scenario: Adding dark mode across multiple components.
> Add dark mode support to @[src/components/ThemeProvider.tsx:15:45] and update @[src/styles/theme.css:23:67]
Forge understands your theme system and suggests consistent changes across files.
Configuration
The extension provides several settings to customize its behavior. Access settings via File → Preferences → Settings → Extensions → Forge.
Available Settings
forge.terminalMode
Controls terminal interaction when copying file references with Ctrl+U.
- Type: String (dropdown)
- Options:
once(default): Open terminal once and reuse it for subsequent operationsnever: Never open terminal, only copy file reference to clipboard
- Default:
once
When to use once: Most users should use this. The extension intelligently manages Forge terminals, creating one when needed and reusing it for subsequent file references.
When to use never: Use this if you always work with Forge in an external terminal and only want the extension to copy file references to clipboard without any terminal interaction.
forge.pasteDelay
Delay in milliseconds before auto-pasting file reference into a newly created Forge terminal.
- Type: Number
- Default:
5000(5 seconds) - Range: 0-10000 milliseconds
Why this exists: When the extension creates a new Forge terminal, it needs time to start up before accepting input. This delay ensures the file reference is pasted after Forge is ready.
When to adjust:
- If file references aren't being pasted: Increase the value (try 7000-10000ms)
- If you have a fast machine and want quicker pasting: Decrease the value (try 3000-4000ms)
- Note: This only affects newly created terminals, not existing ones
forge.showInstallationPrompt
Show a prompt to install Forge CLI if it's not detected in your PATH.
- Type: Boolean
- Default:
true
When to disable: If you use Forge via npx or have it installed in a non-standard location, you might want to disable this prompt.
Troubleshooting
Extension Not Working
Quick fixes to try:
- Verify Forge CLI is installed - run
forge --versionin terminal - Check your VS Code version (Help → About) - need 1.102.0+
- Verify the extension is enabled in Extensions view (
Ctrl+Shift+X) - Restart VS Code completely
Keyboard Shortcut Not Working
Ctrl+U does nothing:
This usually means another extension grabbed that shortcut. Here's how to fix it:
- File → Preferences → Keyboard Shortcuts
- Search for "Forge" or "Copy File Reference"
- Click the pencil icon next to "Copy File Reference"
- Pick a new combo like
Ctrl+Shift+UorAlt+U
Common culprits: Vim extensions, browser preview extensions, other developer tools.
Nothing Gets Copied to Clipboard
Try these workarounds:
- Use Command Palette:
Ctrl+Shift+P→ "Copy File Reference" - Use right-click menu → "Copy File Reference"
- Check if you're in a text file (extension won't work on images/binaries)
- Some systems have clipboard permission issues - restart VS Code usually fixes this
Terminal Not Opening or Forge Not Starting
If "Start New Forge Session" doesn't work:
- Check that Forge is in your PATH - run
which forge(macOS/Linux) orwhere forge(Windows) in terminal - If using
npx, the extension may not detect it - install Forge globally:npm install -g forgecode - Try manually opening a terminal and running
forgeto see if there are any errors - Restart VS Code after installing Forge globally
If file references aren't being pasted automatically:
- Increase the
forge.pasteDelaysetting (try 7000-10000ms for slower machines) - The default is 5000ms (5 seconds) - if that's not enough, Forge may need more time to start
- Check that your terminal shell is compatible (bash, zsh, PowerShell work well)
- Try using
Ctrl+Uto copy the reference, then manually paste it into the Forge terminal
Weird File Paths
Sometimes you'll see paths like /workspaces/project/src/file.js instead of normal ones.
This is actually fine. VS Code uses different path formats for remote development, containers, and workspace setups. Forge handles these correctly, so don't worry about how they look.
Pro Tips
Start small: Reference one function, ask Forge about it, see how it responds. Then level up to multi-file references.
Be selective: Don't dump entire files unless you actually need context from the whole thing. Forge works better with focused references.
Combine with descriptions: @[component.tsx:45:67] this validation logic isn't working with empty strings gives Forge both code and context.
Next Steps
You're ready to start using the extension! The goal isn't to reference every line of code - it's to give Forge just enough context to actually help with your specific situation.
Related Guides
- File Tagging with @: Enhance AI Context for Faster Developer Workflow
- Quickstart: Get started with Forge in minutes
- Built-in Commands: Essential commands for productive workflows
Still Need Help?
If you're still stuck:
- Extension logs: View → Output → Select "Forge" from dropdown
- Report bugs: GitHub Issues
- Community help: Join our Discord for quick answers