Skip to main content

A tool to visualize codebases for LLM interactions

Project description

CodeView

PyPI version License: MIT Python Versions

Overview

CodeView is a powerful command-line utility designed to help developers effectively communicate their codebases to Large Language Models (LLMs) like ChatGPT, Claude, and Gemini. It solves the common problem of needing to share multiple files and directory structures with LLMs in a clean, organized format.

Key Features:

  • 📁 Visualizes directory structures with customizable depth
  • 📝 Displays file contents with optional syntax highlighting and line numbers
  • 🔍 Flexible filtering by file type, directory, or content patterns
  • 📤 Multiple output formats (text, markdown, JSON) for different LLM platforms
  • 💾 Save output to a file or display in terminal
  • 🚀 Easy to install and use with intuitive CLI interface

Installation

Prerequisites

  • Python 3.6 or higher
  • The tree command:

Install from PyPI

pip install codeview

Install from Source

# Clone the repository
git clone https://github.com/ZiadAmerr/codeview.git
cd codeview

# Install in development mode
pip install -e .

Quick Start

Generate a view of your entire codebase:

codeview

Create a Markdown file for sharing with an LLM:

codeview -m markdown -o my_project.md

Focus on specific file types:

codeview -i "*.py" -i "*.js"

Detailed Usage

codeview [options]

Options

Option Long Form Description Example
-h --help Display help message codeview -h
-i PATTERN --include PATTERN File patterns to include (can use multiple times) codeview -i "*.py" -i "*.js"
-e DIR --exclude-dir DIR Directories to exclude (can use multiple times) codeview -e node_modules -e .venv
-x PATTERN --exclude-file PATTERN File patterns to exclude (can use multiple times) codeview -x "*.pyc" -x "*.log"
-d DEPTH --max-depth DEPTH Maximum directory depth to traverse codeview -d 2
-t --no-tree Don't show directory tree codeview -t
-f --no-files Don't show file contents codeview -f
-n --line-numbers Show line numbers in file contents codeview -n
-o FILE --output FILE Write output to file instead of stdout codeview -o project.txt
-s PATTERN --search PATTERN Only include files containing the pattern codeview -s "def main"
-p DIR --path DIR Include specific directory (can use multiple times) codeview -p src/models -p tests
-m FORMAT --format FORMAT Output format: text, markdown, json codeview -m markdown

Default Values

  • Include Patterns: *.py, *.md, *.js, *.html, *.css, *.json, *.yaml, *.yml
  • Exclude Directories: myenv, venv, .venv, node_modules, .git, __pycache__, .pytest_cache, build, dist
  • Exclude Files: *.pyc, *.pyo, *.pyd, *.so, *.dll, *.class, *.egg-info, *.egg
  • Max Depth: No limit
  • Output Format: text

Use Cases

Working with LLMs on Your Projects

# Generate a Markdown overview of your Python project
codeview -i "*.py" -m markdown -o project_for_llm.md

# Then upload the markdown file to your favorite LLM platform

Focusing on Specific Components

# Show only model and controller files
codeview -p src/models -p src/controllers -i "*.py"

# View only files containing authentication logic
codeview -s "def authenticate" -s "class Auth"

Collaborating with Team Members

# Create a JSON representation for programmatic use
codeview -m json -o project_structure.json

# Generate documentation of the core modules
codeview -p src/core -m markdown -o core_modules.md

Output Formats

Text (Default)

**./src/main.py**
def main():
    print("Hello, world!")
    
if __name__ == "__main__":
    main()

Markdown

## ./src/main.py

```python
def main():
    print("Hello, world!")
    
if __name__ == "__main__":
    main()
```

JSON

{
  "files": [
    {
      "path": "./src/main.py",
      "content": "def main():\n    print(\"Hello, world!\")\n    \nif __name__ == \"__main__\":\n    main()"
    }
  ]
}

Effective Use with LLMs

  1. Filter appropriately: Only include relevant files to stay within token limits
  2. Use markdown format for better readability with most LLMs
  3. Include line numbers (-n) when discussing specific code sections
  4. Exclude large/binary files to avoid token waste
  5. Limit depth (-d) for large projects to focus on high-level structure

Troubleshooting

Common Issues

"Command not found: tree"

  • Install the tree command using your package manager:

    # Debian/Ubuntu
    sudo apt-get install tree
    
    # macOS
    brew install tree
    

"Files not showing up"

  • Check your include/exclude patterns
  • Make sure you're running from the correct directory
  • Use the -v flag for verbose output to see what's happening

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/new-amazing-feature)
  3. Commit your changes (git commit -m 'Add some new amazing feature')
  4. Push to the branch (git push origin feature/new-amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Inspired by the need to efficiently share code with LLMs


If you find CodeView useful, please consider ⭐ starring the repository on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codeview-0.0.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codeview-0.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file codeview-0.0.4.tar.gz.

File metadata

  • Download URL: codeview-0.0.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codeview-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c23a735d13adaea2a688bcd20684eed0126adf2e79988ea268040d3cac58073f
MD5 3a2d82da9b1be24ab3bf781d594caff0
BLAKE2b-256 1a1d05557b7a2169fbc3d1be03a0e4057d65d3c7f6972649bc861675a868eac5

See more details on using hashes here.

File details

Details for the file codeview-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: codeview-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for codeview-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d41e447a414ce41ee389ae2745bd3360fc570ea492c6578f73cc16c0bc317006
MD5 24da1b801233dd047224a82d89f60696
BLAKE2b-256 cbc4f14b715c4bb65cb3d3902843018d0ccf70263f293df52cb405b35183edc5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page