A simple yet powerful Python utility that scans your codebase and compiles all source code files into a single document. Perfect for feeding your entire project context to AI assistants like Claude or ChatGPT.
AI assistants work best when they can see the big picture. Instead of sharing individual files or code snippets, CodeScanner lets you give AI tools complete context about your entire codebase in one go.
- Easy to use: Simple command-line interface
- Customizable: Filter by file extensions, ignore specific directories
- Smart filtering: Automatically skips binary files and large generated files
- Well-formatted output: Clear file separators and summary statistics
- Cross-platform: Works on Windows, macOS, and Linux
# Clone the repository
git clone https://github.com/yourusername/code-scanner.git
cd code-scanner
# Make the script executable (Linux/macOS)
chmod +x code_scanner.py
python code_scanner.py /path/to/your/project
This will scan your project directory and create a file called codebase_for_ai.txt
with all your code.
usage: code_scanner.py [-h] [-o OUTPUT] [-e EXTENSIONS] [-i IGNORE] [-m MAX_FILE_SIZE] directory
Scan directories for source code and combine into a single file
positional arguments:
directory Directory to scan for source code
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output file name (default: codebase_for_ai.txt)
-e EXTENSIONS, --extensions EXTENSIONS
Comma-separated list of file extensions to include
-i IGNORE, --ignore IGNORE
Comma-separated list of directories to ignore
-m MAX_FILE_SIZE, --max-file-size MAX_FILE_SIZE
Maximum file size in bytes to include (default: 1MB)
Scan a project and specify output file name:
python code_scanner.py /path/to/your/project -o my_code.txt
Only include specific file types:
python code_scanner.py /path/to/your/project -e py,js,html,css
Ignore specific directories:
python code_scanner.py /path/to/your/project -i node_modules,build,tests
Set maximum file size:
python code_scanner.py /path/to/your/project -m 500000
- Run CodeScanner on your project
- Upload the generated file to your AI assistant of choice
- Ask questions about your code with full context
- Profit! 🎉
MIT License - See LICENSE file for details.
Contributions welcome! Feel free to submit a Pull Request.