Skip to main content

Generate README.md from any GitHub or local repository

Project description

repo2readme

Generate a professional README.md from any GitHub or local repository. This tool analyzes your project structure and file contents, then leverages AI models to intelligently craft a comprehensive and informative README.

๐ŸŒŸ Table of Contents

About the Project

repo2readme is a command-line interface (CLI) tool designed to
automate the creation of high-quality README.md files. It intelligently scans your repository, summarizes key files, and then
iteratively generates and refines a README using advanced AI agents. Whether your project is hosted on GitHub or resides locally, repo2readme streamlines documentation, ensuring your projects are
well-explained and easily understood.

Tech Stack

The repo2readme project leverages a modern Python ecosystem for its
functionality:

  • ๐Ÿ Python (>=3.10)
  • ๐Ÿ› ๏ธ Setuptools
  • ๐Ÿ–ฑ๏ธ Click: For building intuitive command-line interfaces.
  • โœจ Rich: For beautiful terminal output and progress displays.
  • โš™๏ธ GitPython: For programmatic interaction with Git repositories.
  • ๐Ÿ”‘ python-dotenv: For managing environment variables.
  • ๐Ÿฆœ LangChain: A framework for developing applications powered by
    language models.
  • ๐ŸŒ LangChain Community: Community integrations for LangChain.
  • ๐Ÿง  LangChain Groq: Integration for Groq language models.
  • ๐Ÿ“š LangChain Google GenAI: Integration for Google Generative AI
    models.
  • ๐Ÿ’จ Groq: For fast inference with language models (specifically
    openai/gpt-oss-120b for summarization).
  • ๐Ÿš€ Google GenAI: For accessing Google Gemini models (gemini-2.5-flash for README generation and review).
  • Pydantic: For data validation and settings management (used in
    reviewer agent schema).
  • os, json, tempfile, shutil, stat, operator, typing: Standard Python libraries for system interactions, data handling, and type hinting.

Key Features

  • Repository Analysis: Automatically loads files and content from GitHub URLs or local directories.
  • Intelligent Summarization: Uses a Groq LLM to summarize
    individual source files, capturing their purpose and functionality.
  • Hierarchical Tree Generation: Creates a visual representation
    of your repository's directory structure.
  • AI-Powered README Creation: Employs a Google Gemini model to
    draft comprehensive and structured README.md content.
  • Iterative Refinement: Utilizes an agent-based workflow with a
    reviewer agent (Google Gemini) to iteratively score and improve the
    generated README until a high-quality standard is met.
  • API Key Management: Securely stores and manages API keys for
    Groq and Google Gemini services in your local environment.
  • File Filtering: Automatically ignores common development
    artifacts (.git, node_modules, __pycache__, etc.) to focus on
    relevant project files.

Folder Structure

Repo2Readme/
    โ”œโ”€โ”€ LICENSE
    โ”œโ”€โ”€ pyproject.toml
    โ”œโ”€โ”€ repo2readme/
        โ”œโ”€โ”€ config.py
        โ”œโ”€โ”€ cli/
            โ”œโ”€โ”€ main.py
        โ”œโ”€โ”€ loaders/
            โ”œโ”€โ”€ loader.py
            โ”œโ”€โ”€ repo_loader.py
        โ”œโ”€โ”€ readme/
            โ”œโ”€โ”€ agent_workflow.py
            โ”œโ”€โ”€ readme_generator.py
            โ”œโ”€โ”€ reviewer_agent.py
        โ”œโ”€โ”€ summerize/
            โ”œโ”€โ”€ summary.py
        โ”œโ”€โ”€ utils/
            โ”œโ”€โ”€ detect_language.py
            โ”œโ”€โ”€ filter.py
            โ”œโ”€โ”€ force_remove.py
            โ”œโ”€โ”€ tree.py

Installation

To install repo2readme, you need Python 3.10 or higher.

  1. Clone the repository (optional, if installing from source):

    git clone https://github.com/agsaru/repo2readme.git
    cd repo2readme
    
  2. Install the package:

    pip install repo2readme
    

Usage

repo2readme provides two main commands: run to generate a README
and reset to clear your stored API keys.

1. Generate a README

Use the run command with either a GitHub repository URL or a local
path.

From a GitHub Repository URL:

repo2readme run --url https://github.com/agsaru/repo2readme -o
README_NEW.md

From a Local Repository Path:

repo2readme run --local ./path/to/your/repo -o README_LOCAL.md

Options:

  • -u, --url <URL>: GitHub repository URL to process.
  • -l, --local <PATH>: Path to a local repository.
  • -o, --output <FILE_PATH>: File path to save the generated
    README (defaults to README.md).

2. Reset API Keys

To clear your stored Groq and Google Gemini API keys:

repo2readme reset

This will delete the configuration file storing your keys, prompting
you to re-enter them on the next run command.

Configuration

repo2readme requires API keys for Groq and Google Gemini to interact with large language models. These keys can be provided either as
environment variables or will be prompted for and saved locally.

API Keys

  • GROQ_API_KEY: Required for accessing the Groq LLM (used for
    file summarization).
  • GOOGLE_API_KEY: Required for accessing Google Generative AI
    (Gemini) models (used for README generation and review).

When repo2readme run is executed for the first time or if keys are
missing, the CLI will interactively prompt you to enter them. These
keys are then saved in a JSON file at ~/.repo2readme_env.json for
future use.

Alternatively, you can set these as system environment variables:

export GROQ_API_KEY="your_groq_api_key"
export GOOGLE_API_KEY="your_google_api_key"

How It Works

The repo2readme tool orchestrates a sophisticated workflow to
generate a README:

  1. Repository Loading:

    • Based on your input (GitHub URL or local path), a RepoLoader determines whether to use a UrlRepoLoader (which clones the GitHub
      repository into a temporary directory) or a LocalRepoLoader (which
      reads from your local filesystem).
    • During loading, an intelligent filter (github_file_filter) is applied to ignore irrelevant files and directories (e.g., .git,
      node_modules, package-lock.json, .env, various binary or data
      files), focusing only on source code and essential project files.
  2. Repository Structure & File Analysis:

    • A visual directory tree (generate_tree) is constructed,
      providing a clear overview of the project's structure.
    • For each relevant file, its programming language is detected
      (detect_lang) based on its extension.
    • A summarize_file function is then invoked, which uses a
      specialized LangChain chain powered by the Groq LLM (openai/gpt-oss-120b) to generate a concise, JSON-formatted summary
      of the file's content and purpose. This summary is tailored for README generation.
  3. Iterative README Generation Workflow:

    • The core of the README creation is handled by a LangGraph
      state machine
      . This machine iteratively generates, reviews, and
      refines the README.
    • Generation Node: The generate_readme_node utilizes a
      Google Gemini 2.5 Flash model via LangChain. It takes all file
      summaries, the repository tree structure, any previous README content, and reviewer feedback to produce a new README.md draft.
    • Review Node: The readme_reviewer_node also uses a
      Google Gemini 2.5 Flash model. This agent evaluates the latest
      README draft, assigns it a quality score (1-10), and provides constructive feedback for improvement.
    • Conditional Loop: The workflow continues looping between
      generation and review. The process stops when the generated README
      achieves a score of 8.5 or higher, or if a maximum number of iterations is reached, ensuring a high-quality output while preventing infinite
      loops.
  4. Output:

    • The best-scoring README.md generated during the iterative
      process is selected.
    • This final README content is then either printed to the
      console or saved to the specified output file (defaulting to README.md).

Throughout this process, repo2readme/config.py manages the secure
loading and saving of API keys, prompting the user for input if
necessary. Temporary directories created during remote repository
cloning are also safely cleaned up using force_remove.

License

This project is licensed under the MIT License.

Copyright (c) 2025 Sarowar Jahan Biswas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

repo2readme-1.0.2.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

repo2readme-1.0.2-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file repo2readme-1.0.2.tar.gz.

File metadata

  • Download URL: repo2readme-1.0.2.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for repo2readme-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c1cd155f91e1f95cd0652eef96fde03246fa24aa5e4f33769730db522388a97c
MD5 24fe357cd4e9db83ade5544bb4403d13
BLAKE2b-256 c4af9512db347131870d02d5876223f9ed067feff222c94a22428093d517ceb1

See more details on using hashes here.

File details

Details for the file repo2readme-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: repo2readme-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for repo2readme-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a42c469ac7078c1c4474a809d1b030c0c93e07bfed215f5cc321bcb2c2fa3619
MD5 e3909f574de35fc917ec6ba4bf6a96b1
BLAKE2b-256 55c39d2defb8b85ed975a5e60d9afac1f6fd12bd018ab9f939f0d0d1ef68a5b3

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