A CLI tool to extract project source code into structured Markdown files for LLM & AI context.
Project description
Codebase Extractor
A user-friendly CLI tool to extract project source code into structured Markdown files.
💡 Love this tool? Found a bug or have an idea? Share it on GitHub!
🤝 Connect with me on LinkedIn.
☕ Enjoying it? Support development with a coffee!
🚀 Overview
Codebase Extractor is a command-line interface (CLI) tool designed to scan a project directory and consolidate all relevant source code into neatly organized Markdown files. It's perfect for creating a complete project snapshot for analysis, documentation, or providing context to Large Language Models (LLMs) like GPT-4, Gemini, or Claude.
The tool is highly configurable, allowing you to select specific folders, exclude large files, and intelligently ignore common directories like node_modules and .git.
✨ Key Features
- Interactive & User-Friendly: A guided, multi-step CLI experience that makes selecting options simple and clear.
- Smart Filtering: Automatically excludes common dependency folders, build artifacts, version control directories, and IDE configuration files.
- Flexible Selection Modes: Choose to extract the entire project with one command, or dive into a specific selection mode.
- 🌳 Nested Folder Selection: Interactively browse and select specific sub-folders from a tree-like view.
- 🔢 Configurable Scan Depth: You decide how many levels deep the script should look for folders when building the selection tree.
- YAML Metadata: Each generated Markdown file is prepended with a YAML front matter block containing useful metadata like a unique run ID, timestamp, and file count for easy tracking and parsing.
- 🚀 Quick Start Mode: Use the
--no-instructionsflag to skip the detailed intro guide on subsequent runs. - Safe & Robust: Features graceful exit handling (
Ctrl+C) and provides clear feedback during the extraction process.
📦 Installation
To get started with Codebase Extractor, follow these steps.
-
Clone the Repository
git clone [https://github.com/lukaszlekowski/codebase-extractor.git](https://github.com/lukaszlekowski/codebase-extractor.git) cd codebase-extractor
-
Set Up a Virtual Environment (Recommended) This keeps the dependencies for this project isolated from your system's Python installation.
# For macOS/Linux python3 -m venv venv source venv/bin/activate # For Windows python -m venv venv venv\Scripts\activate
-
Install Dependencies The required Python packages are listed in
requirements.txt.pip install -r requirements.txt
▶️ Usage
Basic Usage
Once installed, simply run the script from the root of the project you wish to extract:
python3 codebase_extractor.py
Quick Start
For repeat usage, you can skip the detailed introductory guide by using the --no-instructions or -ni flag:
python3 codebase_extractor.py --no-instructions
The Process
The tool will guide you through a series of prompts:
- Initial Setup [1/2]: A yes/no question to skip files larger than 1MB.
- Extraction Mode [2/2]: Choose whether to extract the entire project (
Everything) or select specific folders.
Specific Selection (if chosen):
- Scan Depth: You'll be asked how many sub-folder levels to scan for the selection list (defaults to 3).
- Folder Tree: You'll see a checklist of available folders and sub-folders to extract. The script handles selections intelligently:
- Selecting a parent folder automatically includes all its sub-folders, so you don’t need to select them individually.
- To extract only a sub-folder’s contents, select the sub-folder but not its parent.
- The special
root [...]option extracts only the files in your project's main directory, ignoring all sub-folders.
Output Details
All output files are saved in a CODEBASE_EXTRACTS directory within your project folder. Each generated Markdown file includes a YAML metadata header with a unique reference ID, timestamp, and file count for easy tracking and parsing.
📜 License
This project is licensed under a modified MIT License. Please see the LICENSE file for the full text.
The standard MIT License has been amended with a single, important attribution requirement:
If you use, copy, or modify any part of this software, you must include a clear and visible attribution to the original author and project in your derivative work.
This attribution must include:
- A link back to this original GitHub repository: https://github.com/lukaszlekowski/codebase-extractor
- A link to the author's LinkedIn profile: https://www.linkedin.com/in/lukasz-lekowski
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codebase_extractor-1.0.0.tar.gz.
File metadata
- Download URL: codebase_extractor-1.0.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd6e9839832742bf09f15e0eca1bba8139cdf5d937e7c20f9660aedff3b6e9a9
|
|
| MD5 |
dc149fd4861e90231f0647d0f0ebfb3b
|
|
| BLAKE2b-256 |
d31bf13ea6368ce4a78c0eece6ec31313cf024db195bf2d81f2ea22d39daf7ee
|
File details
Details for the file codebase_extractor-1.0.0-py3-none-any.whl.
File metadata
- Download URL: codebase_extractor-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8755073b5ead5b57aa160e61e6343977f7de2e26e760762a0ea0608ef3a86a0d
|
|
| MD5 |
8804ca9f640ce060bf59bf71d05b7b87
|
|
| BLAKE2b-256 |
579d8b8a67fa8f2dcc75c34ff8e6a4776bc88010e41bda4bab975fe00e5eb1fe
|