Copy4AI: Better Context for AI Coding Assistants
When working with AI coding assistants like ChatGPT or Claude, I noticed a common problem: sharing individual code snippets without project context often led to suboptimal AI responses. This extension solves that problem.
What It Does
Copy4AI lets VS Code users:
- Copy entire directories with their structure intact
- Select specific files and folders to include
- Format the output in ways that are optimized for different AI models
- Preserve important context like import relationships and file hierarchy
Advanced Features
The extension offers sophisticated capabilities:
- Ignores dot files and respects
.gitignore
rules - Provides plaintext, markdown, and XML output formats
- Uses asynchronous processing for speed with large codebases
- Includes options for project tree inclusion/exclusion
- Offers code compression and comment removal
- Provides token counting for various LLMs
- Excludes binary files automatically
How It Works
Users select files or folders in VS Code, right-click, and choose "Copy to Clipboard (Copy4AI)" or "Copy Project Structure (Copy4AI)". The extension processes the selection according to user preferences and places the formatted content on the clipboard, ready to paste into an AI assistant.
Security and Performance
The extension prioritizes security and performance:
- Automatically excludes sensitive files (like .env)
- Detects and skips binary files to prevent corruption
- Processes files asynchronously for better performance
- Implements configurable file size limits to prevent oversized outputs
Output Formats
The extension supports three output formats:
- Plaintext: Simple text with clear section divisions
- Markdown: Formatted with code blocks and syntax highlighting
- XML: Structured format with explicit file relationships