codeforge-dev 1.14.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/{.devcontainer/config/defaults → .codeforge/config}/ccstatusline-settings.json +44 -6
  2. package/.codeforge/config/main-system-prompt.md +412 -0
  3. package/.codeforge/config/orchestrator-system-prompt.md +333 -0
  4. package/{.devcontainer/config/defaults → .codeforge/config}/settings.json +7 -2
  5. package/{.devcontainer/config → .codeforge}/file-manifest.json +15 -9
  6. package/{.devcontainer → .codeforge/scripts}/connect-external-terminal.sh +3 -1
  7. package/.devcontainer/.env.example +17 -5
  8. package/.devcontainer/.secrets.example +3 -0
  9. package/.devcontainer/CHANGELOG.md +215 -0
  10. package/.devcontainer/CLAUDE.md +26 -43
  11. package/.devcontainer/README.md +35 -20
  12. package/.devcontainer/devcontainer.json +36 -17
  13. package/.devcontainer/features/agent-browser/install.sh +3 -0
  14. package/.devcontainer/features/ast-grep/install.sh +3 -0
  15. package/.devcontainer/features/biome/install.sh +3 -0
  16. package/.devcontainer/features/ccburn/install.sh +2 -0
  17. package/.devcontainer/features/ccms/install.sh +2 -0
  18. package/.devcontainer/features/ccstatusline/README.md +7 -6
  19. package/.devcontainer/features/ccstatusline/install.sh +9 -4
  20. package/.devcontainer/features/ccusage/install.sh +2 -0
  21. package/.devcontainer/features/chromaterm/chromaterm.yml +2 -2
  22. package/.devcontainer/features/chromaterm/install.sh +2 -0
  23. package/.devcontainer/features/claude-code-native/README.md +47 -0
  24. package/.devcontainer/features/claude-code-native/devcontainer-feature.json +29 -0
  25. package/.devcontainer/features/claude-code-native/install.sh +131 -0
  26. package/.devcontainer/features/claude-monitor/install.sh +2 -0
  27. package/.devcontainer/features/claude-session-dashboard/README.md +2 -2
  28. package/.devcontainer/features/claude-session-dashboard/install.sh +3 -0
  29. package/.devcontainer/features/dprint/install.sh +2 -0
  30. package/.devcontainer/features/hadolint/install.sh +2 -0
  31. package/.devcontainer/features/kitty-terminfo/README.md +3 -1
  32. package/.devcontainer/features/kitty-terminfo/install.sh +2 -0
  33. package/.devcontainer/features/lsp-servers/install.sh +4 -0
  34. package/.devcontainer/features/mcp-qdrant/CHANGES.md +3 -3
  35. package/.devcontainer/features/mcp-qdrant/README.md +1 -0
  36. package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +1 -1
  37. package/.devcontainer/features/mcp-qdrant/install.sh +9 -2
  38. package/.devcontainer/features/mcp-qdrant/poststart-hook.sh +9 -2
  39. package/.devcontainer/features/notify-hook/devcontainer-feature.json +1 -1
  40. package/.devcontainer/features/notify-hook/install.sh +2 -0
  41. package/.devcontainer/features/ruff/install.sh +2 -0
  42. package/.devcontainer/features/shellcheck/install.sh +2 -0
  43. package/.devcontainer/features/shfmt/install.sh +2 -0
  44. package/.devcontainer/features/tmux/README.md +3 -3
  45. package/.devcontainer/features/tmux/install.sh +3 -1
  46. package/.devcontainer/features/tree-sitter/install.sh +4 -0
  47. package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +27 -11
  48. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/README.md +20 -6
  49. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/architect.md +182 -29
  50. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/bash-exec.md +9 -0
  51. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/claude-guide.md +13 -4
  52. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/debug-logs.md +24 -5
  53. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/dependency-analyst.md +16 -5
  54. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/documenter.md +412 -0
  55. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/explorer.md +18 -6
  56. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/generalist.md +36 -10
  57. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/git-archaeologist.md +10 -1
  58. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/implementer.md +260 -0
  59. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/investigator.md +262 -0
  60. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/migrator.md +10 -0
  61. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/perf-profiler.md +21 -5
  62. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/refactorer.md +18 -8
  63. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/researcher.md +23 -5
  64. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/security-auditor.md +20 -6
  65. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/spec-writer.md +12 -0
  66. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/statusline-config.md +12 -2
  67. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/test-writer.md +22 -7
  68. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/scripts/guard-readonly-bash.py +9 -5
  69. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/scripts/redirect-builtin-agents.py +2 -5
  70. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/README.md +1 -1
  71. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/advisory-test-runner.py +4 -2
  72. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/README.md +3 -2
  73. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/block-dangerous.py +89 -15
  74. package/.devcontainer/plugins/devs-marketplace/plugins/git-workflow/.claude-plugin/plugin.json +7 -0
  75. package/.devcontainer/plugins/devs-marketplace/plugins/git-workflow/README.md +125 -0
  76. package/.devcontainer/plugins/devs-marketplace/plugins/git-workflow/skills/pr-review/SKILL.md +325 -0
  77. package/.devcontainer/plugins/devs-marketplace/plugins/git-workflow/skills/ship/SKILL.md +314 -0
  78. package/.devcontainer/plugins/devs-marketplace/plugins/prompt-snippets/.claude-plugin/plugin.json +5 -0
  79. package/.devcontainer/plugins/devs-marketplace/plugins/prompt-snippets/README.md +52 -0
  80. package/.devcontainer/plugins/devs-marketplace/plugins/prompt-snippets/skills/ps/SKILL.md +37 -0
  81. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/README.md +2 -2
  82. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected-bash.py +80 -6
  83. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected.py +4 -4
  84. package/.devcontainer/plugins/devs-marketplace/plugins/session-context/README.md +30 -14
  85. package/.devcontainer/plugins/devs-marketplace/plugins/session-context/hooks/hooks.json +13 -1
  86. package/.devcontainer/plugins/devs-marketplace/plugins/session-context/scripts/collect-session-edits.py +44 -0
  87. package/.devcontainer/plugins/devs-marketplace/plugins/session-context/scripts/commit-reminder.py +89 -10
  88. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/.claude-plugin/plugin.json +1 -1
  89. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/README.md +19 -11
  90. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/scripts/skill-suggester.py +476 -282
  91. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/skills/team/SKILL.md +4 -4
  92. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/skills/worktree/SKILL.md +227 -0
  93. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/skills/worktree/references/manual-worktree-commands.md +238 -0
  94. package/.devcontainer/plugins/devs-marketplace/plugins/skill-engine/skills/worktree/references/parallel-workflow-patterns.md +228 -0
  95. package/.devcontainer/plugins/devs-marketplace/plugins/spec-workflow/skills/spec-build/SKILL.md +2 -2
  96. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/scripts/ticket-linker.py +2 -2
  97. package/.devcontainer/plugins/devs-marketplace/plugins/workspace-scope-guard/README.md +1 -1
  98. package/.devcontainer/plugins/devs-marketplace/plugins/workspace-scope-guard/scripts/guard-workspace-scope.py +69 -31
  99. package/.devcontainer/scripts/check-setup.sh +5 -3
  100. package/.devcontainer/scripts/preflight.sh +113 -0
  101. package/.devcontainer/scripts/setup-aliases.sh +13 -8
  102. package/.devcontainer/scripts/setup-auth.sh +46 -0
  103. package/.devcontainer/scripts/setup-config.sh +29 -10
  104. package/.devcontainer/scripts/setup-migrate-claude.sh +80 -0
  105. package/.devcontainer/scripts/setup-migrate-codeforge.sh +60 -0
  106. package/.devcontainer/scripts/setup-plugins.sh +5 -5
  107. package/.devcontainer/scripts/setup-projects.sh +4 -2
  108. package/.devcontainer/scripts/setup-terminal.sh +3 -1
  109. package/.devcontainer/scripts/setup-update-claude.sh +22 -27
  110. package/.devcontainer/scripts/setup.sh +78 -5
  111. package/LICENSE.txt +14 -0
  112. package/README.md +82 -7
  113. package/package.json +4 -1
  114. package/setup.js +392 -21
  115. package/.devcontainer/config/defaults/main-system-prompt.md +0 -664
  116. package/.devcontainer/docs/configuration-reference.md +0 -93
  117. package/.devcontainer/docs/keybindings.md +0 -100
  118. package/.devcontainer/docs/optional-features.md +0 -64
  119. package/.devcontainer/docs/plugins.md +0 -176
  120. package/.devcontainer/docs/troubleshooting.md +0 -128
  121. package/.devcontainer/plugins/devs-marketplace/plugins/agent-system/agents/doc-writer.md +0 -334
  122. package/.devcontainer/scripts/setup-symlink-claude.sh +0 -36
  123. /package/{.devcontainer/config/defaults → .codeforge/config}/keybindings.json +0 -0
  124. /package/{.devcontainer/config/defaults → .codeforge/config}/rules/session-search.md +0 -0
  125. /package/{.devcontainer/config/defaults → .codeforge/config}/rules/spec-workflow.md +0 -0
  126. /package/{.devcontainer/config/defaults → .codeforge/config}/rules/workspace-scope.md +0 -0
  127. /package/{.devcontainer/config/defaults → .codeforge/config}/writing-system-prompt.md +0 -0
  128. /package/{.devcontainer → .codeforge/scripts}/connect-external-terminal.ps1 +0 -0
@@ -165,7 +165,7 @@ Choose the agent whose domain matches the work. **Generalist is a last resort.**
165
165
  | `researcher` | Codebase & web research | Read-only |
166
166
  | `test-writer` | Write test suites | Read + Write + Bash |
167
167
  | `refactorer` | Safe code transformations | Read + Write + Bash |
168
- | `doc-writer` | README, API docs, docstrings | Read + Write |
168
+ | `documenter` | README, API docs, docstrings | Read + Write |
169
169
  | `migrator` | Framework upgrades, version bumps | Read + Write + Bash |
170
170
  | `security-auditor` | OWASP audit, secrets scan | Read-only |
171
171
  | `git-archaeologist` | Git history investigation | Read-only + Bash |
@@ -198,14 +198,14 @@ Prefix with `agent-system:` when spawning (e.g., `agent-system:test-writer`).
198
198
 
199
199
  | Purpose | Recommended Team |
200
200
  |---------|-----------------|
201
- | Feature build | `researcher` + `test-writer` + `doc-writer` |
201
+ | Feature build | `researcher` + `test-writer` + `documenter` |
202
202
  | Security hardening | `security-auditor` + `dependency-analyst` |
203
203
  | Codebase cleanup | `refactorer` + `test-writer` |
204
204
  | Migration project | `researcher` + `migrator` |
205
205
  | Performance work | `perf-profiler` + `refactorer` |
206
206
  | Full-stack feature | `architect` + `generalist` (backend) + `generalist` (frontend) + `test-writer` |
207
207
  | Code audit | `security-auditor` + `dependency-analyst` + `perf-profiler` |
208
- | Documentation sprint | `researcher` + `doc-writer` |
208
+ | Documentation sprint | `researcher` + `documenter` |
209
209
 
210
210
  ---
211
211
 
@@ -230,7 +230,7 @@ Prefix with `agent-system:` when spawning (e.g., `agent-system:test-writer`).
230
230
  - **Wait for teammates to finish** — leads sometimes start implementing work that teammates are handling. If you notice this, redirect yourself to monitoring and coordination.
231
231
  - **Start with research and review** — for first-time team use, prefer tasks with clear boundaries that don't require code changes: reviewing PRs, researching libraries, investigating bugs.
232
232
  - **Monitor and steer** — check progress via `TaskList`, redirect failing approaches, synthesize findings. Unattended teams risk wasted effort.
233
- - **Avoid file conflicts** — break work so each teammate owns different files. Agents with `isolation: worktree` (test-writer, refactorer, doc-writer, migrator) get automatic file isolation via git worktrees.
233
+ - **Avoid file conflicts** — break work so each teammate owns different files. Agents with `isolation: worktree` (test-writer, refactorer, documenter, migrator) get automatic file isolation via git worktrees.
234
234
 
235
235
  ---
236
236
 
@@ -0,0 +1,227 @@
1
+ ---
2
+ name: worktree
3
+ description: >-
4
+ Guides git worktree creation, management, and cleanup for parallel
5
+ development workflows including EnterWorktree usage, .worktreeinclude
6
+ setup, and worktree lifecycle. USE WHEN the user asks to "create a
7
+ worktree", "work in a worktree", "set up parallel branches", "isolate
8
+ my work", "clean up worktrees", "list worktrees", "enter worktree",
9
+ "worktree include", or works with git worktree commands, EnterWorktree,
10
+ or parallel development patterns. DO NOT USE for routine git branching
11
+ or single-branch workflows.
12
+ version: 0.1.0
13
+ allowed-tools: Bash, Read, Grep, Glob, EnterWorktree
14
+ ---
15
+
16
+ # Git Worktrees
17
+
18
+ ## Mental Model
19
+
20
+ A git worktree is a parallel checkout of the same repository. One `.git` database, multiple working directories, each on a different branch. Think of it as having multiple monitors for code — same project, different contexts, simultaneously active.
21
+
22
+ The key difference from branches: a branch is a pointer to a commit; a worktree is a full working directory with its own index and working tree. Switching branches requires stashing, committing, or discarding changes. Switching worktrees means walking to a different directory.
23
+
24
+ Use worktrees when:
25
+ - **Parallel features** — work on two features without context-switching overhead
26
+ - **Safe experimentation** — try a risky refactor without touching the main checkout
27
+ - **Code review** — review a PR in one worktree while continuing work in another
28
+ - **Hotfixes** — address an urgent bug without stashing mid-feature work
29
+ - **Agent isolation** — give Claude Code agents their own working directory to prevent file conflicts
30
+
31
+ ---
32
+
33
+ ## Creating Worktrees
34
+
35
+ ### Primary: EnterWorktree Tool (In-Session)
36
+
37
+ The fastest way to create a worktree during a Claude Code session. Call `EnterWorktree` with a descriptive name:
38
+
39
+ ```text
40
+ EnterWorktree: feature-auth-oauth2
41
+ ```
42
+
43
+ **Behavior:**
44
+ - Creates worktree at `<repo>/.claude/worktrees/<name>/`
45
+ - Branches from current HEAD
46
+ - Auto-names the branch `worktree-<name>`
47
+ - Session moves into the worktree directory
48
+ - **Auto-cleanup:** If no changes are made, the worktree and branch are removed on session exit. If changes exist, Claude prompts to keep or remove.
49
+
50
+ ### CLI Flag: `--worktree`
51
+
52
+ Start a new Claude Code session directly in a worktree:
53
+
54
+ ```bash
55
+ # Named worktree
56
+ claude --worktree feature-auth-oauth2
57
+
58
+ # Auto-generated name
59
+ claude --worktree
60
+
61
+ # Combined with tmux for background work
62
+ claude --worktree feature-auth-oauth2 --tmux
63
+ ```
64
+
65
+ The worktree is created at `<repo>/.claude/worktrees/<name>/` with the same auto-cleanup behavior as `EnterWorktree`.
66
+
67
+ ### Manual: `git worktree add`
68
+
69
+ For worktrees outside of Claude Code sessions, or when precise control over path and branch is needed:
70
+
71
+ ```bash
72
+ # Create worktree with new branch
73
+ git worktree add /path/to/worktree -b feature-branch-name
74
+
75
+ # Create worktree tracking existing branch
76
+ git worktree add /path/to/worktree existing-branch
77
+ ```
78
+
79
+ > **Deep dive:** See `references/manual-worktree-commands.md` for the full command reference with all flags, path conventions, and troubleshooting.
80
+
81
+ ### Naming Conventions
82
+
83
+ - **Kebab-case, descriptive:** `feature-auth-oauth2`, `bugfix-login-timeout`, `spike-new-db`
84
+ - **Prefix with category:** `feature-`, `bugfix-`, `spike-`, `chore-`
85
+ - **Claude Code auto-naming:** Branches created by `--worktree` or `EnterWorktree` are prefixed `worktree-`
86
+
87
+ ---
88
+
89
+ ## Environment Setup
90
+
91
+ ### `.worktreeinclude` File
92
+
93
+ New worktrees start with only tracked files. Environment files (`.env`, `.env.local`) are typically `.gitignore`-excluded and will be missing. The `.worktreeinclude` file solves this.
94
+
95
+ Place at the project root. It lists `.gitignore`-excluded files that should be **copied into every new worktree** automatically:
96
+
97
+ ```gitignore
98
+ .env
99
+ .env.local
100
+ .env.*
101
+ **/.claude/settings.local.json
102
+ ```
103
+
104
+ **Rules:**
105
+ - Uses `.gitignore` pattern syntax
106
+ - Only files matching **both** `.worktreeinclude` and `.gitignore` are copied
107
+ - Tracked files are never duplicated (they come from the checkout itself)
108
+ - Commit `.worktreeinclude` to the repo so the team benefits
109
+
110
+ **If `.worktreeinclude` doesn't exist:** Copy environment files manually after worktree creation, or create the file first.
111
+
112
+ ### Post-Creation Checklist
113
+
114
+ After creating a worktree, the working directory needs initialization:
115
+
116
+ 1. **Install dependencies** — `npm install`, `uv sync`, `cargo build`, or whatever the project requires. Worktrees share the git database but not `node_modules/`, `.venv/`, or `target/`.
117
+ 2. **Run `/init`** — in a new Claude Code session within the worktree, run `/init` to orient Claude to the worktree context.
118
+ 3. **Verify the dev environment** — run the test suite or start the dev server to confirm everything works.
119
+
120
+ ---
121
+
122
+ ## Managing Worktrees
123
+
124
+ ### Listing
125
+
126
+ ```bash
127
+ git worktree list
128
+ ```
129
+
130
+ Output shows each worktree's path, HEAD commit, and branch:
131
+
132
+ ```text
133
+ /workspaces/projects/CodeForge d2ba55e [main]
134
+ /workspaces/projects/.worktrees/feature-a abc1234 [feature-a]
135
+ ```
136
+
137
+ ### Switching Context
138
+
139
+ Worktrees are directories. To switch context:
140
+ - **Terminal:** Open a new terminal and `cd` to the worktree path
141
+ - **VS Code Project Manager:** Worktrees in `.worktrees/` are auto-detected and tagged `"worktree"` — click to open
142
+ - **Claude Code:** Start a new session with `claude --worktree <name>` or use `EnterWorktree`
143
+
144
+ ### Cleanup
145
+
146
+ **Claude Code auto-cleanup:**
147
+ - No changes → worktree and branch removed automatically on session exit
148
+ - Changes exist → prompted to keep or remove
149
+
150
+ **Manual cleanup** (confirm with user first — destructive):
151
+
152
+ ```bash
153
+ # Remove a specific worktree
154
+ git worktree remove /path/to/worktree
155
+
156
+ # Force remove (discards uncommitted changes)
157
+ git worktree remove --force /path/to/worktree
158
+
159
+ # Clean up stale worktree references (after manual directory deletion)
160
+ git worktree prune
161
+ ```
162
+
163
+ ### Merging Work Back
164
+
165
+ After completing work in a worktree:
166
+
167
+ 1. **Commit and push** the worktree branch
168
+ 2. **Create a PR** from the worktree branch to the target branch
169
+ 3. **After merge**, clean up:
170
+ ```bash
171
+ git worktree remove /path/to/worktree
172
+ git branch -d worktree-feature-name # delete merged branch
173
+ ```
174
+
175
+ Alternatively, merge locally:
176
+ ```bash
177
+ # From the main checkout
178
+ git merge feature-branch-name
179
+ ```
180
+
181
+ ---
182
+
183
+ ## CodeForge Integration
184
+
185
+ ### Project Manager Auto-Detection
186
+
187
+ The `setup-projects.sh` script scans `.worktrees/` directories at depth 3. Worktrees are detected by checking for a `.git` **file** (not directory) containing a `gitdir:` pointer. Detected worktrees receive both `"git"` and `"worktree"` tags in VS Code Project Manager.
188
+
189
+ ### Agent Isolation
190
+
191
+ Five CodeForge agents use `isolation: worktree` in their frontmatter — refactorer, test-writer, migrator, documenter, and implementer. When spawned via the `Task` tool, these agents automatically get their own worktree copy of the repository. The worktree is cleaned up after the agent finishes (removed if no changes; kept if changes exist).
192
+
193
+ ### Workspace Scope Guard
194
+
195
+ Each worktree is treated as an independent project directory by the workspace-scope-guard plugin. File operations are restricted to the worktree's directory boundary.
196
+
197
+ ### Path Conventions
198
+
199
+ Two conventions coexist:
200
+
201
+ | Convention | Path | Used by |
202
+ |-----------|------|---------|
203
+ | **Native (primary)** | `<repo>/.claude/worktrees/<name>/` | `--worktree` flag, `EnterWorktree` tool |
204
+ | **Legacy** | `<container-dir>/.worktrees/<name>/` | Manual `git worktree add`, Project Manager detection |
205
+
206
+ Native is recommended for Claude Code sessions. Legacy is used for manual worktree management and remains supported by `setup-projects.sh`.
207
+
208
+ ---
209
+
210
+ ## Ambiguity Policy
211
+
212
+ - Default to `EnterWorktree` for in-session worktree creation.
213
+ - Default to the native path convention unless the user specifies otherwise.
214
+ - When the purpose is unclear, ask: "What will you work on in the worktree?"
215
+ - Default branch base: current branch HEAD, not main/master.
216
+ - Default cleanup: prompt before removing worktrees with uncommitted changes.
217
+ - When `.worktreeinclude` doesn't exist and the project has `.env` files, suggest creating one.
218
+ - For agent work, defer to the `team` skill for orchestration — worktree isolation is automatic for agents that declare it.
219
+
220
+ ---
221
+
222
+ ## Reference Files
223
+
224
+ | File | Contents |
225
+ |------|----------|
226
+ | `references/manual-worktree-commands.md` | Full `git worktree` command reference with all flags, path conventions, `.git` file anatomy, and troubleshooting |
227
+ | `references/parallel-workflow-patterns.md` | Workflow patterns for multi-worktree development, agent swarms, hooks, and anti-patterns |
@@ -0,0 +1,238 @@
1
+ # Git Worktree Command Reference
2
+
3
+ Complete reference for `git worktree` subcommands with flags, path conventions, and troubleshooting.
4
+
5
+ ---
6
+
7
+ ## `git worktree add`
8
+
9
+ Create a new worktree linked to the current repository.
10
+
11
+ ```bash
12
+ # New branch from HEAD
13
+ git worktree add <path> -b <new-branch>
14
+
15
+ # Existing branch
16
+ git worktree add <path> <existing-branch>
17
+
18
+ # Detached HEAD at specific commit
19
+ git worktree add --detach <path> <commit>
20
+
21
+ # Track a remote branch
22
+ git worktree add <path> --track -b <local-name> origin/<remote-branch>
23
+ ```
24
+
25
+ ### Common Flags
26
+
27
+ | Flag | Purpose |
28
+ |------|---------|
29
+ | `-b <branch>` | Create and checkout a new branch |
30
+ | `-B <branch>` | Create or reset and checkout a branch |
31
+ | `--detach` | Checkout in detached HEAD state |
32
+ | `--track` | Set up tracking for the new branch |
33
+ | `--no-checkout` | Create worktree without checking out files (fast, populate later) |
34
+ | `--lock` | Lock the worktree immediately after creation |
35
+ | `-f` / `--force` | Override safeguards (e.g., allow checking out a branch already in another worktree) |
36
+ | `--orphan` | Create worktree with a new orphan branch (no parent commits) |
37
+
38
+ ### Path Conventions
39
+
40
+ **Claude Code native convention (recommended for Claude sessions):**
41
+ ```bash
42
+ # Automatic — handled by --worktree flag or EnterWorktree
43
+ # Path: <repo>/.claude/worktrees/<name>/
44
+ # Branch: worktree-<name>
45
+ claude --worktree feature-auth
46
+ ```
47
+
48
+ **Legacy CodeForge convention (for manual management):**
49
+ ```bash
50
+ # Container directory .worktrees/ sibling to repos
51
+ mkdir -p /workspaces/projects/.worktrees
52
+ git worktree add /workspaces/projects/.worktrees/<name> -b <branch>
53
+ ```
54
+
55
+ **General best practice:**
56
+ - Keep worktrees in a predictable location
57
+ - Use the same naming pattern for worktree directories and branches
58
+ - Add the worktree directory to `.gitignore` if it lives inside the repo
59
+
60
+ ---
61
+
62
+ ## `git worktree list`
63
+
64
+ Show all worktrees linked to the repository.
65
+
66
+ ```bash
67
+ # Default format
68
+ git worktree list
69
+
70
+ # Porcelain format (machine-readable)
71
+ git worktree list --porcelain
72
+ ```
73
+
74
+ **Default output:**
75
+ ```text
76
+ /workspaces/projects/CodeForge d2ba55e [main]
77
+ /workspaces/projects/.worktrees/feature-a abc1234 [feature-a]
78
+ /workspaces/projects/.worktrees/bugfix-b def5678 [bugfix-b] locked
79
+ ```
80
+
81
+ **Porcelain output:**
82
+ ```text
83
+ worktree /workspaces/projects/CodeForge
84
+ HEAD d2ba55eabc1234def5678901234567890abcdef
85
+ branch refs/heads/main
86
+
87
+ worktree /workspaces/projects/.worktrees/feature-a
88
+ HEAD abc1234def5678901234567890abcdef01234567
89
+ branch refs/heads/feature-a
90
+ ```
91
+
92
+ ---
93
+
94
+ ## `git worktree remove`
95
+
96
+ Remove a worktree and its administrative files. **Destructive — confirm before executing.**
97
+
98
+ ```bash
99
+ # Remove (fails if there are uncommitted changes)
100
+ git worktree remove <path>
101
+
102
+ # Force remove (discards uncommitted changes)
103
+ git worktree remove --force <path>
104
+ ```
105
+
106
+ **Safety notes:**
107
+ - Without `--force`, refuses to remove worktrees with modified or untracked files
108
+ - Does NOT delete the branch — use `git branch -d <branch>` separately
109
+ - The main worktree (the original checkout) cannot be removed
110
+
111
+ ---
112
+
113
+ ## `git worktree prune`
114
+
115
+ Clean up stale worktree administrative data. Run this when a worktree directory was deleted manually without using `git worktree remove`.
116
+
117
+ ```bash
118
+ # Prune stale references
119
+ git worktree prune
120
+
121
+ # Dry run — show what would be pruned
122
+ git worktree prune --dry-run
123
+
124
+ # Verbose — show details
125
+ git worktree prune --verbose
126
+ ```
127
+
128
+ **When to use:**
129
+ - After manually deleting a worktree directory (e.g., `rm -rf`)
130
+ - When `git worktree list` shows a worktree that no longer exists on disk
131
+ - During routine repository maintenance
132
+
133
+ ---
134
+
135
+ ## `git worktree move`
136
+
137
+ Relocate an existing worktree to a new path.
138
+
139
+ ```bash
140
+ git worktree move <old-path> <new-path>
141
+
142
+ # Force move (even if locked)
143
+ git worktree move --force <old-path> <new-path>
144
+ ```
145
+
146
+ **Notes:**
147
+ - The main worktree cannot be moved
148
+ - Updates the `.git` file in the worktree and the metadata in the main repo
149
+ - Locked worktrees require `--force`
150
+
151
+ ---
152
+
153
+ ## `git worktree lock` / `unlock`
154
+
155
+ Prevent a worktree from being pruned (useful for worktrees on removable media or network shares).
156
+
157
+ ```bash
158
+ # Lock with reason
159
+ git worktree lock --reason "on USB drive" <path>
160
+
161
+ # Unlock
162
+ git worktree unlock <path>
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Worktree `.git` File Anatomy
168
+
169
+ The main repository has a `.git` **directory**. Each worktree has a `.git` **file** (not directory) containing a pointer:
170
+
171
+ ```text
172
+ gitdir: /workspaces/projects/CodeForge/.git/worktrees/feature-a
173
+ ```
174
+
175
+ This pointer tells git where the worktree metadata is stored within the main repository's `.git/worktrees/` directory. The metadata includes:
176
+ - `HEAD` — current commit reference
177
+ - `commondir` — path back to the shared `.git` directory
178
+ - `gitdir` — path to the worktree's working directory
179
+
180
+ **Detection pattern:** To check if a directory is a worktree (not a standalone repo):
181
+ ```bash
182
+ [ -f "$dir/.git" ] && grep -q "gitdir:" "$dir/.git"
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Troubleshooting
188
+
189
+ ### "fatal: '<branch>' is already checked out"
190
+
191
+ A branch can only be checked out in one worktree at a time.
192
+
193
+ **Fix:** Use a different branch name, or remove the worktree that has it checked out:
194
+ ```bash
195
+ git worktree list # find which worktree has the branch
196
+ git worktree remove <path> # remove it
197
+ ```
198
+
199
+ ### "fatal: '<path>' is a missing but locked worktree"
200
+
201
+ The worktree directory was deleted but the lock prevents pruning.
202
+
203
+ **Fix:**
204
+ ```bash
205
+ git worktree unlock <path>
206
+ git worktree prune
207
+ ```
208
+
209
+ ### Stale worktree references after directory deletion
210
+
211
+ `git worktree list` shows worktrees that no longer exist on disk.
212
+
213
+ **Fix:**
214
+ ```bash
215
+ git worktree prune --verbose
216
+ ```
217
+
218
+ ### Worktree not detected by `setup-projects.sh`
219
+
220
+ CodeForge auto-detection scans `.worktrees/` directories. Ensure:
221
+ 1. The worktree is inside a `.worktrees/` directory
222
+ 2. The worktree has a `.git` file with `gitdir:` (not a standalone repo)
223
+ 3. Run `check-setup` to re-trigger project detection
224
+
225
+ ### Shared state issues between worktrees
226
+
227
+ Worktrees share:
228
+ - The `.git` database (commits, branches, refs, stash)
229
+ - Git configuration (`.git/config`)
230
+ - Hooks (`.git/hooks/`)
231
+
232
+ Worktrees do NOT share:
233
+ - Working tree files
234
+ - Index (staging area)
235
+ - `node_modules/`, `.venv/`, `target/` (dependency directories)
236
+ - `.env` files (unless `.worktreeinclude` copies them)
237
+
238
+ If one worktree's operations seem to affect another, check for shared state leaks through the `.git` database (e.g., `git stash` is shared across all worktrees).