Skip to content
Back to skills

Worktree Lifecycle

ASecurity

Run every task as ticket → its own git worktree + branch on its own ports → PR → merge → teardown, with nanoflow. Use when starting, continuing, opening a PR for, or finishing any code task in a repo that has .claude/nanoflow.json or the nanoflow CLI.

  • 15 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 9, 2026
ai-agentsbashgitdatabase

Works with

  • terminal
  • cli
  • mcp

Security analysis

A100/100

Scanned November 10, 2026

npx -y skills add nanosite-ai/nanoflow --skill worktree-lifecycle --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Worktree Lifecycle?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Worktree Lifecycle
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nanosite-ai-worktree-lifecycle/badge)](https://www.skillsdirectory.com/skills/nanosite-ai-worktree-lifecycle)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: worktree-lifecycle
description: Run every task as ticket → its own git worktree + branch on its own ports → PR → merge → teardown, with nanoflow. Use when starting, continuing, opening a PR for, or finishing any code task in a repo that has .claude/nanoflow.json or the nanoflow CLI.
---

# Worktree lifecycle

Every task gets **its own ticket, git worktree, branch and PR**. The main checkout stays on the main branch,
so several tasks (and several agent sessions) can run side by side, each on its own ports, sharing one
database and one set of secrets. `nanoflow` (alias `nf`) does each step as one command, so you never
hand-roll a `gh`/`git` sequence.

## 1. Kick off: before reading or editing code

```bash
nf task start <issue#>                 # claim an existing issue
nf task start --new "<plain title>"    # or create it first (--type bug, --definition "…")
nf task start ED-712 --type fix        # tickets in Jira (ticket.tracker: "jira"; once: install acli, nf jira login)
```

One command: issue → board **In progress** → worktree `../<repo>-<ticket>-<slug>` on branch
`feat/<ticket>-<slug>`, on the next free port slot → session + terminal title `#<ticket> · <branch> · <short>`
→ an opening comment on the issue. Then `cd` into the printed worktree and do **all** the work there.

Never edit in the main checkout, and never commit to the main branch.

## 2. Work

| Need | Command |
|---|---|
| This worktree's ports and URLs | `nf env` |
| Start the app on those ports, wait until it answers | `nf up --bg` |
| Is it up? Its logs? Stop it | `nf status`, `nf logs <service> --grep error`, `nf kill` |
| Run the repo's checks (one line each; only failures print) | `nf check` / `nf check typecheck test` |
| Every worktree, its ticket, PR and CI, at a glance | `nf flow` |

Commit with Conventional Commits (`feat(scope): subject`). Commit to the task branch only.

## 3. Open the PR

```bash
nf check
nf pr create --body-file pr.md [--shots before.png after.png]
```

It pushes, opens the PR with a valid title (`type(scope): subject (#N)`) and `Closes #N`, attaches the
screenshots, sets the board to **In review** and adds `· PR #n` to the title. Then:

```bash
nf ci --watch --failed-log     # wait for CI without a poll loop; read only the failing steps
nf pr comments                 # unresolved review threads; reply with --reply <id> --body "…"
```

## 4. Merged

```bash
nf task done      # board → Done, title gets ✓
```

## 5. Teardown: always ask first

A merged (or abandoned) worktree costs disk, holds a port slot, and piles up. Teardown deletes things, so
**ask the user every time**: *"PR #N is merged. Tear down `<worktree>` (deletes the dir + local branch)?"*
Never on a general "done", never for a worktree with an open PR or unpushed work.

After a yes, from the **main checkout**:

```bash
nf wt remove <name> --delete-branch    # one worktree; stops its processes first
nf wt clean --yes                      # every worktree whose PR is merged/closed
```

`remove` refuses uncommitted or unpushed work unless `--force` (line-ending-only changes, like npm rewriting a
bin shim, don't count). It returns in about a second: the worktree is renamed into `../.<repo>-trash` and
deleted in the background. Then do what the CLI can't:

- close any browser you opened for verification (Playwright MCP: `browser_close`);
- delete the screenshots and recordings you saved locally (only your own files).

## Ground rules

- `--dry` first for anything that writes; `--yes` only after the user approved.
- `--json` when you need to parse a result.
- If a ritual has no command, run the raw `git`/`gh` once, then suggest adding a command.

<sub>Part of [nanoflow](https://github.com/nanosite-ai/nanoflow) by [nanosite.ai](https://nanosite.ai).</sub>

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.