npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trees-cli

v0.1.3

Published

Git worktree manager — switch branches like cd

Downloads

249

Readme

trees

Git worktree manager — switch branches like cd.

Git's worktree interface is powerful but clunky. trees wraps it in a simple, opinionated CLI so jumping between branches feels natural.

tree up my-feature   # create worktree + cd into it
tree down            # cd back to main
tree list            # see all worktrees + dirty status
tree switch          # interactive picker
tree remove my-feature

Installation

npm install -g trees-cli
source ~/.zshrc   # or ~/.bashrc

The install automatically adds a tree shell function to your ~/.zshrc and/or ~/.bashrc. This wrapper is needed because a Node process can't change your shell's directory — tree runs trees under the hood and handles the cd for you.

Commands

tree up <branch>

Switch to a branch worktree, creating it if it doesn't exist yet.

tree up main              # switch to main
tree up feature/my-work   # create worktree + switch

Worktrees are stored at ~/.trees/repositories/<repo>/<branch>.

If a setup hook is configured, it runs automatically when a new worktree is created (not on subsequent switches).

tree down

Return to the main (non-worktree) copy of the repo.

tree remove <branch>

Remove a worktree. If you're currently inside it, you'll be moved to the main repo first.

tree remove feature/my-work

tree list

Show all worktrees for the current repo with their dirty status.

BRANCH          STATUS  PATH
──────────────────────────────────────────────────────
main            clean   ~/projects/my-app
feature/auth    dirty   ~/.trees/repositories/my-app/feature/auth

tree switch

Interactively pick a worktree to switch to (uses arrow keys).

tree clean

Find and remove worktrees whose branches no longer exist locally. Shows a dry-run list and prompts before deleting anything.

tree config

Manage setup and teardown hooks for the current repo.

tree config                           # show effective config
tree config add setup "npm install"   # run after worktree creation
tree config add teardown "npm run clean"
tree config clear setup               # remove all setup commands

Hooks can be saved globally (~/.trees/config.json) or locally (.treesrc.json in the repo root). You'll be prompted each time — the default is smart: local if a local config already exists, global otherwise.

Tab Completion

Tab completion is installed automatically alongside the shell function. It works in both zsh and bash:

  • tree <TAB> — completes subcommands (up, down, remove, list, switch, clean, config)
  • tree up <TAB> — completes all local git branches
  • tree remove <TAB> — completes only active worktree branches
  • tree config <TAB> — completes add, clear

If you installed before tab completion was added, run trees install to update the shell function, then reload your shell.

Configuration

Global — applies to a named repo across all machines:

// ~/.trees/config.json
{
  "repos": {
    "my-app": {
      "setup": ["npm install"],
      "teardown": ["npm run clean"]
    }
  }
}

Per-repo — commit it (or gitignore it) alongside the code:

// .treesrc.json
{
  "setup": ["npm install", "npm run bootstrap"],
  "teardown": []
}

Per-repo config takes precedence over global.


Contributing

Prerequisites

  • Node 18+
  • npm 9+

Setup

git clone https://github.com/<you>/trees
cd trees
npm install
npm run build
npm link        # makes `trees` available in your PATH
source ~/.zshrc # shell function is auto-installed by postinstall

Development

npm run dev     # watch mode — rebuilds on save

Test your changes directly with tree <command> in any git repo.

Project structure

src/
  index.ts          # CLI entrypoint (commander)
  commands/
    up.ts           # tree up <branch>
    down.ts         # tree down
    remove.ts       # tree remove <branch>
    list.ts         # tree list
    switch.ts       # tree switch
    clean.ts        # tree clean
    config.ts       # tree config
  lib/
    git.ts          # git operations (child_process)
    config.ts       # load/merge global + per-repo config
    paths.ts        # ~/.trees/repositories/<repo>/<branch>
    shell.ts        # __TREES_CD__ signal
    hooks.ts        # run setup/teardown commands

The cd mechanism

tree up <branch> needs to change your shell's directory. Since Node can't do that directly, the mechanism works like this:

  1. The tree shell function creates a temp file and passes it via TREES_CD_FILE
  2. trees (Node) writes the target path to that file
  3. The shell function reads the file and runs cd

This approach lets trees run with a direct TTY connection, so interactive prompts (like tree switch or tree config add) work correctly.

Releasing

Releases are automated via auto. Labels on PRs drive version bumps:

| Label | Version bump | Appears in changelog | |---|---|---| | major | 1.0.0 → 2.0.0 | Yes — Breaking Changes | | minor | 1.0.0 → 1.1.0 | Yes — Features | | patch | 1.0.0 → 1.0.1 | Yes — Bug Fixes | | documentation | none | Yes — Documentation | | internal | none | Yes — Internal | | dependencies | none | Yes — Dependencies | | skip-release | none | No |

When a PR merges to main, CI runs auto shipit which:

  1. Determines the version bump from PR labels
  2. Bumps package.json version
  3. Appends to CHANGELOG.md
  4. Creates a GitHub release + git tag
  5. Publishes to npm

First-time setup (one-time, after pushing the repo to GitHub):

  1. Add repo secrets in GitHub → Settings → Secrets:

    • GH_TOKEN — a GitHub personal access token with repo scope
    • NPM_TOKEN — an npm access token with publish rights
  2. Create the PR labels on the repo (one-time):

    GH_TOKEN=<your-token> npx auto create-labels

    Or trigger the Create Labels workflow manually from the Actions tab.

  3. Tag the initial version so auto has a baseline:

    git tag v0.1.0
    git push --tags