zip-unzip-cli

star 6

Use this skill whenever the user wants to compress or decompress files with zip or unzip inside the Xpert sandbox. Trigger when they mention creating zip archives, extracting zip files, listing archive contents, testing integrity, excluding files during compression, password-based extraction, or split zip archives.

xpert-ai By xpert-ai schedule Updated 3/25/2026

name: zip-unzip-cli description: Use this skill whenever the user wants to compress or decompress files with zip or unzip inside the Xpert sandbox. Trigger when they mention creating zip archives, extracting zip files, listing archive contents, testing integrity, excluding files during compression, password-based extraction, or split zip archives.

Zip/Unzip CLI Skill

This skill explains how to use the system zip and unzip commands inside the Xpert sandbox through sandbox_shell.

Mandatory Workflow

  1. Run archive commands through sandbox_shell.
  2. Before first use in a session, read this file with:
    cat /workspace/.xpert/skills/zip-unzip/SKILL.md
    
  3. Use Ubuntu/Linux shell syntax.
  4. Avoid interactive commands. The sandbox is non-interactive.

Core Operations

Compress Files or Directories

Basic compression:

zip archive.zip file1.txt file2.txt
zip -r archive.zip directory/

Compression levels (1 = fastest, 9 = best compression):

zip -1 fast.zip largefile.txt
zip -9 small.zip largefile.txt

Preserve symlinks:

zip -ry archive.zip directory/

Extract Archives

Extract to current directory:

unzip archive.zip

Extract to a specific directory:

unzip archive.zip -d /path/to/destination/

Extract specific files:

unzip archive.zip file1.txt folder/file2.txt

Choose overwrite behavior explicitly when files may already exist:

unzip -o archive.zip
unzip -n archive.zip

View Archive Contents

List files:

unzip -l archive.zip

Detailed listing with sizes and dates:

unzip -v archive.zip

Test archive integrity:

unzip -t archive.zip

Password Handling

Non-interactive password extraction

unzip -P mypassword secure.zip -d /tmp/extracted

Non-interactive password creation

zip -P mypassword secure.zip sensitive_file.txt

zip -P and unzip -P are non-interactive, but the password is visible in the command line, shell history, and process listing. Only use them when the user explicitly provided the password and understands that tradeoff.

Do not use interactive password prompts

zip -e secure.zip sensitive_file.txt

Do not use zip -e in sandbox_shell. It prompts for a password and can hang. The middleware blocks it.

Excluding Files

Exclude specific files or patterns:

zip -r archive.zip project/ -x "*.log" "*.tmp" "*/node_modules/*" "*/.git/*"

Exclude hidden files:

zip -r archive.zip directory/ -x "*/.*"

Quote glob patterns so the shell does not expand them before zip receives them.

Split Archives

Create a split archive (size in k, m, or g):

zip -r -s 100m large.zip bigdirectory/

Reassemble and extract a split archive:

zip -F large.zip --out complete.zip
unzip complete.zip

Update Existing Archives

Add files to an existing archive:

zip archive.zip newfile.txt
zip -r archive.zip newfolder/

Update changed files only:

zip -u archive.zip file.txt

Delete files from an archive:

zip -d archive.zip unwanted.txt "*.log"

Common Patterns

Backup with a timestamp

zip -r backup_$(date +%Y%m%d_%H%M%S).zip /path/to/data/

Quiet extraction

unzip -q archive.zip

Preserve Unix attributes when needed

zip -rX archive.zip directory/

Sandbox Notes

  • This middleware checks and installs zip / unzip automatically inside the sandbox. Do not suggest apt or sudo as the first step.
  • If unzip might overwrite files, explicitly choose -o or -n instead of relying on a prompt.
  • Prefer the smallest command that matches the user request.
  • After creating an archive, consider verifying it with unzip -t archive.zip.

Quick Reference

Task Command
Compress file zip archive.zip file.txt
Compress directory zip -r archive.zip dir/
Extract unzip archive.zip
Extract to path unzip archive.zip -d /path/
Extract with password unzip -P mypassword secure.zip -d /path/
List contents unzip -l archive.zip
Exclude pattern zip -r archive.zip dir/ -x "*.log"
Split 100MB zip -r -s 100m archive.zip dir/
Delete from archive zip -d archive.zip file.txt
Test integrity unzip -t archive.zip
Install via CLI
npx skills add https://github.com/xpert-ai/xpert-plugins --skill zip-unzip-cli
Repository Details
star Stars 6
call_split Forks 10
navigation Branch main
article Path SKILL.md
More from Creator