Tool to export any project folder or repository into a single, neatly formatted file — ideal for quick AI-assisted code review, debugging and refactoring. The script collects source files recursively, wraps each file in fenced code blocks with relative paths, filters common noise (e.g. node_modules, .git, images), and produces a paste-ready output or copies it to the clipboard.
- Prepare full project context for AI quickly: paste the entire codebase into ChatGPT/Claude without manual copying.
- Fast code review and debugging: get a consolidated snapshot to ask focused questions about structure, bugs or refactoring.
- Share reproducible context: include relative paths and file order so AI or reviewers can follow the codebase layout.
- Filter and reduce noise: automatically ignore large binaries, images and common vendor folders to keep the export relevant.
- Code review and refactoring requests to AI assistants (send whole project context in one paste).
- Pair-programming / debugging sessions where you need to show multiple files at once.
- Student help and tutoring: submit a full assignment for constructive feedback.
- Quick repository snapshots for onboarding, audits or issue reproduction.
- Recursively scans a directory and collects source files
- Configurable ignore rules for directories, filenames and extensions (
config.py) - Save output to a file and/or copy to the clipboard
- Print simple statistics (file count, characters, runtime)
- Works with CLI or GUI folder picker (Tkinter)
-
Requires Python 3.6+ (recommended)
-
Optional clipboard support: install
pyperclip(recommended for macOS/Linux or for a more reliable cross-platform clipboard).
Install optional dependency (one of the options below):
# install only pyperclip
pip install pyperclip
# or install from project's requirements.txt
pip install -r requirements.txt- Open a terminal in the
CodeExportForAIfolder. - Run:
python code_export_for_AI.pyOr provide a folder and output file directly:
python code_export_for_AI.py -d "C:\path\to\project" -o export.txt- If you run without
-d, a folder selection dialog opens. The script will createoutput.txtby default and may copy the content to the clipboard if enabled. Clipboard support is cross-platform: the tool usespyperclipwhen available, otherwise falls back to native utilities (clip,pbcopy,xclip/xsel).
Each file is exported with a relative path header followed by a fenced code block. Example:
src/main.py:
```python
def hello():
print("Hello World")
```
components/button.js:
```javascript
function Button() {
return <button>Click me</button>
}
```
The script loads config.py from the same folder (if present). Defaults are used otherwise. Key options:
BLACKLIST_EXTENSIONS— set of file extensions to ignoreBLACKLIST_DIRS— directories to skip (e.g.node_modules,.git)OUTPUT_FILENAME— default output file nameMAX_FILE_SIZE_MB— maximum file size to includeCREATE_FILE— whether to write the output fileCOPY_TO_CLIPBOARD— whether to copy result to clipboardBLACKLIST_FILENAMES— filenames to ignoreFILENAME_FILTER_MODE—'exact'or'contains'FILENAME_FILTER_MODE—'exact'or'contains'USE_PYGMENTS— (bool) enablepygments-based detection of fenced-code language tags (default:True).EXTENSION_LANGUAGE_MAP— dict mapping extensions (no dot) to language tags used in fenced code blocks. Used as a fallback and fully user-overridable.
When USE_PYGMENTS is enabled and pygments is installed the script will try to auto-detect language aliases from filename+content; otherwise it falls back to EXTENSION_LANGUAGE_MAP. If no language is found the code fence remains untagged. To customize, edit config.py.
- For large repositories, increase
MAX_FILE_SIZE_MBor run on a subset of folders. - If you rely on clipboard copying on Linux, ensure
xcliporxselis installed or installpyperclip.
Improvements welcome — open an issue or submit a pull request.