Files

2.5 KiB

cliprepo

cliprepo is a lightweight, efficient CLI tool written in Go that helps you package your repository's file tree and source code content into a formatted Markdown block. It is designed to quickly build comprehensive context for Large Language Models (LLMs) like GPT, Claude, or DeepSeek.

Features

  • File Tree Generation: Automatically generates a clean ASCII directory tree, honoring your .gitignore rules.
  • Flexible File Filtering: Match files using flexible presets (*, cmd/*, or specific file paths).
  • Gitignore Smart Filtering: Automatically skips files and directories specified in your .gitignore (e.g., .git, node_modules, .DS_Store).
  • Clipboard Integration: Directly copies the generated prompt to your clipboard—no manual file saving required.
  • Customizable Templates: Define how your code blocks are presented to the LLM via a YAML configuration file.

Installation

Ensure you have Go installed (version 1.26 or higher), then clone the repository and run:

chmod +x install.sh
./install.sh

This will compile and install the cliprepo binary into your $GOPATH/bin directory.

Configuration

Create a .cliprepo.yaml file in the root of your project to manage path modes, custom prompt templates, and file group presets:

config:
  path_mode: relative # Options: 'relative' or 'absolute'

prompts:
  preset: "The following code is from file {{path}}:\n---\n{{content}}"

preset:
  all: 
    - "*" # Scans and includes all tracked files in the repo

  internal:
    - "internal/tree/*"
    - "internal/resolver/resolver.go"

  cmd:
    - "cmd/*"

Usage

Run the tool using the run command by specifying a preset key defined in your .cliprepo.yaml.

Print to Terminal

cliprepo run --delineate cmd

Copy Directly to Clipboard

cliprepo run --delineate all --clipboard

Flags

  • --delineate (string): The preset key to use from .cliprepo.yaml (Required).
  • --clipboard (bool): Copy the output directly to your system clipboard instead of printing it to stdout.

Output Example

When running cliprepo run --delineate cmd, the output format will look like this:

.
├── cmd
│   ├── root.go
│   └── run.go
└── main.go

The following code is from file cmd/root.go:
---
package cmd
...

The following code is from file cmd/run.go:
---
package cmd
...

License

MIT License