copyfiles-cli

Generate a copyfiles.txt containing project tree + file contents.


Keywords
llm, context, project-tree, cli
License
MIT
Install
pip install copyfiles-cli==0.1.8

Documentation

copyfiles-cli

copyfiles-cli is a small but mighty CLI that scans a project directory, filters out junk via .gitignore-style rules, and spits out a single copyfiles.txt containing:

  1. Project tree – an indented outline of kept files and folders.
  2. File contents – each retained file wrapped in a language-tagged code fence.

It’s perfect for piping an entire repo into an LLM prompt or sharing a compact “snapshot” of code with teammates.


Features

Feature What it does
Smart filtering Honors your project’s .gitignore, plus optional extra ignore file (--config).
Size guards & truncation Skip very large files (--skip-large) or keep only the first N bytes (--max-bytes).
Colorful, pretty CLI Rich / Colorama styling with automatic NO_COLOR detection.
Zero-config defaults Run copyfiles in any repo and get a sane copyfiles.txt instantly.

Installation

# Recommended: inside a virtualenv
pip install copyfiles-cli           # from PyPI
# or, for local development
git clone https://github.com/yourname/copyfiles
cd copyfiles
pip install -e '.[dev]'         # installs package + test/QA deps

Requires Python 3.8+


Quick Start

# From your project root
copyfiles

# Generates ./copyfiles.txt:
# ├── app.py
# ├── module/
# │   └── __init__.py
# └── README.md

Open copyfiles.txt in any editor or paste it directly into ChatGPT / Gemini – you’ll see an ASCII tree followed by each file’s contents inside code fences.


Advanced CLI Flags

Flag Default Purpose
--root PATH . Directory to scan.
--out FILE copyfiles.txt Output file name/path.
--config FILE none Extra ignore patterns (one per line, same syntax as .gitignore).
--max-bytes N 100 000 Truncate individual files to the first N bytes.
--skip-large KB off Skip files larger than KB kilobytes entirely.
-v / --verbose off Show scanning / filtering progress.
--no-color off Force plain-text output (useful in CI).
-V / --version Print version and exit.
--help Full help text with examples.

Contributing

  1. Fork & clone the repo.

  2. Create a virtualenv and install dev deps:

    python -m venv .venv && source .venv/bin/activate
    pip install -e '.[dev]'
  3. Run the entire QA suite before submitting a PR:

    pytest          # unit + CLI tests
    tox -p auto     # multi-python matrix + lint
    ruff check src tests  # additional lint if you like
  4. Commit using conventional commits (feat: …, fix: …, etc.) and open a pull request – GitHub Actions will run the same tox matrix.

Project Layout

src/copyfiles/       # library & CLI
tests/               # unit and CLI tests + fixtures
README.md
pyproject.toml
tox.ini

Licence

MIT – see LICENSE file for full text.


Made with ☕, 🐍, and a sprinkle of Rich ANSI sparkle.