rendergit

repository·master·Indexed 25 days ago

https://github.com/karpathy/rendergit

A utility that flattens a GitHub repository into a single static HTML page for fast skimming and search. It features a 'Human View' with syntax highlighting and a directory tree, and an 'LLM View' that provides the codebase in CXML format for easy copying into Large Language Models.

Tokens
1.2K
Snippets
2
Records
7
Agent score
32%

What's inside rendergit

  1. How rendergit works

    master

    When you run rendergit <github_url>, the tool performs the following workflow:

    1. Clones the repository to a temporary directory.
    2. Renders the source code into a single static temporary HTML file.
    3. Automatically opens the generated HTML file in your default web browser.

    Once the browser opens, you can switch between two distinct viewing modes:

  2. Switch between Human and LLM views

    master

    The rendered HTML page provides two primary viewing modes:

    • 👤 Human View: A visual interface designed for people. It includes syntax highlighting, a sidebar for navigation, and a directory tree overview.
    • 🤖 LLM View: A raw text format using CXML. This mode is designed for copying the entire codebase as a single block of text to paste into LLMs like Claude or ChatGPT for analysis.

    Features included in the Human View:

    • Syntax highlighting via Pygments.
    • Markdown rendering for READMEs and documentation.
    • Sidebar navigation with file links and sizes.
    • Smart filtering that automatically skips binary files and oversized files.
    • Search-friendly layout optimized for Ctrl+F usage.
  3. Install and use rendergit via pip

    master

    If you prefer a manual installation, clone the repository and install it in editable mode using pip.

    git clone https://github.com/karpathy/rendergit
    cd rendergit
    pip install -e .
    rendergit https://github.com/karpathy/nanoGPT
  4. Install and use rendergit via uv

    master

    The fastest way to install and run rendergit is using uv. This installs the tool globally and allows you to run it directly on any GitHub repository URL.

    uv tool install git+https://github.com/karpathy/rendergit
    rendergit https://github.com/karpathy/nanogpt
  5. Understand the rendergit output features

    master

    The generated HTML file provides several views designed for different use cases:

    👤 Human View

    Optimized for manual skimming and searching:

    • Directory Tree: A visual representation of the repository structure.
    • Table of Contents: A sidebar and top-level list of all rendered files with their sizes.
    • File Sections: Each file is rendered in its own section. Markdown files are converted to HTML, and code files are syntax-highlighted using Pygments.
    • Skipped Items: Collapsible sections listing binary files or files that were too large to render.

    🤖 LLM View

    Optimized for feeding repository context into Large Language Models:

    • CXML Format: A structured <documents> XML format containing <document> blocks with <source> paths and <document_content> text.
    • Easy Copying: The view includes a text area that automatically selects all text when you switch to this view, allowing for a quick Ctrl+A / Ctrl+C workflow.
  6. Use the rendergit CLI to flatten a GitHub repository

    master

    The rendergit CLI tool clones a GitHub repository and flattens its contents into a single, searchable HTML page. This page includes a directory tree, a table of contents, syntax-highlighted code, and a specialized "LLM View" containing the repository content in CXML format for easy copying into an LLM.

    Basic Usage

    Run the script with a GitHub repository URL:

    python3 rendergit.py https://github.com/owner/repo

    CLI Arguments

    ArgumentFlagDescription
    repo_urlThe GitHub repository URL (e.g., https://github.com/owner/repo or https://github.com/owner/repo.git).
    --out-oSpecify the output HTML file path. If omitted, a temporary file is created in your system's temp directory named after the repository.
    --max-bytesThe maximum file size (in bytes) to render. Files exceeding this limit are listed in the HTML but their content is skipped. Default is 51200 (50 KiB).
    --no-openPrevents the script from automatically opening the generated HTML file in your default web browser.

    Example: Customizing output and size limit

    To save the output to my_repo.html and allow files up to 1MB:

    python3 rendergit.py https://github.com/owner/repo -o my_repo.html --max-bytes 1048576
  7. Reference: rendergit CLI flags and arguments

    master

    The rendergit CLI accepts the following arguments:

    python3 rendergit.py repo_url [-o OUT] [--max-bytes BYTES] [--no-open]
    • repo_url: GitHub repo URL (https://github.com/owner/repo[.git])
    • -o, --out: Output HTML file path (default: temporary file derived from repo name)
    • --max-bytes: Max file size to render (bytes); larger files are listed but skipped (default: 51200)
    • --no-open: Don't open the HTML file in browser after generation