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

@adamhancock/worktree

v1.1.4

Published

Git worktree manager with branch selection, dependency installation, and VS Code integration

Downloads

17

Readme

@adamhancock/worktree

A CLI tool for managing Git worktrees with automated setup for development environments.

Features

  • Interactive branch selection from remote branches
  • Automatic worktree creation with proper branch handling
  • Copies .env files from the main repository
  • Auto-detects package manager (pnpm, yarn, npm, bun) and installs dependencies
  • Opens the new worktree in VS Code
  • Configurable via JSON config files

Installation

Global installation

npm install -g @adamhancock/worktree

One-time usage with npx

npx @adamhancock/worktree

Usage

Interactive branch selection

worktree
# or with npx
npx @adamhancock/worktree

Create worktree for a specific branch

worktree feature/new-feature
# or with npx
npx @adamhancock/worktree feature/new-feature

Create worktree without opening VS Code

worktree --no-vscode
# or with a specific branch
worktree feature/new-feature --no-vscode

How it works

  1. Fetches latest branches from origin
  2. Creates a new worktree in ../<prefix>-{branch-name}
  3. Handles existing local branches, remote branches, or creates new branches
  4. Sets up branch tracking (without auto-pushing new branches)
  5. Copies all .env files from the original repository
  6. Auto-detects package manager and installs dependencies
  7. Opens the new worktree in VS Code

Configuration

You can customize the behavior by creating a .worktreerc.json file in your project root or home directory. The tool will look for config files in this order:

  1. ./.worktreerc.json (project root)
  2. ./.worktreerc (project root)
  3. ~/.worktreerc.json (home directory)
  4. ~/.worktreerc (home directory)

Example configuration

{
  "vscode": {
    "command": "code",
    "args": ["--new-window", "--goto"],
    "open": true
  },
  "worktree": {
    "prefix": "myproject",
    "location": "../worktrees/{prefix}-{branch}"
  },
  "git": {
    "fetch": true,
    "remote": "origin",
    "defaultBranch": "main",
    "pushNewBranches": false
  },
  "env": {
    "copy": true,
    "patterns": [".env*", "config.local.js"],
    "exclude": [".env.example", ".env.test"]
  },
  "packageManager": {
    "install": true,
    "force": "pnpm",
    "command": null
  },
  "hooks": {
    "postCreate": [
      "echo 'Worktree created!'",
      "npm run prepare"
    ]
  }
}

Configuration options

VS Code

  • vscode.command: The command to launch VS Code (default: "code")
  • vscode.args: Additional arguments to pass to VS Code (default: [])
  • vscode.open: Whether to open VS Code after creating worktree (default: true)

Worktree

  • worktree.prefix: Prefix for worktree directory names (default: "")
  • worktree.location: Custom location pattern for worktrees. Supports placeholders:
    • {prefix}: The configured prefix
    • {branch}: The branch name with slashes replaced by hyphens
    • {original-branch}: The original branch name with slashes

Git

  • git.fetch: Whether to fetch before creating worktree (default: true)
  • git.remote: Remote name to use (default: "origin")
  • git.defaultBranch: Default branch for new branches (default: "main")
  • git.pushNewBranches: Auto-push new branches to remote (default: false)

Environment Files

  • env.copy: Whether to copy env files (default: true)
  • env.patterns: File patterns to copy (default: [".env*"])
  • env.exclude: Patterns to exclude from copying (default: [])

Package Manager

  • packageManager.install: Whether to auto-install dependencies (default: true)
  • packageManager.force: Force specific package manager: "npm", "yarn", "pnpm", or "bun"
  • packageManager.command: Custom install command (overrides auto-detection)

Hooks

  • hooks.postCreate: Array of commands to run after worktree creation. Supports template variables:
    • {branch}: The branch name (e.g., feature/new-feature)
    • {safeBranch}: Branch name with slashes replaced by hyphens (e.g., feature-new-feature)
    • {worktreePath}: Absolute path to the worktree directory
    • {originalDir}: Path to the original repository
    • {prefix}: The configured worktree prefix
    • {remote}: The git remote name (e.g., origin)
    • {defaultBranch}: The default branch name (e.g., main)

Example with variables:

{
  "hooks": {
    "postCreate": [
      "echo 'Setting up worktree for branch {branch}'",
      "npx zx scripts/setup.mjs --branch {branch} --path {worktreePath}",
      "npm run configure:{safeBranch}"
    ]
  }
}

Requirements

  • Git
  • Node.js
  • Package manager (pnpm, yarn, npm, or bun)
  • VS Code (optional, for auto-opening)