PromptContext 用于把代码上下文快速整理成适合粘贴给大模型的 Markdown:包含相对路径、目录树(可选)与文件内容,并自动跳过常见二进制/超大文件。
你可以从 GitHub Releases 下载 .vsix 并安装(无需扩展市场)。
- 打开仓库的 GitHub Release 页面,下载最新的
.vsix(例如prompt-context-v1.0.1.vsix)。 - VS Code → 扩展(Extensions)→ 右上角
...→ 从 VSIX 安装...(Install from VSIX...)。 - 选择下载的
.vsix文件并安装,按提示重载窗口。
(可选)命令行安装:
code --install-extension ./prompt-context-v1.0.1.vsix --forcemacOS / Linux(curl,一行命令):
tmp="$(mktemp -t prompt-context.XXXXXX.vsix)" && curl -fsSL -o "$tmp" "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" && code --install-extension "$tmp" --force && rm -f "$tmp"macOS / Linux(wget,一行命令):
tmp="$(mktemp -t prompt-context.XXXXXX.vsix)" && wget -qO "$tmp" "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" && code --install-extension "$tmp" --force && rm -f "$tmp"Windows PowerShell(一行命令):
$p = Join-Path $env:TEMP "prompt-context-v1.0.1.vsix"; Invoke-WebRequest -Uri "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" -OutFile $p; code --install-extension $p --force; Remove-Item $p -Force- 在编辑器中选中一段代码。
- 执行命令 Prompt Context: 复制为提示词 (Markdown)。
- 直接粘贴到 ChatGPT/Claude/DeepSeek/Gemini 等。
你可以用任意一种方式触发:
- 命令面板:
Ctrl+Shift+P(macOS:Cmd+Shift+P)→ 运行 Prompt Context: 复制为提示词 (Markdown) - 编辑器右键菜单(编辑区):选择 复制为提示词 (Markdown)
- 编辑器标签页:在文件选项卡区域点击/右键找到 复制为提示词 (Markdown)
- 在资源管理器中右键一个文件夹。
- 选择 复制为提示词 (Markdown)。
- 会递归收集文本文件(自动跳过二进制/超大文件),并在开头附带目录树(如可生成)。
- 在资源管理器按住
Ctrl/Cmd多选多个文件/文件夹。 - 右键选择 复制为提示词 (Markdown)。
- 打开一个文件。
- 运行 Prompt Context: 插入文件路径头注释。
- 扩展会在文件顶部插入相对路径,并触发 VS Code 的“添加行注释”。
- 复制选区:在编辑器内选中代码后执行命令,会复制带行号的选区内容(更适合问“第 N 行为什么这样写”)。
- 复制文件/文件夹:在资源管理器选择文件或文件夹后执行命令,会递归读取文本文件并可生成目录树。
- 多选:在资源管理器多选多个文件/文件夹后执行命令,会按所选内容生成上下文。
- 插入路径头:把当前文件的相对路径插入到文件顶部,并触发 VS Code 的“添加行注释”。
- 命令面板:
Prompt Context: Copy to Prompt (Markdown)/Prompt Context: Add File Path Header - 编辑器右键菜单(编辑区):可复制/插入路径头
- 资源管理器右键菜单:可对文件/文件夹复制
- 编辑器标签页:在文件选项卡(标签栏)上也可以触发“复制为提示词”
在 VS Code 设置中搜索 prompt-context:
prompt-context.maxFileSize:最大文件大小(KB),默认100prompt-context.excludedExtensions:自动排除的扩展名列表(如图片/压缩包/二进制等)
pnpm install
pnpm run package
pnpm dlx @vscode/vsce package --no-dependencies- 手动打包(Artifact):
.github/workflows/package.yml支持workflow_dispatch,会产出.vsix并作为 artifact 上传 - 自动发 Release:
.github/workflows/release.yml在推送v*tag(例如v1.0.0)时自动创建 GitHub Release 并上传.vsix- 版本校验:
tag必须等于v${package.json.version},否则 workflow 失败
- 版本校验:
扩展文案支持中文/英文,会跟随 VS Code 的显示语言自动切换。
PromptContext prepares code context for LLM prompting as Markdown: relative paths, optional directory tree, and file contents, while skipping common binary/oversized files.
You can install the extension from GitHub Releases as a .vsix (no Marketplace required).
- Open the repository’s GitHub Releases page and download the latest
.vsix(for exampleprompt-context-v1.0.1.vsix). - VS Code → Extensions → top-right
...→ Install from VSIX... - Select the downloaded
.vsix, install it, then reload when prompted.
(Optional) Install via CLI:
code --install-extension ./prompt-context-v1.0.1.vsix --forcemacOS / Linux (curl, one-liner):
tmp="$(mktemp -t prompt-context.XXXXXX.vsix)" && curl -fsSL -o "$tmp" "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" && code --install-extension "$tmp" --force && rm -f "$tmp"macOS / Linux (wget, one-liner):
tmp="$(mktemp -t prompt-context.XXXXXX.vsix)" && wget -qO "$tmp" "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" && code --install-extension "$tmp" --force && rm -f "$tmp"Windows PowerShell (one-liner):
$p = Join-Path $env:TEMP "prompt-context-v1.0.1.vsix"; Invoke-WebRequest -Uri "https://github.com/mukea-org/prompt-context/releases/download/v1.0.1/prompt-context-v1.0.1.vsix" -OutFile $p; code --install-extension $p --force; Remove-Item $p -Force- Select a code snippet in the editor.
- Run Prompt Context: Copy to Prompt (Markdown).
- Paste into ChatGPT/Claude/DeepSeek/Gemini, etc.
Use any of the following:
- Command Palette:
Ctrl+Shift+P(macOS:Cmd+Shift+P) → run Prompt Context: Copy to Prompt (Markdown) - Editor context menu: choose Copy to Prompt (Markdown)
- Editor tab/title area: click/right-click the file tab area and run Copy to Prompt (Markdown)
- In the Explorer, right-click a folder.
- Choose Copy to Prompt (Markdown).
- It will recursively collect text files (skipping binaries/oversized files) and prepend a directory tree (when available).
- In the Explorer, multi-select files/folders with
Ctrl/Cmd. - Right-click and choose Copy to Prompt (Markdown).
- Open a file.
- Run Prompt Context: Add File Path Header.
- The extension inserts the relative path at the top and triggers VS Code “add line comment”.
- Copy selection: with an editor selection, the command copies the selection with line numbers.
- Copy file/folder: from the Explorer, recursively collects text files and can include a directory tree.
- Multi-select: supports selecting multiple files/folders in the Explorer.
- Insert path header: inserts the workspace-relative path at the top of the current file and triggers VS Code “add line comment”.
- Command Palette:
Prompt Context: Copy to Prompt (Markdown)/Prompt Context: Add File Path Header - Editor context menu: copy / insert path header
- Explorer context menu: copy for files/folders
- Editor tab/title area: “Copy to Prompt (Markdown)” is also available from the file tab UI
Search prompt-context in VS Code Settings:
prompt-context.maxFileSize(KB), default100prompt-context.excludedExtensionslist
pnpm install
pnpm run package
pnpm dlx @vscode/vsce package --no-dependencies- Manual packaging (Artifact):
.github/workflows/package.ymlsupportsworkflow_dispatchand uploads a.vsixartifact - Automatic Release:
.github/workflows/release.ymlruns onv*tags (e.g.v1.0.0), creates a GitHub Release, and uploads the.vsix- Version check: the tag must equal
v${package.json.version}
- Version check: the tag must equal