Skip to content

zondatw/magic-pack

Repository files navigation

Magic pack

Magic pack is a tool that makes it easy to compress and decompress files without remembering lots of commands.

Quick install

cargo install magic-pack

Ubuntu / Debian (apt)

Download the latest .deb from GitHub Releases and install:

# x86_64
wget https://github.com/zondatw/magic-pack/releases/download/v0.12.0/magic-pack_0.12.0-1_amd64.deb
sudo apt install ./magic-pack_0.12.0-1_amd64.deb

# arm64 (e.g. Raspberry Pi, AWS Graviton)
wget https://github.com/zondatw/magic-pack/releases/download/v0.12.0/magic-pack_0.12.0-1_arm64.deb
sudo apt install ./magic-pack_0.12.0-1_arm64.deb

Arch Linux (AUR)

Install from the AUR using your preferred AUR helper:

# build from source
yay -S magic-pack

# or pre-built binary (faster)
yay -S magic-pack-bin

Or manually with makepkg:

git clone https://aur.archlinux.org/magic-pack.git
cd magic-pack
makepkg -si

MCP server

Install the optional MCP server binary:

cargo install magic-pack --features mcp --bin magic-pack-mcp

Example MCP client config:

{
  "mcpServers": {
    "magic-pack": {
      "command": "magic-pack-mcp",
      "env": {
        "MAGIC_PACK_MCP_ALLOWED_ROOT": "/absolute/path/you/want/to/allow"
      }
    }
  }
}

Codex config example (~/.codex/config.toml):

[mcp_servers.magic-pack]
command = "magic-pack-mcp"

[mcp_servers.magic-pack.env]
MAGIC_PACK_MCP_ALLOWED_ROOT = "/absolute/path/you/want/to/allow"

Local test example:

{
  "mcpServers": {
    "magic-pack": {
      "command": "magic-pack-mcp",
      "env": {
        "MAGIC_PACK_MCP_ALLOWED_ROOT": "/Users/zonda/Repos/magic-pack"
      }
    }
  }
}

Codex config example (~/.codex/config.toml):

[mcp_servers.magic-pack]
command = "cargo"
args = ["run", "--features", "mcp", "--bin", "magic-pack-mcp"]
cwd = "/Users/zonda/Repos/magic-pack"

[mcp_servers.magic-pack.env]
MAGIC_PACK_MCP_ALLOWED_ROOT = "/Users/zonda/Repos/magic-pack"

After saving the MCP config, restart your MCP client so it re-runs magic-pack-mcp. Then call the tools with absolute paths inside MAGIC_PACK_MCP_ALLOWED_ROOT, for example:

compress /Users/zonda/Repos/magic-pack/temp/test_dir to /Users/zonda/Repos/magic-pack/temp/test_dir.zip as zip
decompress /Users/zonda/Repos/magic-pack/temp/test_dir.zip to /Users/zonda/Repos/magic-pack/temp/test_dir_unpacked
detect file type of /Users/zonda/Repos/magic-pack/temp/test_dir.zip
list supported formats

Commands

just all
just all-release
just quality

Skill for AI agents

The repo ships a Claude Code skill at skills/magic-pack/ that teaches other Claude / Codex agents when to invoke magic-pack and how to read its output. It's the prompt-side companion to the MCP server above — MCP gives the agent the tools, the skill teaches it which tool to pick and how to interpret the result.

Install the skill into Claude's user-global skills directory:

# clone into a stable location, then symlink — keeps the skill in
# sync if the repo updates
git clone https://github.com/zondatw/magic-pack ~/src/magic-pack
ln -s ~/src/magic-pack/skills/magic-pack ~/.claude/skills/magic-pack

Or copy just the markdown if you don't want a clone:

mkdir -p ~/.claude/skills/magic-pack
curl -L https://raw.githubusercontent.com/zondatw/magic-pack/main/skills/magic-pack/SKILL.md \
  -o ~/.claude/skills/magic-pack/SKILL.md
curl -L https://raw.githubusercontent.com/zondatw/magic-pack/main/skills/magic-pack/recipes.md \
  -o ~/.claude/skills/magic-pack/recipes.md

For OpenAI Codex, the same skills/magic-pack/ directory works — drop it under ~/.codex/skills/magic-pack/ (or symlink it) so Codex's skill discovery picks it up. The MCP wiring in ~/.codex/config.toml shown above is what gives the agent the actual tools; the skill only adds the trigger-phrase / decision-tree layer on top.

After installation the agent automatically discovers the skill via its description field; no further config edit is needed. The skill itself detects whether magic-pack-mcp / magic-pack are on PATH and falls back to surfacing the cargo install magic-pack --features mcp command if they aren't.

Command

Usage

Magic pack tool

Usage: magic-pack [OPTIONS] <--compress|--decompress> <INPUT>

Arguments:
  <INPUT>

Options:
  -c, --compress
  -f <FILE_TYPE>       [possible values: zip, tar, bz2, gz, tarbz2, targz, seven-z, xz, tarxz, zst, tarzst, lz4, tarlz4, upx]
                       (`7z` is accepted as an alias for `seven-z`)
  -d, --decompress
  -l, --level <LEVEL>  [default: 5]
  -o <OUTPUT>          [default: .]
  -p[<PASSWORD>]       7z AES-256 password; `-p` alone prompts (encryption build only)
  -q, --quiet          suppress the progress bar and result summary
  -h, --help           Print help information
  -V, --version        Print version information

While an operation runs, magic-pack shows an animated progress bar on stderr, then prints a one-line result summary (file count, sizes, compression ratio, elapsed time, and an encrypted note for password 7z) on stdout. Pass -q/--quiet to silence both — useful in scripts and pipes (errors still go to stderr). Color on the is dropped automatically when output isn't a TTY or when NO_COLOR is set.

Example

// zip
./magic-pack -c -f zip -o temp/temp.zip src
./magic-pack -d -o temp/. temp/temp.zip

// gz (single file)
./magic-pack -c -f gz -o temp/file.txt.gz temp/file.txt
./magic-pack -d -o temp/. temp/file.txt.gz

// bz2 (single file)
./magic-pack -c -f bz2 -o temp/file.txt.bz2 temp/file.txt
./magic-pack -d -o temp/. temp/file.txt.bz2

// tar
./magic-pack -c -f tar -o temp/temp.tar src
./magic-pack -d -o temp/. temp/temp.tar

// tar.bz2
./magic-pack -c -f tarbz2 -o temp/temp.tar.bz2 src
./magic-pack -d -o temp/. temp/temp.tar.bz2

// tar.gz
./magic-pack -c -f targz -o temp/temp.tar.gz src
./magic-pack -d -o temp/. temp/temp.tar.gz

// 7z
./magic-pack -c -f 7z -o temp/temp.7z src
./magic-pack -d -o temp/. temp/temp.7z

// xz (single file)
./magic-pack -c -f xz -o temp/file.txt.xz temp/file.txt
./magic-pack -d -o temp/. temp/file.txt.xz

// tar.xz
./magic-pack -c -f tarxz -o temp/temp.tar.xz src
./magic-pack -d -o temp/. temp/temp.tar.xz

// zst (single file)
./magic-pack -c -f zst -o temp/file.txt.zst temp/file.txt
./magic-pack -d -o temp/. temp/file.txt.zst

// tar.zst
./magic-pack -c -f tarzst -o temp/temp.tar.zst src
./magic-pack -d -o temp/. temp/temp.tar.zst

// lz4 (single file)
./magic-pack -c -f lz4 -o temp/file.txt.lz4 temp/file.txt
./magic-pack -d -o temp/. temp/file.txt.lz4

// tar.lz4
./magic-pack -c -f tarlz4 -o temp/temp.tar.lz4 src
./magic-pack -d -o temp/. temp/temp.tar.lz4

// upx (executable packer; requires the `upx` binary on PATH)
./magic-pack -c -f upx -o temp/hello.upx hello
./magic-pack -d -o temp/. temp/hello.upx

// auto-detect format on decompress
./magic-pack -d -o temp/. temp/temp.tar.gz

// nested archives (decompress multiple layers)
./magic-pack -d -l 3 -o temp/. temp/archive.tar.gz

// output to current directory
./magic-pack -d temp/temp.zip

UPX dependency

The upx format detects, packs, and unpacks executable binaries (PE / ELF / Mach-O) by shelling out to the upx binary. Install it separately:

# Debian / Ubuntu
sudo apt install upx-ucl

# macOS (Homebrew)
brew install upx

# Arch Linux
sudo pacman -S upx

# Windows (Scoop)
scoop install upx

Note: UPX-packed Mach-O binaries on Apple Silicon may fail to execute under macOS code-signing; UPX 5.x requires --force-macos even to produce one. For Mach-O work, prefer Linux ELF or Windows PE targets.

7z encryption (password)

AES-256 password protection for the 7z format is available in builds compiled with the encryption feature (content and filenames are encrypted):

cargo install magic-pack --features encryption
# or, with the MCP server too:
cargo install magic-pack --features "mcp encryption" --bin magic-pack-mcp

Note: the prebuilt distributions — the .deb, the AUR magic-pack-bin package, and the GitHub release binaries — are built with default features and do not include encryption (no -p flag, no MCP password arg). Use cargo install … --features encryption or build from source to get it.

Usage — -p takes the password inline, or prompts (no echo) when given alone:

# Prompt interactively (recommended — keeps the password out of `ps` and shell history)
./magic-pack -c -f 7z -p -o temp/secret.7z src
./magic-pack -d -p -o temp/. temp/secret.7z

# Inline (convenient, but the password is visible in `ps` / history)
./magic-pack -c -f 7z -p "hunter2" -o temp/secret.7z src
./magic-pack -d -p "hunter2" -o temp/. temp/secret.7z

Archives are standard AES-256 7z — 7z x -p<password> and other tools interoperate. Decrypting without -p (or with the wrong password) fails with a clear error and never echoes the password. For the MCP server, pass a password string argument to the compress / decompress tools (only advertised in encryption builds).

Reference

GNU / Linux 各種壓縮與解壓縮指令
File Magic Numbers
File

Packages

 
 
 

Contributors