agentleFS
nanosite-ainanosite-ai/nanoflow/skills/worktree-lifecycle/SKILL.md

worktree-lifecycle

Skill15 starsChanged 33 days agoMITView on GitHub

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.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every task gets its own ticket, git worktree, branch and PR.

    line 8
  2. Distinctive:

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

    line 25
  3. Very specific:

    Commit with Conventional Commits (feat(scope): subject).

    line 37
  4. Distinctive:

    Never on a general "done", never for a worktree with an open PR or unpushed work.

    line 64
  5. Distinctive:

    After a yes, from the main checkout:

    line 66
  6. Distinctive:

    delete the screenshots and recordings you saved locally (only your own files).

    line 78
  7. Very specific:

    If a ritual has no command, run the raw git/gh once, then suggest adding a command.

    line 84

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

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

NeedCommand
This worktree's ports and URLsnf env
Start the app on those ports, wait until it answersnf up --bg
Is it up? Its logs? Stop itnf 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 glancenf flow

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

3. Open the PR

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:

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

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:

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 by nanosite.ai.</sub>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.