πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Sign inDemoInstall
Socket

code2clipboard

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code2clipboard

A utility that scans any codebase and generates prompts directly to your clipboard, ready to be pasted into your preferred AI assistant.

0.1.3
Source
PyPI
Maintainers
1

Code2Clipboard

Effortlessly transform your codebase into AI-ready prompts and insights.

πŸš€ What is Code2Clipboard?

Code2Clipboard is a developer utility that scans your codebase, tokenizes content, and generates LLM-ready prompts directly to your clipboard. With features like directory tree visualization, token count preview, and whole project prompt generation, it’s designed to save time and supercharge your workflow.

It will will to add to your prompt a full context of your project, so that your prefered AI Assistant can produce the best possible answer.

✨ Features

  • πŸ” Prompt Generator: Automatically turn your code into structured, tokenized prompts for large language models (LLMs).
  • πŸ—‚οΈ Directory Tree Viewer: Generate token-aware, human-readable directory trees with file sizes and token counts.
  • πŸ“‹ Clipboard-Ready: Instantly copy file contents, summaries, or prompts to your clipboard for seamless pasting.
  • πŸ“¦ Token Insights: Analyze token usage across your codebase for any OpenAI-compatible model.
  • βš™οΈ Customizable: Include/exclude files, set maximum file sizes, and optionally include hidden files.
  • πŸ–‡οΈ File Merger: Merge multiple files into a single clipboard-ready text with contextual headers.

πŸ“₯ Installation

pip install code2clipboard

2. From Source

Clone the repository and install locally:

git clone https://github.com/domguia/code2clipboard.git
cd code2clipboard
pip install .

Or install directly from GitHub:

pip install git+https://github.com/domguia/code2clipboard.git

πŸ› οΈ Usage

After installation, the code2clipboard CLI is ready to use. By default, it merges files and displays a directory tree:

code2clipboard

πŸ”§ Options

  • --tree: Display the directory tree with token counts and file sizes (no merge).
  • --tokens: Only display the total token count (no tree or merge).
  • --include: Include specific file patterns (e.g., *.py, *.md).
  • --exclude: Exclude specific file patterns (e.g., *.log, node_modules/).
  • --add-hidden: Include hidden files and directories.
  • --max-file-size: Set a maximum file size (default: 20KB).

Examples

  • Generate a directory tree:

    code2clipboard --tree
    
  • Analyze tokens in Python files only:

    code2clipboard --tokens --include '*.py'
    
  • Merge files into a clipboard-ready prompt:

    code2clipboard --include '*.py' '*.md'
    
  • Include hidden files and exclude logs:

    code2clipboard --add-hidden --exclude '*.log'
    

πŸ“‹ Output Examples

Default Behavior (Merge + Tree)

code2clipboard

Output:

project/        - 32kb ~6.2k tokens
β”œβ”€β”€ main.py     - 12kb ~3k tokens
β”œβ”€β”€ utils.py    - 8kb ~2k tokens
└── README.md   - 2kb ~512 tokens

(Tree copied to clipboard.)
(All file contents merged and copied to clipboard.)

Tree Only

code2clipboard --tree

Output:

project/        - 32kb ~6.2k tokens
β”œβ”€β”€ main.py     - 12kb ~3k tokens
└── utils.py    - 8kb ~2k tokens

(Tree copied to clipboard.)

Token Analysis

code2clipboard --tokens

Output:

Estimated total tokens: 6.2k

πŸ§‘β€πŸ’» Why Developers Love Code2Clipboard

  • Speed Up Prompt Creation: Build prompts directly from your codebase, no manual copy-pasting required.
  • Token Awareness: Tailor your prompts to fit within LLM token limits effortlessly.
  • Clipboard Integration: Skip the file-by-file workflowβ€”copy everything you need in one go.
  • Customizable Workflow: Filter by file types, exclude directories, or focus on specific content.

🀝 Contributing

We welcome contributions from the community! Here’s how you can get started:

  • Fork this repository.
  • Create a feature branch: git checkout -b feature-name.
  • Commit your changes: git commit -m "Add some feature".
  • Push to your branch: git push origin feature-name.
  • Open a Pull Request.

πŸ“„ License

This project is licensed under the MIT License.

🌟 Feedback & Support

Found an issue or have a feature request? Open an issue on GitHub Issues. We’d love to hear your feedback!

Happy coding! πŸš€

Key Points in This README

  • Attractive hooks: The project is framed as an indispensable utility for developers working with AI models.
  • Installation clarity: Options for PyPI, GitHub, and local installations make it approachable.
  • Concise examples: Highlight real-world use cases for the tool, appealing directly to the pain points of developers.
  • Encourages contributions: A clear "Contributing" section invites the open-source community to engage.

Let me know if you need help with any specific section!

Keywords

tree

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts