Skip to main content

llmdirtree

A directory tree generator and codebase context provider designed specifically for enhancing LLM interactions with your code.

Purpose

llmdirtree helps you work more effectively with Large Language Models (LLMs) by:

  • Generating visual directory trees for structural understanding
  • Creating contextual summaries of your codebase that respect privacy settings
  • Optimizing code information for LLM follow-up questions

Installation

pip install llmdirtree

Key Features

Directory Tree Visualization

  • Clean, standardized visualization of project structure
  • Unicode box-drawing characters for optimal parsing
  • Intelligent filtering of non-essential directories
  • Full .gitignore pattern support for accurate representation of your project

LLM Context Generation

  • AI-powered analysis of your codebase using OpenAI API
  • Security-focused with automatic .gitignore pattern recognition
  • File-by-file summaries optimized for follow-up questions
  • Intelligent handling of large files with automatic chunking and summarization
  • Project overview that captures your codebase's essence
  • Customizable OpenAI model selection

Security and Privacy

  • Respects .gitignore patterns to avoid exposing sensitive information
  • Zero dependencies approach (uses system curl instead of libraries)
  • Efficient token usage for minimal data exposure

Usage Examples

Basic Directory Tree

# Generate a simple directory tree
llmdirtree --root /path/to/project --output project_structure.txt

With LLM Context Generation

# Generate both directory tree AND code context
llmdirtree --root /path/to/project --llm-context --openai-key YOUR_API_KEY

This creates two files:

  • directory_tree.txt - Visual structure
  • llmcontext.txt - AI-generated project overview and file summaries

Additional Options

# Exclude specific directories
llmdirtree --exclude node_modules .git venv dist

# Customize output locations
llmdirtree --output custom_tree.txt --context-output custom_context.txt

# Control file selection for context generation
llmdirtree --max-files 150 --llm-context

# Override gitignore protection (not recommended)
llmdirtree --ignore-gitignore --llm-context

# Specify OpenAI model to use (avoids prompting)
llmdirtree --llm-context --model gpt-4

Example Output

Directory Tree

Directory Tree for: /project
Excluding: .git, node_modules, __pycache__, venv
--------------------------------------------------
project/
├── src/
│   ├── main.py
│   └── utils/
│       └── helpers.py
├── tests/
│   └── test_main.py
└── README.md

LLM Context File

# project-name

> A React web application for tracking personal fitness goals with a Node.js backend and MongoDB database.

## src/components/

- **Dashboard.jsx**: Main dashboard component that displays user fitness stats, recent activities, and goal progress.
- **WorkoutForm.jsx**: Form for creating and editing workout entries with validation and submission handling.

## src/utils/

- **api.js**: Contains functions for making API calls to the backend, handling authentication and data fetching.
- **formatters.js**: Utility functions for formatting dates, weights, and other fitness metrics consistently.

Benefits for LLM Workflows

  • Comprehensive context without uploading your entire codebase
  • More accurate responses with both structural and semantic understanding
  • Security first approach that protects sensitive information
  • Time savings from clearer communication with AI assistants
  • Handles large codebases by intelligently processing and summarizing large files

Configuration

OpenAI Model Selection

By default, llmdirtree will ask which OpenAI model you want to use once per run:

  • Default for batch processing: gpt-3.5-turbo-16k
  • Default for project overview: gpt-3.5-turbo

You can skip this prompt by specifying a model directly:

llmdirtree --llm-context --model gpt-4

Large File Handling

llmdirtree automatically handles large files by:

  1. Identifying files exceeding the token threshold (default: 8000 tokens)
  2. Splitting them into meaningful chunks
  3. Summarizing each chunk independently
  4. Creating a cohesive final summary

You can adjust this threshold by modifying the max_tokens_per_file variable in the source code.

Technical Details

  • No external dependencies required for core functionality
  • Progress bar available with optional tqdm installation
  • Automatically respects .gitignore patterns for security
  • Uses system curl instead of Python libraries for API calls

License

MIT

Metadata

Release files for llmdirtree 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmdirtree 0.1.5
File Size Uploaded Provenance
llmdirtree-0.1.5.tar.gz 15.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llmdirtree 0.1.5
File Interpreter ABI Platform
llmdirtree-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.6 kB

Release files / llmdirtree-0.1.5.tar.gz

Download URL llmdirtree-0.1.5.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ceab1e46cca5a0a3fb9c1427d7eae0f084de149c11d86a7004ec2fa5a3905fd3
BLAKE2b-256 checksum
How to use checksums
4cc6983e80b5e1e7bbf19201a31ab7923dbb7b06a2e12ee1175d73a949f45a31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.19

Release files / llmdirtree-0.1.5-py3-none-any.whl

Download URL llmdirtree-0.1.5-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1fbd0e6d16b268d406299c0fd42ecfafc1883165cdb3eef5233c72990401afb
BLAKE2b-256 checksum
How to use checksums
4611021c99a463f3ef29f72e189a8e532ca783407da716fb01e8b5a4dd531679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.19

Security for llmdirtree 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page