Skip to content

Commit e6c7843

Browse files
authored
Add worktree skill for git worktree lifecycle (#5)
* Add worktree skill for git worktree lifecycle guidance New skill-engine skill covering EnterWorktree, --worktree CLI flag, .worktreeinclude setup, worktree management, and CodeForge integration. Updates system prompt <git_worktrees> to recommend native Claude Code convention alongside legacy .worktrees/ path. * Fix 11 CodeRabbit review issues: docs consistency, MD040, missing content - Move system prompt changelog entry from Added to Changed section - Add Worktrees section to CLAUDE.md matching system prompt guidance - Add language tags to 5 fenced code blocks (MD040) across SKILL.md and manual-worktree-commands.md - Soften absolute merge conflict claim in parallel-workflow-patterns.md - Add EnterWorktree to SKILL.md allowed-tools - Add worktree to README.md skills list (21→22 entries) - Fix stale skill counts: 21→22 in features/index.md, getting-started/index.md, plugins/skill-engine.md (description + table); 34→35 in reference/architecture.md --------- Co-authored-by: AnExiledDev <AnExiledDev@users.noreply.github.com>
1 parent 4c0b43a commit e6c7843

File tree

19 files changed

+794
-28
lines changed

19 files changed

+794
-28
lines changed

.devcontainer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
#### Docs
88
- **CLAUDE.md** — new "Status Bar Widgets" section documenting widget properties, token color conventions, label fusion pattern, and available widget types
99

10+
#### Skills
11+
- **worktree** — New skill for git worktree creation, management, and cleanup. Covers `EnterWorktree` tool, `--worktree` CLI flag, `.worktreeinclude` setup, worktree naming conventions, cleanup lifecycle, and CodeForge integration (Project Manager auto-detection, agent isolation). Includes two reference files: manual worktree commands and parallel workflow patterns.
12+
1013
### Changed
1114

15+
#### System Prompt
16+
- **`<git_worktrees>` section** — Updated to document Claude Code native worktree convention (`<repo>/.claude/worktrees/`) as the recommended approach alongside the legacy `.worktrees/` convention. Added `EnterWorktree` tool guidance, `.worktreeinclude` file documentation, and path convention comparison table.
17+
1218
#### Configuration
1319
- Moved `.claude` directory from `/workspaces/.claude` to `~/.claude` (home directory)
1420
- Added Docker named volume for persistence across rebuilds (per-instance isolation via `${devcontainerId}`)

.devcontainer/CLAUDE.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ CodeForge devcontainer for AI-assisted development with Claude Code.
3333

3434
Config files deploy via `file-manifest.json` on every container start. Most deploy to `~/.claude/`; ccstatusline config deploys to `~/.config/ccstatusline/`. Each entry supports `overwrite`: `"if-changed"` (default, sha256), `"always"`, or `"never"`. Supported variables: `${CLAUDE_CONFIG_DIR}`, `${WORKSPACE_ROOT}`, `${HOME}`.
3535

36+
## Worktrees
37+
38+
Git worktrees allow checking out multiple branches simultaneously, each in its own directory.
39+
40+
**Native (recommended for Claude Code sessions):**
41+
- **In-session:** `EnterWorktree` tool — creates worktree at `<repo>/.claude/worktrees/<name>/`, branch `worktree-<name>`, auto-cleaned if no changes
42+
- **New session:** `claude --worktree <name>` — starts Claude in its own worktree; combine with `--tmux` for background work
43+
44+
**Manual (legacy convention):**
45+
```bash
46+
mkdir -p /workspaces/projects/.worktrees
47+
git worktree add /workspaces/projects/.worktrees/<branch-name> -b <branch>
48+
```
49+
50+
**Environment files:** Place a `.worktreeinclude` file at the project root listing `.gitignore`-excluded files to copy into new worktrees (e.g., `.env`). Uses `.gitignore` pattern syntax; only files matching both `.worktreeinclude` and `.gitignore` are copied.
51+
52+
**Management:**
53+
54+
| Command | Purpose |
55+
|---------|---------|
56+
| `git worktree list` | Show all active worktrees |
57+
| `git worktree remove <path>` | Remove a worktree (destructive — confirm first) |
58+
| `git worktree prune` | Clean up stale references (destructive — confirm first) |
59+
60+
**Path conventions:**
61+
- **Native:** `<repo>/.claude/worktrees/<name>/` — used by `--worktree` flag and `EnterWorktree`
62+
- **Legacy:** `.worktrees/` as sibling to the main repo — used for manual `git worktree add` and Project Manager integration
63+
3664
## Commands
3765

3866
| Command | Purpose |
@@ -52,7 +80,7 @@ Config files deploy via `file-manifest.json` on every container start. Most depl
5280
Declared in `settings.json` under `enabledPlugins`, auto-activated on start:
5381

5482
- **agent-system** — 17 custom agents + built-in agent redirection
55-
- **skill-engine**21 general coding skills + auto-suggestion
83+
- **skill-engine**22 general coding skills + auto-suggestion
5684
- **spec-workflow** — 8 spec lifecycle skills + spec-reminder hook
5785
- **session-context** — Git state injection, TODO harvesting, commit reminders
5886
- **auto-code-quality** — Auto-format + auto-lint + advisory test runner

.devcontainer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ Agent definitions in `plugins/devs-marketplace/plugins/agent-system/agents/` pro
344344
| `statusline-config` | ccstatusline configuration |
345345
| `test-writer` | Test authoring with pass verification |
346346

347-
### General Skills (21) — `skill-engine` plugin
347+
### General Skills (22) — `skill-engine` plugin
348348

349349
Skills in `plugins/devs-marketplace/plugins/skill-engine/skills/` provide domain-specific coding references:
350350

351-
`api-design` · `ast-grep-patterns` · `claude-agent-sdk` · `claude-code-headless` · `debugging` · `dependency-management` · `docker` · `docker-py` · `documentation-patterns` · `fastapi` · `git-forensics` · `migration-patterns` · `performance-profiling` · `pydantic-ai` · `refactoring-patterns` · `security-checklist` · `skill-building` · `sqlite` · `svelte5` · `team` · `testing`
351+
`api-design` · `ast-grep-patterns` · `claude-agent-sdk` · `claude-code-headless` · `debugging` · `dependency-management` · `docker` · `docker-py` · `documentation-patterns` · `fastapi` · `git-forensics` · `migration-patterns` · `performance-profiling` · `pydantic-ai` · `refactoring-patterns` · `security-checklist` · `skill-building` · `sqlite` · `svelte5` · `team` · `testing` · `worktree`
352352

353353
### Spec Skills (8) — `spec-workflow` plugin
354354

.devcontainer/config/defaults/main-system-prompt.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,22 +338,30 @@ When blocked, do not use destructive actions as a shortcut. Investigate before d
338338
<git_worktrees>
339339
Git worktrees allow checking out multiple branches simultaneously, each in its own directory.
340340

341-
Layout convention:
342-
- Worktrees go in a `.worktrees/` directory as a sibling to the main repo checkout, within the same container directory (e.g., `projects/.worktrees/feature-name`)
343-
- The main repo has a `.git` directory; worktrees have a `.git` file containing `gitdir:` pointing to the main repo's worktree metadata
341+
Creating worktrees (recommended — use Claude Code native tools):
342+
- **In-session:** Use `EnterWorktree` tool with a descriptive name. Creates worktree at `<repo>/.claude/worktrees/<name>/` with branch `worktree-<name>`. Auto-cleaned if no changes.
343+
- **New session:** `claude --worktree <name>` starts Claude in its own worktree. Combine with `--tmux` for background work.
344344

345-
Creating worktrees:
345+
Creating worktrees (manual):
346346
```bash
347-
# Always create inside .worktrees/
347+
# Legacy convention — detected by setup-projects.sh
348348
mkdir -p /workspaces/projects/.worktrees
349-
git worktree add /workspaces/projects/.worktrees/<branch-name> <branch>
349+
git worktree add /workspaces/projects/.worktrees/<branch-name> -b <branch>
350350
```
351351

352+
Environment files:
353+
- Place a `.worktreeinclude` file at the project root listing `.gitignore`-excluded files to copy into new worktrees (e.g., `.env`, `.env.local`)
354+
- Uses `.gitignore` pattern syntax; only files matching both `.worktreeinclude` and `.gitignore` are copied
355+
352356
Managing worktrees:
353357
- `git worktree list` — show all active worktrees
354358
- `git worktree remove <path>` — remove a worktree (confirm with user first — destructive)
355359
- `git worktree prune` — clean up stale worktree references (confirm with user first — destructive)
356360

361+
Path conventions:
362+
- **Native (recommended):** `<repo>/.claude/worktrees/<name>/` — used by `--worktree` flag and `EnterWorktree`
363+
- **Legacy:** `.worktrees/` as sibling to the main repo — used for manual `git worktree add` and Project Manager integration
364+
357365
Project detection:
358366
- Worktrees in `.worktrees/` are auto-detected by `setup-projects.sh` and tagged with both `"git"` and `"worktree"` in Project Manager
359367
- Each worktree is an independent working directory — workspace-scope-guard treats them as separate project directories

.devcontainer/docs/plugins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins/devs-marketplace/
1616
├── protected-files-guard/ # Safety: protect sensitive files
1717
├── auto-code-quality/ # Batch formatter + linter + advisory test runner
1818
├── agent-system/ # 17 custom agents + redirection hooks
19-
├── skill-engine/ # 21 coding skills + auto-suggestion
19+
├── skill-engine/ # 22 coding skills + auto-suggestion
2020
├── spec-workflow/ # 8 spec lifecycle skills + spec-reminder
2121
├── session-context/ # Git state, TODO harvesting, commit reminders
2222
└── workspace-scope-guard/ # Workspace scope enforcement
@@ -153,9 +153,9 @@ For detailed agent documentation, see `plugins/devs-marketplace/plugins/agent-sy
153153

154154
### skill-engine
155155

156-
**Purpose**: 21 domain-specific coding reference skills with auto-suggestion.
156+
**Purpose**: 22 domain-specific coding reference skills with auto-suggestion.
157157

158-
**Skills**: fastapi, svelte5, docker, docker-py, pydantic-ai, sqlite, testing, debugging, security-checklist, refactoring-patterns, git-forensics, performance-profiling, documentation-patterns, migration-patterns, dependency-management, claude-code-headless, claude-agent-sdk, ast-grep-patterns, api-design, skill-building, team
158+
**Skills**: fastapi, svelte5, docker, docker-py, pydantic-ai, sqlite, testing, debugging, security-checklist, refactoring-patterns, git-forensics, performance-profiling, documentation-patterns, migration-patterns, dependency-management, claude-code-headless, claude-agent-sdk, ast-grep-patterns, api-design, skill-building, team, worktree
159159

160160
**How it works**: Skills are loaded on demand via the Skill tool. A PreToolUse hook auto-suggests relevant skills based on conversation context.
161161

.devcontainer/plugins/devs-marketplace/plugins/skill-engine/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "skill-engine",
3-
"description": "21 coding knowledge packs with auto-suggestion for frameworks, tools, and patterns",
3+
"description": "22 coding knowledge packs with auto-suggestion for frameworks, tools, and patterns",
44
"author": {
55
"name": "AnExiledDev"
66
}

.devcontainer/plugins/devs-marketplace/plugins/skill-engine/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# skill-engine
22

3-
Claude Code plugin that provides 21 coding knowledge packs (skills) with automatic suggestion based on user prompts. Each skill contains domain-specific instructions and reference material that Claude loads on demand via the `/skill` command.
3+
Claude Code plugin that provides 22 coding knowledge packs (skills) with automatic suggestion based on user prompts. Each skill contains domain-specific instructions and reference material that Claude loads on demand via the `/skill` command.
44

55
## What It Does
66

77
Two capabilities:
88

9-
1. **Skill library**21 skills covering frameworks, tools, and development patterns. Each skill is a structured knowledge pack with a `SKILL.md` entrypoint and `references/` subdirectory containing detailed reference docs.
9+
1. **Skill library**22 skills covering frameworks, tools, and development patterns. Each skill is a structured knowledge pack with a `SKILL.md` entrypoint and `references/` subdirectory containing detailed reference docs.
1010

1111
2. **Auto-suggestion** — A `UserPromptSubmit` hook watches user prompts for keyword matches and suggests relevant skills as context, so Claude can proactively load the right knowledge.
1212

@@ -35,6 +35,7 @@ Two capabilities:
3535
| svelte5 | Runes, reactivity, components, SPA routing, LayerCake |
3636
| team | Agent team orchestration, parallel workstreams, task coordination |
3737
| testing | Testing frameworks, FastAPI testing, Svelte testing |
38+
| worktree | Git worktree lifecycle, EnterWorktree, parallel development |
3839

3940
### Auto-Suggestion
4041

@@ -128,7 +129,7 @@ skill-engine/
128129
+-- scripts/
129130
| +-- skill-suggester.py # Keyword-based skill auto-suggestion
130131
+-- skills/
131-
| +-- api-design/ # 21 skill directories
132+
| +-- api-design/ # 22 skill directories
132133
| +-- ast-grep-patterns/
133134
| +-- claude-agent-sdk/
134135
| +-- claude-code-headless/
@@ -149,6 +150,7 @@ skill-engine/
149150
| +-- svelte5/
150151
| +-- team/
151152
| +-- testing/
153+
| +-- worktree/
152154
+-- README.md # This file
153155
```
154156

.devcontainer/plugins/devs-marketplace/plugins/skill-engine/scripts/skill-suggester.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,21 @@
415415
],
416416
"terms": ["TeamCreate", "SendMessage"],
417417
},
418+
"worktree": {
419+
"phrases": [
420+
"create a worktree",
421+
"work in a worktree",
422+
"git worktree",
423+
"worktree",
424+
"parallel branches",
425+
"isolate my work",
426+
"clean up worktrees",
427+
"list worktrees",
428+
"set up a worktree",
429+
"enter worktree",
430+
],
431+
"terms": ["worktree", "EnterWorktree", "WorktreeCreate"],
432+
},
418433
}
419434

420435
# Pre-compile term patterns for whole-word matching

0 commit comments

Comments
 (0)