Simplify how Large Language Models (LLMs) understand your project's organization! This project, LLM Friendly Project Structure, provides scripts in multiple languages to generate a clear, tree-like representation of your project's directory structure. This output is specifically designed to be easily parsed and understood by LLMs, making it ideal for tasks like code analysis, documentation generation, and automated code understanding.
LLMs excel at understanding structured data. By providing a simple, text-based tree view of your project, you're giving the LLM a clear map of your codebase. This helps the LLM:
- Understand Context: Quickly grasp the relationships between files and directories.
- Navigate Code: Easily locate specific files or modules.
- Generate Documentation: Create more accurate and relevant documentation.
- Perform Code Analysis: Analyze code structure and identify potential issues.
- Answer Questions: Provide more accurate answers about your project.
This project currently supports generating project trees using:
- Python 🐍:
generate_project_tree.py
- Ruby 💎:
generate_project_tree.rb
- Bash 🐚:
generate_project_tree.sh
- Kotlin 🤖:
GenerateProjectTree.kt
- LLM-Optimized Output: Generates a clean, text-based tree structure that LLMs can easily parse.
- Multi-Language Support: Choose the language you're most comfortable with!
- Clear Visuals: Creates a well-formatted tree structure using box-drawing characters.
- Customizable: Easily exclude specific directories or files.
- Easy to Use: Simple command-line interface.
- Cross-Platform: Works on macOS, Linux, and Windows (with Ruby and Python installed).
Here's how to run each script, step-by-step:
- Prerequisites: Ensure you have Python 3 installed on your system.
- Navigate: Open your terminal and navigate to your project's root directory.
- Run: Execute the Python script:
python generate_project_tree.py
- Prerequisites: Ensure you have Ruby installed on your system.
- Navigate: Open your terminal and navigate to your project's root directory.
- Run: Execute the Ruby script:
ruby generate_project_tree.rb
- Prerequisites: Ensure you have Bash installed on your system (it's usually the default shell on macOS and Linux).
- Navigate: Open your terminal and navigate to your project's root directory.
- Make Executable: Make the script executable:
bash generate_project_tree.sh
or
./generate_project_tree.sh
- Prerequisites: Ensure you have the Kotlin compiler installed and configured.
- Navigate: Open your terminal and navigate to your project's root directory.
- Compile: Compile and run the Kotlin code:
kotlinc GenerateProjectTree.kt -include-runtime -d GenerateProjectTree.jar
java -jar GenerateProjectTree.jar
- Excluding Directories: Modify the
EXCLUDE_DIRS
variable in each script to exclude specific directories (e.g.,.git
,build
,node_modules
). - Excluding Files: Modify the
EXCLUDE_FILES
variable in each script to exclude specific files (e.g.,.DS_Store
).
You can automate running the script whenever you build or run your Android project in Android Studio or any other Gradle-based project.
Just add these lines to your app/build.gradle.kts
tasks.register<Exec>("generateProjectTree") {
group = "documentation"
description = "Generates a project tree view"
workingDir = project.rootDir
commandLine("sh", "generate_project_tree.sh")
}
tasks.named("preBuild").configure {
dependsOn("generateProjectTree")
}
Here's an example of what the output in project_treeview.txt
might look like:
MyProject/
├── .gitignore
├── build.gradle.kts
├── settings.gradle.kts
├── app/
│ ├── build.gradle.kts
│ └── src/
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ ├── MainApplication.kt
│ │ │ └── ui/
│ │ │ └── MainActivity.kt
│ │ └── res/
│ │ └── values/
│ │ └── strings.xml
│ └── test/
│ └── java/
│ └── com/
│ └── example/
│ └── ExampleUnitTest.kt
├── gradle/
│ ├── libs.versions.toml
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
└── gradlew.bat
Contributions are welcome! If you have any ideas for improvements or want to add support for other languages, feel free to open an issue or submit a pull request.