Copy Path for Claude Code
VS Code extension that copies the active file path in Claude Code's @path format to the clipboard.
Install from VS Code Marketplace
Demo
Why?
Claude Code for VS Code has a built-in command Claude Code: Insert @-Mention Reference — which would make this extension completely unnecessary. Unfortunately, it still doesn't work in some environments
The issues below are closed, but the command still doesn't work in my environment for months. e.g.
So here we are. 🫠
If you're in the same boat, this extension has your back until the official command is fixed. 🫰
Features
- Copy Relative Path — Copies
@relative/path/to/file.ts to clipboard
- Copy Absolute Path — Copies
@/absolute/path/to/file.ts to clipboard
- Line number support — When text is selected, appends line numbers automatically
- Single line:
@path#5
- Range:
@path#5-10
Usage
- Open a file in the editor
- Open the Command Palette (
Cmd+Shift+P or Ctrl+Shift+P)
- Run one of:
Copy Relative Path for Claude Code
Copy Absolute Path for Claude Code
- Paste the result into Claude Code
Optionally, select text before copying to include line numbers.
Keyboard Shortcuts
This extension does not register default keybindings. To set your own:
- Open the Command Palette (
Cmd+Shift+P or Ctrl+Shift+P)
- Run
Preferences: Open Keyboard Shortcuts
- Search for
Copy Path for Claude Code
- Click the pencil icon next to the command and assign your preferred shortcut
| Command |
Command ID |
| Copy Relative Path for Claude Code |
copy-path-for-claude-code.copyRelativePath |
| Copy Absolute Path for Claude Code |
copy-path-for-claude-code.copyAbsolutePath |
You can also edit keybindings.json directly. For example:
[
{
"key": "ctrl+shift+c",
"command": "copy-path-for-claude-code.copyRelativePath",
"when": "editorTextFocus"
}
]
Requirements
License
MIT