llm-copy
v2.0.0
Published
CLI tool to harvest code snippets from a directory, optimized for LLM export
Maintainers
Readme
llm-copy
A simple CLI tool to harvest code snippets from a specified directory, prefix each file with its relative path and output a combined stream ready for Large Language Model (LLM) ingestion.
Features
- Recursively collects all files under a target directory.
- Prefixes each file with a comment header showing its relative path.
- Supports Node.js v16+.
- Uses native clipboard utilities (
pbcopy,clip,xclip,xsel) when available. - Falls back to writing output to
stdoutif no clipboard utility is found. - Easy installation via
npmornpx.
Prerequisites
- Node.js v16 or higher
- npm (comes with Node.js)
- Optional: native clipboard utility (macOS:
pbcopy; Windows:clip; Linux:xcliporxsel)
Installation
Install globally via npm:
npm install -g llm-copyOr use npx without global installation:
npx llm-copy <directory>Usage
Run the CLI against a directory to collect and copy code snippets:
# Harvest snippets from src/
llm-copy ./srcIf a clipboard utility is detected, the combined output is copied to the clipboard.
Otherwise, the output is printed to stdout.
Development
Clone the repository and install dependencies:
git clone https://github.com/yourusername/llm-copy.git
cd llm-copy
npm install # runs `prepare` to buildBuild
npm run buildLink for Local Testing
npm linkThis makes the llm-copy command available globally on your machine for testing.
Tests
Run unit and integration tests with Jest:
npm testLicense
This project is licensed under the MIT License. See the LICENSE file for details.
