Context Generator for LLM
A Visual Studio Code extension that generates copy-ready context from multiple files in your workspace for use with Large Language Models (LLMs) such as ChatGPT, Claude, and Gemini. Instead of manually copying and pasting the contents of file after file every time you want to send them to one of these LLM tools, this extension gathers all the files you select and turns them into a single, well-structured context block that you can paste in one go.


Features
Workspace Context
- Workspace file tree with checkboxes: Browse your current workspace in a dedicated view with a hierarchical tree of folders and files, each with a checkbox.
- Folder-level selection: Checking a folder will check (or uncheck) all files and subfolders under it, making it easy to include whole directories at once.
- Hidden files toggle: Show/hide dotfiles and dotfolders from the workspace tree.
- Refresh Workspace: Sync the tree with the current filesystem while keeping your existing selections.
- Markdown-style context generation: For every selected file, the extension generates a block like:
File: relative/path/to/file.ext
- Followed by the full file contents wrapped in triple backticks.
- Dedicated "Generated Context" view: The generated text is shown in a separate webview tab called Generated Context.
- Line numbers toggle: Optionally add line numbers in the generated output.
- Remove comments toggle: Optionally remove comments from the generated output using Tree-sitter (supported languages are listed below).
- Token + line counts: Displays token and line counts for the current output.
- One-click copy: A Copy to Clipboard button copies the entire generated context so you can paste it directly into your LLM prompt.
- Clear selection command: Quickly uncheck everything in the tree with a single command.
Remove comments – supported languages
- C (
c)
- C++ (
cpp, cpphdr)
- JavaScript (
javascript, javascriptreact)
- TypeScript (
typescript)
- TSX (
typescriptreact)
- Python (
python)
Note: For unsupported languages, the Remove comments toggle may have no effect (the original content will be used).
Git Diff Context
- Git commit view: Browse recent commits in the current repository.
- Generate Diff Context: Select exactly two commits and generate a copy-ready
git diff.
- Pick files/folders to include: Choose which changed paths to include in the diff output before generating.
Requirements
- Visual Studio Code: version 1.106.1 or higher (as defined in
engines.vscode).
- Git (optional): Required only for Git features (Git view / diff context). Git must be available in
PATH, and the opened workspace must be a Git repository.
Installation
- Open the Extensions view in VS Code (
Ctrl+Shift+X / Cmd+Shift+X).
- Search for "Context Generator for LLM".
- Click Install.
- Reload VS Code if prompted.
Usage
1. Open a workspace
Open a folder or workspace in VS Code that contains the files you want to send as context to an LLM.
2. Open the Context Generator views
- In the Activity Bar, find the view container titled Context Generator for LLM.
- Open it to see:
- Workspace view (file selector)
- Git view (commit selector)
Workspace: Generate Context
1) Select files and folders
- Use the checkboxes to select the files you want to include.
- You can also check a folder to select (or unselect) all files and subfolders inside it.
- Only real files are included in the generated context; folders themselves are used only for grouping and selection.
2) Generate context
You can generate context in either of the following ways:
- Click the Generate Context button in the title bar of the Workspace view.
- Or run the Generate Context command from the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P).
When executed, the extension:
- Collects all checked items that are files.
- Reads their contents (via VS Code documents).
- Builds a single text document where each selected file is wrapped like this:
File: path/from/workspace/root.ext
// file contents here (wrapped in triple backticks in the actual output)
- Opens a Generated Context webview tab showing the final result.
If no files are selected, a warning message is shown instead.
In the Generated Context tab:
- Line numbers: Adds/removes line numbers in the output.
- Remove comments: Strips comments ufor supported languages.
Note: Depending on the language/parser availability, comment stripping may fall back to the original content.
4) Copy the generated text
- In the Generated Context tab, click the Copy to Clipboard button.
- Paste the copied text into your LLM chat or prompt.
5) Refresh Workspace / Toggle hidden files
- Refresh Workspace: Click Refresh Workspace in the Workspace view title bar to sync with the current filesystem.
- Show/Hide Hidden Files: Use the eye icon in the Workspace view title bar to show or hide dotfiles/dotfolders.
- When hidden files are disabled, they are not shown and are not included by folder-recursive selection.
Git: Generate Diff Context
1) Select two commits
- Open the Git view.
- Check exactly two commits.
- The extension labels them as Base (older) and Compare (newer) when possible.
2) Generate diff context
- Click Generate Diff Context in the Git view title bar.
- Select the files/folders you want to include in the diff (a picker will appear).
- A Git Diff Context webview tab opens with the generated output.
3) Copy the diff
In the Git Diff Context tab, click Copy to Clipboard and paste it into your LLM prompt.
Note: Very large diffs may be truncated to keep the UI responsive. If truncation happens, VS Code will show an informational message.
Configuration
This extension does not contribute any user settings (settings.json) at the moment.
Some behaviors are toggled via the view toolbar (for example, showing/hiding hidden files) rather than VS Code settings.