Flatten directory structures for AI analysis while preserving hierarchy context
aixtract
transforms nested file structures into flat directories with encoded path information, making it ideal for uploading codebases to AI assistants that lack directory support.
How it works:
- Reads file paths from
.aixtract
configuration - Copies files to a new timestamped temporary directory
- Encodes original paths using double underscores (
__
)
Example transformation:
src/models/user.py
β src__models__user.py
- π€ AI-Friendly: Maintain file relationships for LLMs without directory support
- π΅οΈ Context Preservation: Hierarchical information remains visible in filenames
- β‘ Zero Dependencies: Single binary for macOS/Linux
# Ensure target directory exists
mkdir -p ~/.local/bin
# macOS (Apple Silicon)
curl -L https://github.com/xthezealot/aixtract/releases/download/v1.0.0/aixtract-darwin-arm64 -o ~/.local/bin/aixtract && chmod +x ~/.local/bin/aixtract
# Linux (AMD64)
wget https://github.com/xthezealot/aixtract/releases/download/v1.0.0/aixtract-linux-amd64 -O ~/.local/bin/aixtract && chmod +x ~/.local/bin/aixtract
# Linux (ARM64)
wget https://github.com/xthezealot/aixtract/releases/download/v1.0.0/aixtract-linux-arm64 -O ~/.local/bin/aixtract && chmod +x ~/.local/bin/aixtract
Add to PATH (if not already):
export PATH="$HOME/.local/bin:$PATH"
-
Create Configuration File
Create.aixtract
in your project root with target files:# Example .aixtract file src/models/user.py tests/test_user.py config/settings.json # Use find to auto-generate (e.g., all Python files) # find . -name "*.py" >> .aixtract
-
Run Extraction
From your project directory:aixtract
-
Access Output
Files are copied to:
~/Downloads/<project_name>_<timestamp>/
(Automatically opened on macOS/Linux)
Original Structure:
myproject/
βββ .aixtract
βββ src/
β βββ models/
β βββ user.py
βββ tests/
β βββ test_user.py
βββ config/
βββ settings.json
After Processing:
/tmp/myproject_20250101123456/
βββ src__models__user.py
βββ tests__test_user.py
βββ config__settings.json
- OS: macOS 10.15+ or modern Linux distro
- Arch: x86_64 or ARM64
- Permissions: Read access to source files, write access to output directory
Q: Can I use this for non-code files?
A: Absolutely! Works with any file type