aidd-template-scale / rules
Cursor rule0 starsChanged 2 months agoMITView on GitHub
Git worktree workflow
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,144 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/CLAUDE.mdcCursor rule
- .cursor/rules/code-style.mdcCursor rule
- .cursor/rules/docker-compose-local.mdcCursor rule
- .cursor/rules/github-cli-pr.mdcCursor rule
- .cursor/rules/git.mdcCursor rule
- .cursor/rules/ticket-driven-workflow.mdcCursor rule
- address-pr-feedbackSkill
- agentic-e2eSkill
- close-ticketSkill
- docs-app-syncSkill
- review-dependabot-prSkill
- screen-to-specSkill
- spec-lookupSkill
- spec-to-screenSkill
- start-ticketSkill
- address-pr-feedbackSkill
- agentic-e2eSkill
- close-ticketSkill
- docs-app-syncSkill
- review-dependabot-prSkill
- screen-to-specSkill
- spec-lookupSkill
- spec-to-screenSkill
- start-ticketSkill
The file
We split this git-worktree.mdc into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
When starting ticket work:
- Distinctive: line 13
NEVER: run git checkout -b, git switch -c, or equivalent on the main repository working tree.
- Very specific: line 14
ALWAYS: create a worktree with git worktree add -b <branch> <worktrees-dir>/<dir> origin/main.
- Distinctive: line 19
Do not use git rev-parse --show-toplevel alone (inside an existing worktree it returns the worktree path).
- Distinctive: line 21
Use the main repo root:
- Very specific: line 40
If pwd is under ${WORKTREES_ROOT}/ → OK, continue.
- Very specific: line 41
If pwd is the main repo root and you are starting ticket implementation → STOP, create worktree first.
- Distinctive: line 59
Remove the worktree when the branch is merged and no longer needed:
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
alwaysApply: true
description: Git worktree workflow
globs: **/*
---
# Git worktree workflow
## Rules (NEVER / ALWAYS)
When starting ticket work:
- **NEVER** run `git checkout -b`, `git switch -c`, or equivalent on the **main repository working tree**.
- **ALWAYS** create a worktree with `git worktree add -b <branch> <worktrees-dir>/<dir> origin/main`.
- **ALWAYS** `cd` into that worktree before Edit / Write / Bash for implementation.
## Resolve main repository root
Do **not** use `git rev-parse --show-toplevel` alone (inside an existing worktree it returns the worktree path).
Use the main repo root:
```bash
COMMON=$(git rev-parse --git-common-dir)
MAIN_ROOT=$(cd "$COMMON/.." && pwd)
REPO=$(basename "$MAIN_ROOT")
WORKTREES_ROOT="$(dirname "$MAIN_ROOT")/${REPO}-worktrees"
```
Worktrees live at: `${WORKTREES_ROOT}/<dir>/`
## Preflight (before first edit)
```bash
git rev-parse --git-common-dir
pwd
git worktree list
```
- If `pwd` is under `${WORKTREES_ROOT}/` → OK, continue.
- If `pwd` is the main repo root and you are starting ticket implementation → **STOP**, create worktree first.
## Create worktree
```bash
ISSUE=42
BRANCH="feature/${ISSUE}"
DIR=$(echo "$BRANCH" | tr '/' '-')
mkdir -p "$WORKTREES_ROOT"
git fetch origin
git worktree add -b "$BRANCH" "${WORKTREES_ROOT}/${DIR}" origin/main
cd "${WORKTREES_ROOT}/${DIR}"
```
Reuse an existing worktree/branch if one already exists for the same issue.
## After merge
Remove the worktree when the branch is merged and no longer needed:
```bash
git worktree remove "${WORKTREES_ROOT}/${DIR}"
git branch -d "$BRANCH"
```
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
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.

