Skip to main content

Turn git repository information into LLM prompt context

Project description

git-to-prompt

A command-line tool for turning Git repository information into context for LLM prompts.

Inspired by files-to-prompt, this tool focuses on git history instead of files, making it easy to include repository history in your prompts to LLMs like Claude and GPT.

This tool was largely written using Claude 3.7 Sonnet, and is very lightly tested.

Installation

Install directly from the repository using uv:

uv tool install git-to-prompt

Usage

Basic usage

Get all the commits from the current repository:

git-to-prompt log

Get all the diffs in this branch back off master:

git-to-prompt log master..HEAD --patch

Show a single commit (patches included by default):

git-to-prompt show <commit-ish>

This outputs Git commits in a Claude XML format that's well-suited for LLM prompting.

Options

Usage: git-to-prompt log [<options>] [<revision-range>] [[--] <path>...]

  Generate a formatted log of git commits suitable for LLM prompts.

  Outputs in Claude XML format, which is designed to be easily parseable by large
  language models while maintaining the structured nature of git commit data.

Arguments:
  <revision-range>   Revision range (e.g., 'HEAD~5..HEAD')
  <path>...          Paths to filter commits by (only commits affecting these paths will be shown)

Options:
  -n, --max-count INTEGER       Maximum number of commits to show
  -p, -u, --patch / --no-patch  Include commit diffs in the output (default: false)
  -o, --output PATH             Output file (defaults to stdout)
  --repo-path DIRECTORY         Path to the Git repository (defaults to current directory)
  --help                        Show this message and exit.

Examples:
  # Get the last 5 commits with diffs attached
  git-to-prompt log -n 5 --patch

  # Get commits between two revisions
  git-to-prompt log "v1.0..v2.0"

  # Output to a file
  git-to-prompt log -o log.xml

  # Filter commits by path (using -- syntax, just like git)
  git-to-prompt log -- path/to/file.py

  # Filter commits by multiple paths
  git-to-prompt log -- path/to/file.py another/path

  # Combine with revision range and paths
  git-to-prompt log HEAD~10..HEAD path/to/file.py

  # Show a single commit (includes patch unless --no-patch is passed)
  git-to-prompt show HEAD~3

Output Format

The output is formatted as XML, which works particularly well with Claude's XML parsing capabilities (indents included for readability):

<commits>
<commit index="1">
  <sha>60122e857891a3dab3a93846c2e6447c2af75adb</sha>
  <short_sha>60122e8</short_sha>
  <author>Bob Bobkins <bob@example.com></author>
  <authored_date>2025-03-04T13:05:29-05:00</authored_date>
  <committer>Bob Bobkins <bob@example.com></committer>
  <committed_date>2025-03-04T13:05:29-05:00</committed_date>
  <subject>more hype</subject>
  <parents>
    <parent>c9560686a132206738cd1ea4952039a05f964b60</parent>
  </parents>
  <patch>
    <file path="README.md" change_type="M" insertions="1" deletions="1">
      <diff>
           1  @@ -1 +1 @@
             -My New Project
           2  +My AWESOME Project
      </diff>
    </file>
  </patch>
  <message>
    more hype
  </message>
</commit>
<commit index="2">
  <sha>c9560686a132206738cd1ea4952039a05f964b60</sha>
  <short_sha>c956068</short_sha>
  <author>Bob Bobkins <bob@example.com></author>
  <authored_date>2025-03-04T13:05:03-05:00</authored_date>
  <committer>Bob Bobkins <bob@example.com></committer>
  <committed_date>2025-03-04T13:05:03-05:00</committed_date>
  <subject>init repo</subject>
  <patch>
    <file path="README.md" change_type="A" insertions="1" deletions="0">
      <diff>
           1  @@ -0,0 +1 @@
           2  +My New Project
      </diff>
    </file>
  </patch>
  <message>
    init repo
  </message>
</commit>
</commits>

Development

Build

To build the project:

just build

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

git_to_prompt-0.1.3.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

git_to_prompt-0.1.3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file git_to_prompt-0.1.3.tar.gz.

File metadata

  • Download URL: git_to_prompt-0.1.3.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_to_prompt-0.1.3.tar.gz
Algorithm Hash digest
SHA256 98862cfbfd5689c7f56fe1764f7f6f704c979af823868c8b0eaea06f3ffc5608
MD5 af9aeed97c998724fb61f97c054b82a6
BLAKE2b-256 f34fe7731bcb0556d244b81844837c7a9849b76a04c1002946f7f1dcb1124119

See more details on using hashes here.

File details

Details for the file git_to_prompt-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: git_to_prompt-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_to_prompt-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e30eac8ca4cfb25e9b2e45c89f5f6490a6b40f6815826b65dc93a4901d71350c
MD5 e67fd356b04d1360c0c91b649f601f44
BLAKE2b-256 9a76ae545dcd1af76a170d06381bcaf1ee90cea660ee42b2c7a5e521cf30e399

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