Project

grab

Command-line tool that pulls individual tools out of a monorepo into any project, with no submodules and no copy-paste

PersonalView project

Technologies used

BashGit

Project details

About the Project

Everyone keeps a folder of useful scripts copied from project to project. Over time they drift: a fix lands in one place and nowhere else, and you lose track of which version is the good one.

grab solves this with one rule: the monorepo is the source of truth, and every project pulls only what it needs.

In practice, a mix between npm install and git sparse-checkout.

What it brings

  • No submodules, no vendoring to maintain
  • Partial clone (--filter=blob:none and sparse-checkout): only the requested tool is downloaded
  • Per-project manifest (.grabfile): anyone cloning the project runs grab install and gets the same tools
  • Pinning to a branch or a tag, tool by tool
  • Hooks: a tool can ship a post-grab.sh that finishes its own installation, for example moving a .devcontainer/ to the project root
  • Publishing: grab publish . sends a tool built on its own into the monorepo, without copy-paste

How it works

grab init git@github.com:me/tools.git   # once per project
grab add stripe-cli                     # pull a tool
grab add docker-utils @v2.1             # pinned to a tag
grab exec stripe-cli listen             # run it

On add, the script sparse-clones the monorepo into a local cache, materializes only the requested directory, copies it into .grab/tools/, records it in .grabfile and adds .grab/ to .gitignore. Cache and tools stay out of the project repository.

Details that matter

Two traps took me longer than the rest. grab publish . run from a folder already managed by grab copied its own cache into the monorepo, so publishing now goes through a throwaway clone, never the project cache. And nested .git directories are dropped during the copy, otherwise you publish a repository inside a repository.

Hooks ask for confirmation before running, since they come from the monorepo and touch the project: --hook and --no-hook settle it once and for all.

Takeaway

A single-file bash script with no dependency beyond git. It is exactly the kind of tool grab exists to distribute: it distributes itself.

Experience : Personal