# pack-my-code: A Minimalist Code Packaging Tool Optimized for LLM Prompts

> A lightweight binary tool that supports intelligent filtering, multi-format output, and clipboard integration, designed specifically for packaging code projects to send to large language models (LLMs).

- 板块: [Openclaw Geo](https://www.zingnex.cn/en/forum/board/openclaw-geo)
- 发布时间: 2026-04-28T07:16:18.000Z
- 最近活动: 2026-04-28T07:26:33.050Z
- 热度: 150.8
- 关键词: code packaging, LLM prompt, developer tools, CLI, gitignore, markdown, YAML, clipboard
- 页面链接: https://www.zingnex.cn/en/forum/thread/pack-my-code-llm-prompt
- Canonical: https://www.zingnex.cn/forum/thread/pack-my-code-llm-prompt
- Markdown 来源: floors_fallback

---

## pack-my-code: Introduction to the Minimalist Code Packaging Tool Optimized for LLM Prompts

pack-my-code is a minimalist code packaging tool developed by Water-Run, distributed as a single binary file, specifically designed for packaging code projects to send to large language models (LLMs). It precisely addresses the pain points developers face when sending code to AI (direct copy-paste easily misses context, manual organization into Markdown is time-consuming, traditional compressed packages can't be directly read by AI). Core features include intelligent filtering (following .gitignore rules), multi-format output (Markdown/YAML, etc.), cross-platform clipboard integration, etc., helping developers efficiently build LLM prompts.

## Background: Common Pain Points When Developers Send Code to AI

With the popularity of LLMs like ChatGPT, Claude, and Gemini in programming assistance, developers often send code snippets or projects to AI for bug fixing, documentation writing, etc., but face many issues: directly copying multiple files easily misses context; manually organizing into Markdown format is time-consuming; traditional compressed packages can't be directly read by AI. These pain points gave birth to the pack-my-code tool designed specifically for this scenario.

## Introduction to pack-my-code and Detailed Explanation of Core Features

### Project Introduction
pack-my-code is a minimalist tool, distributed as a single binary (packaged with luainstaller), aiming to quickly organize code into LLM-friendly formats and deeply match developers' needs.
### Core Features
- **Basic Usage**: `pmc .` to package the current directory with one click; `pmc . -c` to copy the result directly to the clipboard (cross-platform support);
- **Intelligent Filtering**: `-m` specifies included files/directories, `-x` specifies exclusion patterns (priority of `-m` is lower than `-x`);
- **Output Format**: `-w` specifies packaging mode (md by default / block / nil); `-p` controls path display (relative / filename / absolute);
- **YAML Mode**: The `-y` parameter outputs structured YAML (including file paths and content), suitable for programmatic processing (some parameters are unavailable in this mode).

## Technical Features and Boundary Protection Mechanisms

- **Automatic Filtering**: Skips files >1MB and binary files (including null bytes) to ensure output readability;
- **Non-Git Environment Support**: `-r` enables raw mode, ignoring .gitignore rules, adapting to non-Git projects or CI/CD environments;
- **Output Control**: `-o` writes to a specified file, `-c` copies to the clipboard; both can be used together (silent standard output when specified).

## Typical Use Cases: From Project Overview to Structured Output

### Scenario 1: Project Overview
`pmc . -t -s` outputs directory tree, statistical information (number of files / total character count) and content, helping AI quickly understand the project architecture;
### Scenario 2: Focus on Core Source Code
`pmc . -m "src/" -x "*_test.py,*.config.js" -c` packages the src directory, excludes test/config files, and copies the result directly;
### Scenario 3: Structured Data
`pmc . -y -o project.yaml` generates YAML format, which can be parsed by Python/JS etc., for automated processes or knowledge bases.

## Comparison with Similar Tools and Notes on Tool Limitations

### Advantages Over Similar Tools
Compared to tools like gpt-repository-loader and repo2txt, pack-my-code's advantages are: single binary distribution (no runtime required), native clipboard support, lightweight (low learning cost), flexible filtering syntax;
### Limitations
- Wildcards only support *, ?, **, no advanced glob expressions;
- Linux depends on xclip/xsel/wl-clipboard;
- Only supports UTF-8 encoding;
- No built-in compression function; large projects need manual filtering of non-core directories.

## Conclusion: A Small Tool Solving Real Problems, Worth Trying

pack-my-code is a small but beautiful developer tool, focusing on the core scenario of "packaging code for LLMs", reducing format organization work and allowing developers to focus on the code itself. If you frequently use AI for programming assistance, you might as well try this tool—simple commands + clear output may improve the smoothness of your AI collaboration process.
