Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ggrab - Grug Grab Tool

A CLI tool for manually building context to paste into llm chats. ggrab gathers functions, classes, or entire files wraps them with xml and copies it to the clipboard.

Key Features

  • Smart Extraction: Grab entire files or specific functions/classes
  • Intelligent Autocompletion: File paths and function/class names
  • Token Counting: Built-in token counting for AI context limits
  • Language Support:
    • Python (AST-based extraction)
    • JavaScript (Esprima-based extraction)
    • Other files (full file extraction)

Quick Start

  1. Install:
pip install ggrab    # Basic install
# or
pipx install ggrab   # Recommended

Why pipx? The pipx install is recommended because it:

  • Won't interfere with other Python projects (creates its own venv)
  • Makes ggrab available globally in your terminal
  1. Setup:

Add the following to your shell config file (~/.bashrc, ~/.zshrc, or equivalent):

# Enable ggrab autocompletion
eval "$(register-python-argcomplete ggrab)"

Then reload your shell configuration:

# For bash
source ~/.bashrc

# For zsh
source ~/.zshrc

Usage

# Grab entire files
ggrab file.py

# Extract specific functions
ggrab file.py function1 function2

# Mix multiple files and functions
ggrab file1.py func1 func2 file2.js func3

# Now supports full directories (entire files only)
ggrab directory

# Skip files matching a pattern
ggrab directory/ --ignore *.test.*       # Skip test files
ggrab src/ -i node_modules         # Skip node_modules directory
ggrab . -i *.spec.*                # Skip spec files
ggrab . -i dist                    # Skip dist directory
ggrab . -i *.min.*                 # Skip minified files
ggrab . -i vendor                  # Skip vendor directory
ggrab . -i '*.generated.*'         # Skip generated files (quotes needed for *)
ggrab . -i "**/__pycache__/**"     # Skip Python cache dirs (quotes needed for **)
ggrab . -i '(dist|build)/*'        # Skip multiple dirs (quotes needed for special chars)

# Multiple patterns are also supported
ggrab . -i 'dist/*' -i 'build/*'                     # Can use multiple -i flags too

Press TAB at any time for smart autocompletion:

  • After ggrab: Shows file suggestions
  • After selecting a file: Shows available functions/classes

Examples

# Extract multiple functions from a Python file
$ ggrab utils.py parse_data validate_input
Gathered code from:
  - utils.py, functions: parse_data, validate_input (203 tokens)

===== Combined Snippets (copied to clipboard) =====

# Extract from multiple files
$ ggrab api.py handle_request db.js queryDatabase
Gathered code from:
  - api.py, functions: handle_request (156 tokens)
  - db.js, functions: queryDatabase (178 tokens)

Total tokens across all files: 334

Performance Features

  • Lazy Loading: Heavy dependencies load only when needed
  • Smart Caching: Function/class listings cached for quick access
  • Hybrid Parsing: Fast regex for completion, accurate AST/Esprima for extraction

Requirements

  • Python 3.7+
  • Required: argcomplete
  • Optional but recommended:
    • pyperclip (clipboard support)
    • tiktoken (token counting)
    • esprima (JavaScript parsing)

Advanced Setup

Disable completion sorting (optional):

complete -o nosort -F _python_argcomplete ggrab

For zsh users:

autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
eval "$(register-python-argcomplete ggrab)"

Acknowledgments

  • Developed -- ok, prompted into existance by Claude 3.5, o1 pro. Fixed up to working order by Keizo Gates making GrugNotes :)

License

MIT License


For bug reports and feature requests, please open an issue on GitHub.

Metadata

Release files for ggrab 0.1.0a15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ggrab 0.1.0a15
File Size Uploaded Provenance
ggrab-0.1.0a15.tar.gz 14.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ggrab 0.1.0a15
File Interpreter ABI Platform
ggrab-0.1.0a15-py3-none-any.whl Python 3 none any Details

Total release size: 24.4 kB

Release files / ggrab-0.1.0a15.tar.gz

Download URL ggrab-0.1.0a15.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3eaf37c0c1bc16b7b95238d62bab7bbd27bd6e6fe158eac5fc772583435cb746
BLAKE2b-256 checksum
How to use checksums
d3f7874860560b819a52551451355e6a2b8e1f7476c21558b82e78162396614c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 30, 2024.

Transparency log

Release files / ggrab-0.1.0a15-py3-none-any.whl

Download URL ggrab-0.1.0a15-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fb41cc168e8d3b6418edb4d68abd6c1e9f08ac80b54f7b75e067d4e9fa1736a
BLAKE2b-256 checksum
How to use checksums
0ed46061a45de464efef7f771706c33575e6a89ce90224c0ba88e1144ad73092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 30, 2024.

Transparency log

Security for ggrab 0.1.0a15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ggrab-0.1.0a15.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 30, 2024.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page