Code Context Extractor is a Visual Studio Code extension designed to streamline the process of feeding codebases into Large Language Models (LLMs) like GPT-4, Claude, or Gemini.
It generates a single, formatted text file (ProjectContext.txt) containing your project's folder structure and file contents, filtering out unnecessary noise and binary files to save tokens.
Key Features
- Dual Operation Modes:
- Blacklist (Exclude) Mode: Best for general project context. Everything is included by default; you select what to hide (e.g.,
node_modules, secrets, logs).
- Whitelist (Include) Mode: Best for specific tasks. Start with nothing. Select only the specific files or folders you need for a specific bug or feature.
- Smart Path Resolution: In Include mode, the extension now supports relative paths (e.g.,
pkg/routes/main.go), deep folder search (e.g., migrations/), and wildcards. It automatically handles un-ignoring parent directories so you don't have to manually select the whole tree.
- Smart Grouping: In Exclude mode, rules are organized into "Imported Rules" (from
.gitignore/Templates) and "Custom Rules" for better manageability.
- Binary File Detection: Automatically detects binary files (images, PDFs, executables) and excludes their raw content to prevent "garbage" text in your context file.
- GitHub Templates: Built-in access to standard
.gitignore templates (Node, Python, Go, etc.) for quick setup.
- State Persistence: Remembers your selection, custom rules, and active mode between sessions.
How to Use
- Open the Code Context Extractor view from the VS Code Activity Bar (Sidebar).
Mode 1: Exclude (Blacklist)
Use this when you want to share the whole project but hide specific clutter.
- Select "Exclude Mode" at the top.
- Click "Load .gitignore & Templates". This imports rules from your project's
.gitignore, VS Code settings, and optionally a GitHub template.
- Refine the List:
- Imported Rules: Expand the group to see standard exclusions. Uncheck items to include them back into the context.
- Custom Rules: Type a folder or file name (e.g.,
temp/ or *.log) and press Enter to add it. You can delete these later using the × button.
- Click "Generate Context File".

Mode 2: Include (Whitelist)
Use this when you want to focus on a specific feature.
- Select "Include Mode" at the top.
- The list starts empty (everything is ignored by default).
- Add Files or Paths: You can input:
- Relative Paths: e.g.,
pkg/routes/public_route.go (includes specifically this file).
- Folder Names: e.g.,
migrations/ (finds and includes this folder and its contents, even if deeply nested).
- Wildcards: e.g.,
*.sql or src/**/*.ts.
- Only the items in this list (and their contents) will be written to the output file.
- Click "Generate Context File".

Output
A ProjectContext.txt file is created in your root directory and opened automatically. It contains:
- A visual tree of your folder structure.
- The text content of every allowed file, formatted with headers for easy LLM parsing.

Extension Settings
This extension contributes the following settings:
code-context-extractor.excludeDirs: List of directory names to exclude by default in Exclude Mode (e.g., .git, .vscode).
code-context-extractor.excludeFiles: List of file names to exclude by default in Exclude Mode (e.g., package-lock.json).
code-context-extractor.useGitignoreTemplates: Enable/Disable the GitHub template fetcher.
Release Notes
1.4.0
- Smart Path Resolution: Include Mode now supports full relative paths (e.g.,
pkg/routes/file.go).
- Deep Folder Search: Fixed logic where deep folders (e.g.,
migrations/) were ignored. The extension now automatically detects and un-ignores the parent directory chain.
- Improved UI: UI text updated to clarify that relative paths and wildcards are supported.
1.3.0
- Major Feature Update:
- Introduced Whitelist (Include) Mode for targeted context extraction.
- Added Binary File Detection to prevent binary content corruption.
- UI Overhaul: Added collapsible "Accordion" groups for Imported vs. Custom rules.
- Added ability to Delete custom rules.
- Improved state persistence and checkbox logic.
0.0.1
| |