lw is a Go CLI that turns a Linear, GitHub, or Jira issue into an isolated Git worktree. It can either print
the worktree path for shell composition or run an explicit command inside the worktree.
The normal flow is:
issue search -> repository routing -> branch resolution -> create or reuse worktree -> path or command
lw is local-first. It reads one selected issue provider, writes only local configuration and Git worktrees, and
has no hosted service or telemetry.
-
Issue-based worktrees
- Search the selected provider interactively or pass a provider-specific
--issuereference. - Create worktrees under
~/.lw/worktrees/<repository>/<ISSUE>by default. - Keep the issue identifier as the worktree directory while resolving repository-specific branch names.
- Search the selected provider interactively or pass a provider-specific
-
Interactive issue discovery
- Search by exact issue identifier, team key, or workspace text.
- Use
Tabto cycle through issue, project, and team views. - Use
Ctrl+Pto pin frequently used projects or teams.
-
Repository routing
- Remember which local repository belongs to a Linear project.
- Use team-level routing for issues without a project.
- Let an explicit
--repooverride remembered routing.
-
Repository-specific branches
- Fetch and reuse one local or remote branch that unambiguously contains the ticket identifier.
- Prompt when several branches match, or edit the provider suggestion when no branch exists.
- Use safe repository-scoped templates or
--branchfor non-interactive creation.
-
Shell composition
- Plain
lwprints exactly one worktree path on stdout. - Pickers, progress, warnings, and errors go to stderr.
- This makes
cd "$(lw)"and scripts predictable.
- Plain
-
Explicit command launching
lw run -- <command> [args...]runs a command directly inside the selected worktree.- It does not invoke a shell or reinterpret arguments.
- The child owns stdin, stdout, stderr, and its exit code.
- The child inherits the user environment except provider API tokens.
-
Local ticket context
- Each worktree stores
lw.jsonin its private Git directory, not in the checkout. lw contextandlw context --jsonexpose that metadata without contacting a provider.lw summary <text>records a local change of focus without writing to a provider.
- Each worktree stores
-
Safe cleanup and diagnostics
lw prunepreviews merged or gone worktrees.lw prune --yesremoves eligible worktrees without forcing dirty checkouts.lw doctorchecks Git, credentials, configuration, and worktree storage.
-
Local credential handling
- Every provider integration is read-only.
- Linear credential resolution is
credentialCommand, thenLINEAR_API_KEY, then the saved key. - Saved Linear credentials prefer the operating system credential store.
- GitHub reads
GITHUB_TOKEN/GH_TOKEN; Jira reads its URL, email, and token from environment variables.
Pick an issue interactively and enter its worktree:
cd "$(lw)"Resolve an issue directly without the picker:
cd "$(lw --issue TEAM-123 --branch alex/team-123-fix)"Force the source repository:
cd "$(lw --issue TEAM-123 --repo ~/src/api --branch alex/team-123-fix)"Manage the current repository's branch rule:
lw branches set-rule --username alex '{username}/{ticket}/{slug}'
lw branches show-rule
lw branches preview TEAM-123
lw branches unset-ruleRun an explicit command inside the worktree:
lw run -- pi
lw run -- claude
lw run -- cursor .Inspect or update local issue context from inside an lw worktree:
lw context
lw context --json
lw summary "investigate repository discovery"Preview and perform cleanup:
lw prune
lw prune --yesPreserve these contracts when changing the code:
- Do not mutate issue-provider data.
- Do not add a hosted backend, daemon, telemetry, or hidden network service.
- Do not couple core behavior to an editor, agent, terminal multiplexer, or workspace manager.
- Keep plain
lwstdout to exactly one successful path line. - Keep TUI output, progress, warnings, and errors on stderr.
- Never expose credentials in arguments, logs, errors, config, metadata, or child processes.
- Never delete an occupied non-worktree path or force-remove a dirty worktree.
- Do not place
lw.jsonin the repository checkout. - Use synthetic organizations, issues, URLs, paths, and credentials in documentation and tests.
lw.go public custom-binary Run entry point
cmd/lw official binary entry point
internal/cli parsing, dispatch, orchestration, and child launching
internal/domain shared issue, repository, stage, and result values
internal/config local config, repository routing, and branch templates
internal/credential credential resolution and storage boundaries
provider public compile-time provider and WorkItem contract
internal/providers built-in Linear, GitHub, and Jira adapters
internal/linear Linear GraphQL transport and collection browsing
internal/gitrepo repository discovery and validation
internal/branch ref discovery, template expansion, and branch planning
internal/worktree worktree creation, reuse, metadata, and pruning
internal/tui onboarding, pickers, progress, and terminal interaction
internal/doctor environment diagnostics
internal/lwerr typed user-facing errors and next actions
Read SPEC.md for behavioral contracts and ARCHITECTURE.md for package boundaries before
changing behavior. Keep those files, README.md, CLI help, and tests synchronized when a
user-visible contract changes.
Run focused tests while developing. Before considering a change complete, run the repository
gate from CONTRIBUTING.md:
test -z "$(gofmt -l .)"
go test ./...
go test -race ./...
go vet ./...
go mod verify
shellcheck install.sh scripts/generate-third-party-notices.sh
./scripts/generate-third-party-notices.sh
git diff --check
git diff --exit-code -- THIRD_PARTY_NOTICES.mdTests must not contact real issue providers, read real credentials, or modify user repositories. Worktree tests should use temporary real Git repositories; other external behavior should use injected fakes.