Transform any GitHub repo or folder on your Mac into a simple text file so that you can upload it to an LLM (Claude, ChatGPT, etc.) to reason over the whole thing in the context window.
LLMs like ChatGPT and Claude let you upload files, but they limit how many you can upload at once. When you're dealing with large codebases that have tons of files, you can't just upload them directly to an LLM. You end up having to use RAG (retrieval augmented generation) techniques, which in my experience aren't as effective as uploading everything into the full context window - especially when you need to reason about architecture or understand the entire system. See example.
Coding assistants like Cursor are amazeballs, but they work better for day-to-day code completion and inline edits than they do for higher-level system understanding.
AND/OR conditions to target exactly what you need for focused analysis.Choose your adventure:
curl -fsSL https://raw.githubusercontent.com/mattmireles/flatty/main/install_flatty.sh | bash -s -- --quickcurl -fsSL https://raw.githubusercontent.com/mattmireles/flatty/main/install_flatty.sh | bashThe paranoid install (default) includes checksum verification and full security checks. Quick install skips these checks for the "I like to live dangerously" crowd.
Basic usage is stupidly simple:
cd your-project-directory
flattyThis creates a nicely formatted text file in ~/Documents/flatty/ containing all your project's text files, ready for LLM consumption.
Take control of what gets included in your flattened output by specifying patterns and conditions. This feature allows you to focus on specific parts of your codebase, improving efficiency and relevance.
Command-Line Arguments:
--pattern "pattern1": Specify a pattern or keyword to filter files. You can use multiple --pattern flags for multiple patterns.--condition AND|OR: Define how multiple patterns should be matched.
AND: All specified patterns must be present in a file (either in the filename or content).OR: Any one of the specified patterns must be present.Examples:
Include files containing either useEffect or async function:
flatty --pattern "useEffect" --pattern "async function" --condition ORInclude files containing both useEffect and async function:
flatty --pattern "useEffect" --pattern "async function" --condition ANDInclude files with README in the filename:
flatty --pattern "README" --condition ORDefault behavior without patterns (includes all eligible text files):
flattyBehavior:
Flatty intelligently skips:
node_modules, vendor).git.DS_Store)Flattened text files are saved in the ~/flattened/ directory with filenames formatted as:
<project-name>-v<version>-<timestamp>.txt
Each output file includes:
Developed with ❤️ by TalkTastic
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
To maintain the integrity of the flatty.sh script and ensure that the checksum file (flatty.sh.sha256) is always up-to-date, contributors should set up a pre-commit Git hook. This hook automatically generates and updates the checksum before each commit.
Steps to Set Up the Pre-Commit Hook:
Navigate to the Git Hooks Directory:
cd .git/hooksCreate or Edit the pre-commit Hook:
cursor pre-commitAdd the Following Script to the pre-commit File:
#!/bin/bash
# Generate SHA256 checksum for flatty.sh
sha256sum flatty.sh > flatty.sh.sha256
# Add the checksum file to the commit
git add flatty.sh.sha256Make the Hook Executable:
chmod +x pre-commitExplanation: This hook ensures that every time flatty.sh is modified and a commit is made, the corresponding flatty.sh.sha256 checksum file is automatically updated and included in the commit. This maintains the integrity verification process for the installation script.
MIT