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.
- Automatic Git Leak Protection: Protects
ProjectContext.txt from ever being accidentally committed to GitHub using a multi-layer strategy (.gitignore, .git/info/exclude, and live file watchers).
- Monorepo & Multi-Root Support: Accurately targets the active workspace package in monorepos and automatically opens the generated file in your primary editor.
- Smart Path Resolution: In Include mode, supports relative paths (e.g.,
pkg/routes/main.go), deep folder search (e.g., migrations/), and wildcards. Automatically un-ignores parent directory chains.
- Smart Grouping & Safety Confirmation: Exclude mode rules are organized into "Imported Rules" and "Custom Rules" with safety confirmation prompts before reloading rules.
- 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, Rust, Java, etc.) with automatic project type detection.
- 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 suggested GitHub templates.
- 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 in the editor. 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.5.0
- Multi-Tier Git Leak Protection: Automatic exclusion across
.gitignore, .git/info/exclude, and live file watchers.
- Monorepo & Multi-Root Support: Improved root directory detection and reliable automatic opening of
ProjectContext.txt.
- Reload Confirmation: Safety prompt before resetting/reloading existing exclusion rules.
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.
1.3.0
- Whitelist (Include) Mode: Added targeted context extraction.
- Binary File Detection: Prevents binary content corruption.
- UI Overhaul: Added collapsible "Accordion" groups for Imported vs. Custom rules.
- State Persistence: Remembers selections and custom rules.
0.0.1
| |