Struct_Repo is a command-line (CLI) tool written in Dart that analyzes a project's directory structure and generates a single, comprehensive Markdown file containing the contents of all its text-based files.
This tool is incredibly useful for:
- Code Analysis: Having an entire project's source code in one file makes it easier to search, understand architecture, and get a high-level overview.
- Code Reviews: Share a single file with the complete project structure for more effective and context-aware reviews.
- Documentation: Create a complete, text-based "snapshot" of your repository at any given time.
- AI and LLM Context: Provide full project context to Large Language Models like GPT-4, Claude 3, and Gemini for more accurate assistance and analysis.
The tool is designed to be smart: it automatically ignores binary files, focusing only on content that can be read as text.
You can use Struct_Repo by either compiling it from source or running it directly with the Dart SDK.
- Dart SDK installed and configured in your system's PATH.
Compiling the tool creates a native executable that you can run from anywhere on your system without needing to call Dart directly.
-
Clone the repository:
git clone https://github.com/TrexPD/struct_repo.git cd struct_repo
-
Compile for your platform:
-
For Windows:
dart compile exe .\src\main.dart -o .\bin\structrepo.exe
-
For macOS or Linux:
dart compile exe src/main.dart -o bin/structrepo
-
-
(Optional) Add the Executable to Your PATH: To use the
structrepo
command from any directory, add the project'sbin
folder to your system's PATH environment variable.-
Windows (in PowerShell):
# Get the full path to the 'bin' directory $binPath
= (Get-Item "bin").FullName # Add it to your user PATH (this change is permanent) $oldPath = [System.Environment]::GetEnvironmentVariable("Path", "User") [System.Environment]::SetEnvironmentVariable("Path", "$oldPath;$binPath", "User") # You will need to restart your terminal for the change to take effect Write-Host "The 'bin' directory has been added to your PATH. Please restart your terminal." -
macOS/Linux (for bash/zsh): Open your shell's configuration file (e.g.,
~/.bashrc
,~/.zshrc
, or~/.profile
) and add the following line:export PATH="$PATH:/full/path/to/struct_repo/bin"
Save the file and reload your shell configuration by running
source ~/.bashrc
(or the name of the file you edited).
-
If you prefer not to compile an executable, you can run the script directly.
-
Clone the repository:
git clone https://github.com/TrexPD/struct_repo.git cd struct_repo
-
Run the command:
Instead of
structrepo
, you will usedart run src/main.dart
. See usage examples below.
The tool is designed for simplicity. The basic syntax is:
structrepo [directory_path]
Or, if you are using dart run
:
dart run src/main.dart [directory_path]
- If no
directory_path
is provided, the tool will analyze the current directory. - The output file will be generated in the directory from which the command is run, named
[directory_name].md
.
Navigate to the project folder you want to document and run:
structrepo .
Or, more simply:
structrepo
This will create a file named current_directory_name.md
in that same location.
You can provide a relative or absolute path to any directory.
# Example with a relative path
structrepo ../my-other-project
# Example with an absolute path on Windows
structrepo C:\Users\YourName\Documents\Projects\my-web-project
# Example with an absolute path on macOS/Linux
structrepo /home/your_user/projects/my-api-project
This will generate an output file (my-other-project.md
, my-web-project.md
, etc.) in the directory where you ran the command.
When structrepo
is run on a project, it generates a Markdown file formatted as follows:
# Project Structure: project-name
### file1.txt
content...
##### subdirectory/file2.dart
content...
...and so on for all text files.
Contributions are welcome! Feel free to report problems or send pull requests.
Struct_Repo is open-source under the MIT License.
Created with ❤️ and Dart by Paulo Daniel (TrexPD)!