Skip to content

About

Interactive CLI tool to collect and format multiple code files for LLM context sharing

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

Code Collect

Interactive CLI tool to collect and format multiple code files for sharing with LLMs. Select files with a fuzzy finder, get perfectly formatted output copied to your clipboard.

Why?

When working with LLMs on coding tasks, you often need to share multiple files for context. Code Collect makes this effortless by:

  • 🎯 Interactive selection - Pick exactly the files you need with fuzzy search
  • 📋 Perfect formatting - Files formatted with paths and syntax highlighting
  • 🚀 One command - From selection to clipboard in seconds
  • 🧠 Smart filtering - Ignores binaries, build files, and common junk

Demo

$ code-collect

Scanning /Users/you/project...
Found 34 eligible files.
# Interactive fzf interface opens
Processing 6 files...
✅ Copied 6 files to clipboard!

Output format (without rendering):

// src/components/Button.tsx
```typescript
export const Button = () => {
     return "Click me"
}
```

// src/utils/helpers.py
```python
def format_data(data):
     return data.strip()
```

Installation

Prerequisites

  • Python 3.6+
  • fzf - brew install fzf (macOS) or apt install fzf (Ubuntu)

Quick Install

curl -sSL https://raw.githubusercontent.com/amadsalman/code-collect/main/install.sh | bash

Manual Install

# Clone the repository
git clone https://github.com/amadsalman/code-collect.git
cd code-collect

# Run the install script
./install.sh

Alternative Manual Install

# Download the script directly
curl -o code-collect https://raw.githubusercontent.com/amadsalman/code-collect/main/code-collect
chmod +x code-collect

# Make it globally available
sudo mv code-collect /usr/local/bin/

Usage

# Interactive selection from all files
code-collect

# Auto-collect all git modified files (staged + unstaged)
code-collect --changed

# Auto-collect only git staged files  
code-collect --staged

# Auto-collect all files (respects .gitignore)
code-collect --all

# Auto-collect all files under specific subpath
code-collect --all src/

# Scan specific directory
code-collect /path/to/project

# Auto-collect modified files from specific directory
code-collect --changed /path/to/project

Git Integration

  • --changed - Automatically collects all modified files (staged + unstaged), skips interactive selection
  • --staged - Automatically collects only staged files, perfect for pre-commit reviews
  • --all - Automatically collects all eligible files while respecting .gitignore, skips interactive selection
  • Default - Interactive fuzzy finder selection from all eligible files

Controls (Interactive Mode)

  • Arrow keys - Navigate files
  • Tab - Multi-select files
  • Enter - Confirm selection
  • Esc - Cancel

Features

  • Git integration - Auto-collect modified or staged files with --changed and --staged
  • Interactive selection - Fuzzy finder with preview for precise file picking
  • Smart file detection - Only shows text files, skips binaries
  • Gitignore integration - Respects your project's .gitignore patterns
  • Intelligent filtering - Ignores common build/cache directories
  • Size limits - Skips files over 1MB
  • Syntax highlighting - Proper language detection for 30+ file types
  • Cross-platform - Works on macOS, Linux, Windows (with WSL)

What gets ignored?

  • Everything in your .gitignore file
  • Binary files and executables
  • Common build/cache directories (.git, node_modules, dist, build, etc.)
  • IDE files (.vscode, .idea)
  • Large files (>1MB)

Contributing

Issues and PRs welcome! This tool was built to scratch a specific itch - making LLM context sharing effortless.

Running Tests

python3 test_code_collect.py

The test suite covers:

  • File detection and filtering
  • Gitignore pattern matching
  • Git integration (modified/staged files)
  • Content formatting
  • Error handling

About

Interactive CLI tool to collect and format multiple code files for LLM context sharing

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages