Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Code Context ExtractorNew to Visual Studio Code? Get it now.
Code Context Extractor

Code Context Extractor

ct-devs

|
56 installs
| (2) | Free
Generates a single text file of your project context for LLMs. Supports both Whitelist and Blacklist modes with smart binary exclusion.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Code Context Extractor

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

  1. 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.

  1. Select "Exclude Mode" at the top.
  2. Click "Load .gitignore & Templates". This imports rules from your project's .gitignore, VS Code settings, and suggested GitHub templates.
  3. 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.
  4. Click "Generate Context File".

Exclude Mode UI

Mode 2: Include (Whitelist)

Use this when you want to focus on a specific feature.

  1. Select "Include Mode" at the top.
  2. The list starts empty (everything is ignored by default).
  3. 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.
  4. Only the items in this list (and their contents) will be written to the output file.
  5. Click "Generate Context File".

Include Mode UI

Output

A ProjectContext.txt file is created in your root directory and opened automatically in the editor. It contains:

  1. A visual tree of your folder structure.
  2. The text content of every allowed file, formatted with headers for easy LLM parsing.

Output Preview

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

  • Initial release.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft