@waoooo/claude-skills 1.0.0
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.
- package/README.md +48 -0
- package/package.json +28 -0
- package/registry.json +431 -0
- package/skills/acceptance-review/SKILL.md +537 -0
- package/skills/all-plan/SKILL.md +19 -0
- package/skills/all-plan/references/flow.md +750 -0
- package/skills/api-docs-generate/SKILL.md +204 -0
- package/skills/api-docs-generate/assets/templates/api.mdx +140 -0
- package/skills/api-docs-generate/scripts/generate-api-docs.ts +308 -0
- package/skills/ask/SKILL.md +42 -0
- package/skills/autonew/SKILL.md +34 -0
- package/skills/capability-analyze/SKILL.md +300 -0
- package/skills/capability-analyze/scripts/analyze-capabilities.ts +531 -0
- package/skills/capability-docs-generate/SKILL.md +155 -0
- package/skills/capability-docs-generate/assets/templates/capability.mdx +271 -0
- package/skills/capability-docs-generate/scripts/generate-capability-docs.ts +358 -0
- package/skills/capability-tree-query/SKILL.md +112 -0
- package/skills/capability-tree-query/scripts/build-capability-tree.ts +402 -0
- package/skills/changelog-generator/SKILL.md +104 -0
- package/skills/continue/SKILL.md +39 -0
- package/skills/continue/agents/openai.yaml +3 -0
- package/skills/creating-skills/SKILL.md +158 -0
- package/skills/creating-skills/references/official_best_practices.md +128 -0
- package/skills/creating-skills/references/skill_examples.md +199 -0
- package/skills/docx/LICENSE.txt +30 -0
- package/skills/docx/SKILL.md +197 -0
- package/skills/docx/docx-js.md +350 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/ooxml/scripts/pack.py +159 -0
- package/skills/docx/ooxml/scripts/unpack.py +29 -0
- package/skills/docx/ooxml/scripts/validate.py +69 -0
- package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/docx/ooxml.md +610 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/document.py +1276 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/docx/scripts/utilities.py +374 -0
- package/skills/git-branch-create/SKILL.md +170 -0
- package/skills/git-branch-merge/SKILL.md +176 -0
- package/skills/git-commit/SKILL.md +56 -0
- package/skills/git-commit/references/commit_examples.md +311 -0
- package/skills/github-actions-trigger/SKILL.md +367 -0
- package/skills/github-issue-create/SKILL.md +294 -0
- package/skills/github-pr-creation/SKILL.md +137 -0
- package/skills/github-pr-creation/references/pr_templates.md +187 -0
- package/skills/github-pr-merge/SKILL.md +112 -0
- package/skills/github-pr-review/SKILL.md +110 -0
- package/skills/github-pr-review/references/severity_guide.md +168 -0
- package/skills/job-create/SKILL.md +294 -0
- package/skills/job-create/scripts/create-job.ts +105 -0
- package/skills/job-workflow/SKILL.md +212 -0
- package/skills/keyword-extract/SKILL.md +229 -0
- package/skills/mcp-builder/LICENSE.txt +202 -0
- package/skills/mcp-builder/SKILL.md +236 -0
- package/skills/mcp-builder/reference/evaluation.md +602 -0
- package/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills/mcp-builder/scripts/connections.py +151 -0
- package/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/mdx-to-openspec/SKILL.md +827 -0
- package/skills/mdx-to-openspec/scripts/mdx-to-openspec.ts +320 -0
- package/skills/mounted/SKILL.md +20 -0
- package/skills/multi-model-review/SKILL.md +459 -0
- package/skills/notion-automation/SKILL.md +215 -0
- package/skills/openspec-review/SKILL.md +513 -0
- package/skills/pdf/LICENSE.txt +30 -0
- package/skills/pdf/SKILL.md +294 -0
- package/skills/pdf/forms.md +205 -0
- package/skills/pdf/reference.md +612 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/pdf/scripts/create_validation_image.py +41 -0
- package/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/skills/pend/SKILL.md +33 -0
- package/skills/ping/SKILL.md +39 -0
- package/skills/pptx/LICENSE.txt +30 -0
- package/skills/pptx/SKILL.md +484 -0
- package/skills/pptx/html2pptx.md +625 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/pptx/ooxml/scripts/pack.py +159 -0
- package/skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/skills/pptx/ooxml/scripts/validate.py +69 -0
- package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/pptx/ooxml.md +427 -0
- package/skills/pptx/scripts/html2pptx.js +979 -0
- package/skills/pptx/scripts/inventory.py +1020 -0
- package/skills/pptx/scripts/rearrange.py +231 -0
- package/skills/pptx/scripts/replace.py +385 -0
- package/skills/pptx/scripts/thumbnail.py +450 -0
- package/skills/progress-update/SKILL.md +394 -0
- package/skills/progress-update/scripts/update-progress.ts +221 -0
- package/skills/release-automation/SKILL.md +306 -0
- package/skills/requirement-parse/SKILL.md +212 -0
- package/skills/requirement-parse/scripts/infer-builder-config.ts +346 -0
- package/skills/requirement-parse/scripts/merge-requirements.ts +228 -0
- package/skills/requirement-parse/scripts/parse-docs.ts +206 -0
- package/skills/requirement-parse/scripts/parse-openspec.ts +168 -0
- package/skills/roadmap-docs-generate/SKILL.md +483 -0
- package/skills/roadmap-docs-generate/assets/templates/ROADMAP.mdx +75 -0
- package/skills/roadmap-docs-generate/assets/templates/ROADMAP.mdx.template +330 -0
- package/skills/roadmap-docs-generate/assets/templates/TODO.mdx +56 -0
- package/skills/roadmap-docs-generate/assets/templates/TODO.mdx.template +363 -0
- package/skills/roadmap-docs-generate/scripts/json-to-mdx.ts +445 -0
- package/skills/roadmap-docs-generate/scripts/json-to-mdx.ts.backup +411 -0
- package/skills/roadmap-generate/SKILL.md +396 -0
- package/skills/roadmap-generate/scripts/generate-roadmap.ts +496 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +356 -0
- package/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/skills/spec-generate/SKILL.md +408 -0
- package/skills/spec-generate/scripts/generate-specs.ts +538 -0
- package/skills/spec-generate/scripts/generate-tasks.ts +174 -0
- package/skills/specs-review/SKILL.md +370 -0
- package/skills/task-execute/SKILL.md +399 -0
- package/skills/task-update-status/SKILL.md +349 -0
- package/skills/task-update-status/scripts/update-task-status.ts +192 -0
- package/skills/task-verify/SKILL.md +407 -0
- package/skills/ui-ux-pro-max/SKILL.md +386 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/skills/vercel-automation/SKILL.md +226 -0
- package/skills/webapp-testing/LICENSE.txt +202 -0
- package/skills/webapp-testing/SKILL.md +96 -0
- package/skills/webapp-testing/examples/console_logging.py +35 -0
- package/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/skills/webapp-testing/scripts/with_server.py +106 -0
- package/skills/worktree-manager/SKILL.md +725 -0
- package/skills/worktree-manager/config.json +15 -0
- package/skills/worktree-manager/scripts/allocate-ports.sh +100 -0
- package/skills/worktree-manager/scripts/cleanup.sh +185 -0
- package/skills/worktree-manager/scripts/launch-agent.sh +155 -0
- package/skills/worktree-manager/scripts/register.sh +125 -0
- package/skills/worktree-manager/scripts/release-ports.sh +48 -0
- package/skills/worktree-manager/scripts/status.sh +169 -0
- package/skills/worktree-manager/scripts/sync.sh +168 -0
- package/skills/worktree-manager/templates/worktree.json +23 -0
- package/skills/xlsx/LICENSE.txt +30 -0
- package/skills/xlsx/SKILL.md +289 -0
- package/skills/xlsx/recalc.py +178 -0
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worktree-manager
|
|
3
|
+
description: Create, manage, and cleanup git worktrees with Claude Code agents across all projects. USE THIS SKILL when user says "create worktree", "spin up worktrees", "new worktree for X", "worktree status", "cleanup worktrees", "sync worktrees", or wants parallel development branches. Also use when creating PRs from a worktree branch (to update registry with PR number). Handles worktree creation, dependency installation, validation, agent launching in Ghostty, and global registry management.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Global Worktree Manager
|
|
7
|
+
|
|
8
|
+
Manage parallel development across ALL projects using git worktrees with Claude Code agents. Each worktree is an isolated copy of the repo on a different branch, stored centrally at `~/tmp/worktrees/`.
|
|
9
|
+
|
|
10
|
+
**IMPORTANT**: You (Claude) can perform ALL operations manually using standard tools (jq, git, bash). Scripts are helpers, not requirements. If a script fails, fall back to manual operations described in this document.
|
|
11
|
+
|
|
12
|
+
## When This Skill Activates
|
|
13
|
+
|
|
14
|
+
**Trigger phrases:**
|
|
15
|
+
- "spin up worktrees for X, Y, Z"
|
|
16
|
+
- "create 3 worktrees for features A, B, C"
|
|
17
|
+
- "new worktree for feature/auth"
|
|
18
|
+
- "what's the status of my worktrees?"
|
|
19
|
+
- "show all worktrees" / "show worktrees for this project"
|
|
20
|
+
- "clean up merged worktrees"
|
|
21
|
+
- "clean up the auth worktree"
|
|
22
|
+
- "launch agent in worktree X"
|
|
23
|
+
- "sync worktrees" / "sync worktree registry"
|
|
24
|
+
- "create PR" (when in a worktree - updates registry with PR number)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## File Locations
|
|
29
|
+
|
|
30
|
+
| File | Purpose |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| `~/.claude/worktree-registry.json` | **Global registry** - tracks all worktrees across all projects |
|
|
33
|
+
| `~/.claude/skills/worktree-manager/config.json` | **Skill config** - terminal, shell, port range settings |
|
|
34
|
+
| `~/.claude/skills/worktree-manager/scripts/` | **Helper scripts** - optional, can do everything manually |
|
|
35
|
+
| `~/tmp/worktrees/` | **Worktree storage** - all worktrees live here |
|
|
36
|
+
| `.claude/worktree.json` (per-project) | **Project config** - optional custom settings |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Core Concepts
|
|
41
|
+
|
|
42
|
+
### Centralized Worktree Storage
|
|
43
|
+
All worktrees live in `~/tmp/worktrees/<project-name>/<branch-slug>/`
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
~/tmp/worktrees/
|
|
47
|
+
├── obsidian-ai-agent/
|
|
48
|
+
│ ├── feature-auth/ # branch: feature/auth
|
|
49
|
+
│ ├── feature-payments/ # branch: feature/payments
|
|
50
|
+
│ └── fix-login-bug/ # branch: fix/login-bug
|
|
51
|
+
└── another-project/
|
|
52
|
+
└── feature-dark-mode/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Branch Slug Convention
|
|
56
|
+
Branch names are slugified for filesystem safety by replacing `/` with `-`:
|
|
57
|
+
- `feature/auth` → `feature-auth`
|
|
58
|
+
- `fix/login-bug` → `fix-login-bug`
|
|
59
|
+
- `feat/user-profile` → `feat-user-profile`
|
|
60
|
+
|
|
61
|
+
**Slugify manually:** `echo "feature/auth" | tr '/' '-'` → `feature-auth`
|
|
62
|
+
|
|
63
|
+
### Port Allocation Rules
|
|
64
|
+
- **Global pool**: 8100-8199 (100 ports total)
|
|
65
|
+
- **Per worktree**: 2 ports allocated (for API + frontend patterns)
|
|
66
|
+
- **Globally unique**: Ports are tracked globally to avoid conflicts across projects
|
|
67
|
+
- **Check before use**: Always verify port isn't in use by system: `lsof -i :<port>`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Global Registry
|
|
72
|
+
|
|
73
|
+
### Location
|
|
74
|
+
`~/.claude/worktree-registry.json`
|
|
75
|
+
|
|
76
|
+
### Schema
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"worktrees": [
|
|
80
|
+
{
|
|
81
|
+
"id": "unique-uuid",
|
|
82
|
+
"project": "obsidian-ai-agent",
|
|
83
|
+
"repoPath": "/Users/rasmus/Projects/obsidian-ai-agent",
|
|
84
|
+
"branch": "feature/auth",
|
|
85
|
+
"branchSlug": "feature-auth",
|
|
86
|
+
"worktreePath": "/Users/rasmus/tmp/worktrees/obsidian-ai-agent/feature-auth",
|
|
87
|
+
"ports": [8100, 8101],
|
|
88
|
+
"createdAt": "2025-12-04T10:00:00Z",
|
|
89
|
+
"validatedAt": "2025-12-04T10:02:00Z",
|
|
90
|
+
"agentLaunchedAt": "2025-12-04T10:03:00Z",
|
|
91
|
+
"task": "Implement OAuth login",
|
|
92
|
+
"prNumber": null,
|
|
93
|
+
"status": "active"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"portPool": {
|
|
97
|
+
"start": 8100,
|
|
98
|
+
"end": 8199,
|
|
99
|
+
"allocated": [8100, 8101]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Field Descriptions
|
|
105
|
+
|
|
106
|
+
**Worktree entry fields:**
|
|
107
|
+
| Field | Type | Description |
|
|
108
|
+
|-------|------|-------------|
|
|
109
|
+
| `id` | string | Unique identifier (UUID) |
|
|
110
|
+
| `project` | string | Project name (from git remote or directory) |
|
|
111
|
+
| `repoPath` | string | Absolute path to original repository |
|
|
112
|
+
| `branch` | string | Full branch name (e.g., `feature/auth`) |
|
|
113
|
+
| `branchSlug` | string | Filesystem-safe name (e.g., `feature-auth`) |
|
|
114
|
+
| `worktreePath` | string | Absolute path to worktree |
|
|
115
|
+
| `ports` | number[] | Allocated port numbers (usually 2) |
|
|
116
|
+
| `createdAt` | string | ISO 8601 timestamp |
|
|
117
|
+
| `validatedAt` | string\|null | When validation passed |
|
|
118
|
+
| `agentLaunchedAt` | string\|null | When agent was launched |
|
|
119
|
+
| `task` | string\|null | Task description for the agent |
|
|
120
|
+
| `prNumber` | number\|null | Associated PR number if exists |
|
|
121
|
+
| `status` | string | `active`, `orphaned`, or `merged` |
|
|
122
|
+
|
|
123
|
+
**Port pool fields:**
|
|
124
|
+
| Field | Type | Description |
|
|
125
|
+
|-------|------|-------------|
|
|
126
|
+
| `start` | number | First port in pool (default: 8100) |
|
|
127
|
+
| `end` | number | Last port in pool (default: 8199) |
|
|
128
|
+
| `allocated` | number[] | Currently allocated ports |
|
|
129
|
+
|
|
130
|
+
### Manual Registry Operations
|
|
131
|
+
|
|
132
|
+
**Read entire registry:**
|
|
133
|
+
```bash
|
|
134
|
+
cat ~/.claude/worktree-registry.json | jq '.'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**List all worktrees:**
|
|
138
|
+
```bash
|
|
139
|
+
cat ~/.claude/worktree-registry.json | jq '.worktrees[]'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**List worktrees for specific project:**
|
|
143
|
+
```bash
|
|
144
|
+
cat ~/.claude/worktree-registry.json | jq '.worktrees[] | select(.project == "my-project")'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Get allocated ports:**
|
|
148
|
+
```bash
|
|
149
|
+
cat ~/.claude/worktree-registry.json | jq '.portPool.allocated'
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Find worktree by branch (partial match):**
|
|
153
|
+
```bash
|
|
154
|
+
cat ~/.claude/worktree-registry.json | jq '.worktrees[] | select(.branch | contains("auth"))'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Add worktree entry manually:**
|
|
158
|
+
```bash
|
|
159
|
+
TMP=$(mktemp)
|
|
160
|
+
jq '.worktrees += [{
|
|
161
|
+
"id": "'$(uuidgen)'",
|
|
162
|
+
"project": "my-project",
|
|
163
|
+
"repoPath": "/path/to/repo",
|
|
164
|
+
"branch": "feature/auth",
|
|
165
|
+
"branchSlug": "feature-auth",
|
|
166
|
+
"worktreePath": "/Users/me/tmp/worktrees/my-project/feature-auth",
|
|
167
|
+
"ports": [8100, 8101],
|
|
168
|
+
"createdAt": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
|
|
169
|
+
"validatedAt": null,
|
|
170
|
+
"agentLaunchedAt": null,
|
|
171
|
+
"task": "My task",
|
|
172
|
+
"prNumber": null,
|
|
173
|
+
"status": "active"
|
|
174
|
+
}]' ~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Add ports to allocated pool:**
|
|
178
|
+
```bash
|
|
179
|
+
TMP=$(mktemp)
|
|
180
|
+
jq '.portPool.allocated += [8100, 8101] | .portPool.allocated |= unique | .portPool.allocated |= sort_by(.)' \
|
|
181
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Remove worktree entry:**
|
|
185
|
+
```bash
|
|
186
|
+
TMP=$(mktemp)
|
|
187
|
+
jq 'del(.worktrees[] | select(.project == "my-project" and .branch == "feature/auth"))' \
|
|
188
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Release ports from pool:**
|
|
192
|
+
```bash
|
|
193
|
+
TMP=$(mktemp)
|
|
194
|
+
jq '.portPool.allocated = (.portPool.allocated | map(select(. != 8100 and . != 8101)))' \
|
|
195
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Initialize empty registry (if missing):**
|
|
199
|
+
```bash
|
|
200
|
+
mkdir -p ~/.claude
|
|
201
|
+
cat > ~/.claude/worktree-registry.json << 'EOF'
|
|
202
|
+
{
|
|
203
|
+
"worktrees": [],
|
|
204
|
+
"portPool": {
|
|
205
|
+
"start": 8100,
|
|
206
|
+
"end": 8199,
|
|
207
|
+
"allocated": []
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
EOF
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Manual Port Allocation
|
|
216
|
+
|
|
217
|
+
If `scripts/allocate-ports.sh` fails, allocate ports manually:
|
|
218
|
+
|
|
219
|
+
**Step 1: Get currently allocated ports**
|
|
220
|
+
```bash
|
|
221
|
+
ALLOCATED=$(cat ~/.claude/worktree-registry.json | jq -r '.portPool.allocated[]' | sort -n)
|
|
222
|
+
echo "Currently allocated: $ALLOCATED"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Step 2: Find first available port (not in allocated list AND not in use by system)**
|
|
226
|
+
```bash
|
|
227
|
+
for PORT in $(seq 8100 8199); do
|
|
228
|
+
# Check if in registry
|
|
229
|
+
if ! echo "$ALLOCATED" | grep -q "^${PORT}$"; then
|
|
230
|
+
# Check if in use by system
|
|
231
|
+
if ! lsof -i :"$PORT" &>/dev/null; then
|
|
232
|
+
echo "Available: $PORT"
|
|
233
|
+
break
|
|
234
|
+
fi
|
|
235
|
+
fi
|
|
236
|
+
done
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Step 3: Add to allocated pool**
|
|
240
|
+
```bash
|
|
241
|
+
TMP=$(mktemp)
|
|
242
|
+
jq '.portPool.allocated += [8100] | .portPool.allocated |= unique | .portPool.allocated |= sort_by(.)' \
|
|
243
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## What You (Claude) Do vs What Scripts Do
|
|
249
|
+
|
|
250
|
+
| Task | Script Available | Manual Fallback |
|
|
251
|
+
|------|------------------|-----------------|
|
|
252
|
+
| Determine project name | No | Parse `git remote get-url origin` or `basename $(pwd)` |
|
|
253
|
+
| Detect package manager | No | Check for lockfiles (see Detection section) |
|
|
254
|
+
| Create git worktree | No | `git worktree add <path> -b <branch>` |
|
|
255
|
+
| Copy .agents/ directory | No | `cp -r .agents <worktree-path>/` |
|
|
256
|
+
| Install dependencies | No | Run detected install command |
|
|
257
|
+
| Validate (health check) | No | Start server, curl endpoint, stop server |
|
|
258
|
+
| Allocate ports | `scripts/allocate-ports.sh 2` | Manual (see above) |
|
|
259
|
+
| Register worktree | `scripts/register.sh` | Manual jq (see above) |
|
|
260
|
+
| Launch agent in terminal | `scripts/launch-agent.sh` | Manual (see below) |
|
|
261
|
+
| Show status | `scripts/status.sh` | `cat ~/.claude/worktree-registry.json \| jq ...` |
|
|
262
|
+
| Cleanup worktree | `scripts/cleanup.sh` | Manual (see Cleanup section) |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Workflows
|
|
267
|
+
|
|
268
|
+
### 1. Create Multiple Worktrees with Agents
|
|
269
|
+
|
|
270
|
+
**User says:** "Spin up 3 worktrees for feature/auth, feature/payments, and fix/login-bug"
|
|
271
|
+
|
|
272
|
+
**You do (can parallelize with subagents):**
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
For EACH branch (can run in parallel):
|
|
276
|
+
|
|
277
|
+
1. SETUP
|
|
278
|
+
a. Get project name:
|
|
279
|
+
PROJECT=$(basename $(git remote get-url origin 2>/dev/null | sed 's/\.git$//') 2>/dev/null || basename $(pwd))
|
|
280
|
+
b. Get repo root:
|
|
281
|
+
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
282
|
+
c. Slugify branch:
|
|
283
|
+
BRANCH_SLUG=$(echo "feature/auth" | tr '/' '-')
|
|
284
|
+
d. Determine worktree path:
|
|
285
|
+
WORKTREE_PATH=~/tmp/worktrees/$PROJECT/$BRANCH_SLUG
|
|
286
|
+
|
|
287
|
+
2. ALLOCATE PORTS
|
|
288
|
+
Option A (script): ~/.claude/skills/worktree-manager/scripts/allocate-ports.sh 2
|
|
289
|
+
Option B (manual): Find 2 unused ports from 8100-8199, add to registry
|
|
290
|
+
|
|
291
|
+
3. CREATE WORKTREE
|
|
292
|
+
mkdir -p ~/tmp/worktrees/$PROJECT
|
|
293
|
+
git worktree add $WORKTREE_PATH -b $BRANCH
|
|
294
|
+
# If branch exists already, omit -b flag
|
|
295
|
+
|
|
296
|
+
4. COPY UNCOMMITTED RESOURCES
|
|
297
|
+
cp -r .agents $WORKTREE_PATH/ 2>/dev/null || true
|
|
298
|
+
cp .env.example $WORKTREE_PATH/.env 2>/dev/null || true
|
|
299
|
+
|
|
300
|
+
5. INSTALL DEPENDENCIES
|
|
301
|
+
cd $WORKTREE_PATH
|
|
302
|
+
# Detect and run: npm install / uv sync / etc.
|
|
303
|
+
|
|
304
|
+
6. VALIDATE (start server, health check, stop)
|
|
305
|
+
a. Start server with allocated port
|
|
306
|
+
b. Wait and health check: curl -sf http://localhost:$PORT/health
|
|
307
|
+
c. Stop server
|
|
308
|
+
d. If FAILS: report error but continue with other worktrees
|
|
309
|
+
|
|
310
|
+
7. REGISTER IN GLOBAL REGISTRY
|
|
311
|
+
Option A (script): ~/.claude/skills/worktree-manager/scripts/register.sh ...
|
|
312
|
+
Option B (manual): Update ~/.claude/worktree-registry.json with jq
|
|
313
|
+
|
|
314
|
+
8. LAUNCH AGENT
|
|
315
|
+
Option A (script): ~/.claude/skills/worktree-manager/scripts/launch-agent.sh $WORKTREE_PATH "task"
|
|
316
|
+
Option B (manual): Open terminal manually, cd to path, run claude
|
|
317
|
+
|
|
318
|
+
AFTER ALL COMPLETE:
|
|
319
|
+
- Report summary table to user
|
|
320
|
+
- Note any failures with details
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### 2. Check Status
|
|
324
|
+
|
|
325
|
+
**With script:**
|
|
326
|
+
```bash
|
|
327
|
+
~/.claude/skills/worktree-manager/scripts/status.sh
|
|
328
|
+
~/.claude/skills/worktree-manager/scripts/status.sh --project my-project
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Manual:**
|
|
332
|
+
```bash
|
|
333
|
+
# All worktrees
|
|
334
|
+
cat ~/.claude/worktree-registry.json | jq -r '.worktrees[] | "\(.project)\t\(.branch)\t\(.ports | join(","))\t\(.status)\t\(.task // "-")"'
|
|
335
|
+
|
|
336
|
+
# For current project
|
|
337
|
+
PROJECT=$(basename $(git remote get-url origin 2>/dev/null | sed 's/\.git$//'))
|
|
338
|
+
cat ~/.claude/worktree-registry.json | jq -r ".worktrees[] | select(.project == \"$PROJECT\") | \"\(.branch)\t\(.ports | join(\",\"))\t\(.status)\""
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### 3. Launch Agent Manually
|
|
342
|
+
|
|
343
|
+
If `launch-agent.sh` fails:
|
|
344
|
+
|
|
345
|
+
**For Ghostty:**
|
|
346
|
+
```bash
|
|
347
|
+
open -na "Ghostty.app" --args -e fish -c "cd '$WORKTREE_PATH' && claude"
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**For iTerm2:**
|
|
351
|
+
```bash
|
|
352
|
+
osascript -e 'tell application "iTerm2" to create window with default profile' \
|
|
353
|
+
-e 'tell application "iTerm2" to tell current session of current window to write text "cd '"$WORKTREE_PATH"' && claude"'
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**For tmux:**
|
|
357
|
+
```bash
|
|
358
|
+
tmux new-session -d -s "wt-$PROJECT-$BRANCH_SLUG" -c "$WORKTREE_PATH" "fish -c 'claude'"
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### 4. Cleanup Worktree
|
|
362
|
+
|
|
363
|
+
**With script:**
|
|
364
|
+
```bash
|
|
365
|
+
~/.claude/skills/worktree-manager/scripts/cleanup.sh my-project feature/auth --delete-branch
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Manual cleanup:**
|
|
369
|
+
```bash
|
|
370
|
+
# 1. Get worktree info from registry
|
|
371
|
+
ENTRY=$(cat ~/.claude/worktree-registry.json | jq '.worktrees[] | select(.project == "my-project" and .branch == "feature/auth")')
|
|
372
|
+
WORKTREE_PATH=$(echo "$ENTRY" | jq -r '.worktreePath')
|
|
373
|
+
PORTS=$(echo "$ENTRY" | jq -r '.ports[]')
|
|
374
|
+
REPO_PATH=$(echo "$ENTRY" | jq -r '.repoPath')
|
|
375
|
+
|
|
376
|
+
# 2. Kill processes on ports
|
|
377
|
+
for PORT in $PORTS; do
|
|
378
|
+
lsof -ti:"$PORT" | xargs kill -9 2>/dev/null || true
|
|
379
|
+
done
|
|
380
|
+
|
|
381
|
+
# 3. Remove worktree
|
|
382
|
+
cd "$REPO_PATH"
|
|
383
|
+
git worktree remove "$WORKTREE_PATH" --force 2>/dev/null || rm -rf "$WORKTREE_PATH"
|
|
384
|
+
git worktree prune
|
|
385
|
+
|
|
386
|
+
# 4. Remove from registry
|
|
387
|
+
TMP=$(mktemp)
|
|
388
|
+
jq 'del(.worktrees[] | select(.project == "my-project" and .branch == "feature/auth"))' \
|
|
389
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
390
|
+
|
|
391
|
+
# 5. Release ports
|
|
392
|
+
TMP=$(mktemp)
|
|
393
|
+
for PORT in $PORTS; do
|
|
394
|
+
jq ".portPool.allocated = (.portPool.allocated | map(select(. != $PORT)))" \
|
|
395
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
396
|
+
done
|
|
397
|
+
|
|
398
|
+
# 6. Optionally delete branch
|
|
399
|
+
git branch -D feature/auth
|
|
400
|
+
git push origin --delete feature/auth
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 5. Create PR from Worktree
|
|
404
|
+
|
|
405
|
+
When creating a PR from a worktree branch, update the registry with the PR number:
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# After gh pr create succeeds, get the PR number
|
|
409
|
+
BRANCH=$(git branch --show-current)
|
|
410
|
+
PR_NUM=$(gh pr view --json number -q '.number')
|
|
411
|
+
|
|
412
|
+
# Update registry with PR number
|
|
413
|
+
if [ -n "$PR_NUM" ] && [ -f ~/.claude/worktree-registry.json ]; then
|
|
414
|
+
TMP=$(mktemp)
|
|
415
|
+
jq "(.worktrees[] | select(.branch == \"$BRANCH\")).prNumber = $PR_NUM" \
|
|
416
|
+
~/.claude/worktree-registry.json > "$TMP" && mv "$TMP" ~/.claude/worktree-registry.json
|
|
417
|
+
echo "Updated worktree registry with PR #$PR_NUM"
|
|
418
|
+
fi
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
This enables `cleanup.sh --merged` to automatically find and clean up worktrees after their PRs are merged.
|
|
422
|
+
|
|
423
|
+
### 6. Sync Registry
|
|
424
|
+
|
|
425
|
+
Reconcile registry with actual worktrees and PR status:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# Check status (no changes)
|
|
429
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh
|
|
430
|
+
|
|
431
|
+
# Auto-fix issues (update PR numbers, remove missing entries)
|
|
432
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh --fix
|
|
433
|
+
|
|
434
|
+
# Quiet mode (only show problems)
|
|
435
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh --quiet
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Package Manager Detection
|
|
441
|
+
|
|
442
|
+
Detect by checking for lockfiles in priority order:
|
|
443
|
+
|
|
444
|
+
| File | Package Manager | Install Command |
|
|
445
|
+
|------|-----------------|-----------------|
|
|
446
|
+
| `bun.lockb` | bun | `bun install` |
|
|
447
|
+
| `pnpm-lock.yaml` | pnpm | `pnpm install` |
|
|
448
|
+
| `yarn.lock` | yarn | `yarn install` |
|
|
449
|
+
| `package-lock.json` | npm | `npm install` |
|
|
450
|
+
| `uv.lock` | uv | `uv sync` |
|
|
451
|
+
| `pyproject.toml` (no uv.lock) | uv | `uv sync` |
|
|
452
|
+
| `requirements.txt` | pip | `pip install -r requirements.txt` |
|
|
453
|
+
| `go.mod` | go | `go mod download` |
|
|
454
|
+
| `Cargo.toml` | cargo | `cargo build` |
|
|
455
|
+
|
|
456
|
+
**Detection logic:**
|
|
457
|
+
```bash
|
|
458
|
+
cd $WORKTREE_PATH
|
|
459
|
+
if [ -f "bun.lockb" ]; then bun install
|
|
460
|
+
elif [ -f "pnpm-lock.yaml" ]; then pnpm install
|
|
461
|
+
elif [ -f "yarn.lock" ]; then yarn install
|
|
462
|
+
elif [ -f "package-lock.json" ]; then npm install
|
|
463
|
+
elif [ -f "uv.lock" ]; then uv sync
|
|
464
|
+
elif [ -f "pyproject.toml" ]; then uv sync
|
|
465
|
+
elif [ -f "requirements.txt" ]; then pip install -r requirements.txt
|
|
466
|
+
elif [ -f "go.mod" ]; then go mod download
|
|
467
|
+
elif [ -f "Cargo.toml" ]; then cargo build
|
|
468
|
+
fi
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## Dev Server Detection
|
|
474
|
+
|
|
475
|
+
Look for dev commands in this order:
|
|
476
|
+
|
|
477
|
+
1. **docker-compose.yml / compose.yml**: `docker-compose up -d` or `docker compose up -d`
|
|
478
|
+
2. **package.json scripts**: Look for `dev`, `start:dev`, `serve`
|
|
479
|
+
3. **Python with uvicorn**: `uv run uvicorn app.main:app --port $PORT`
|
|
480
|
+
4. **Python with Flask**: `flask run --port $PORT`
|
|
481
|
+
5. **Go**: `go run .`
|
|
482
|
+
|
|
483
|
+
**Port injection**: Most servers accept `PORT` env var or `--port` flag
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Project-Specific Config (Optional)
|
|
488
|
+
|
|
489
|
+
Projects can provide `.claude/worktree.json` for custom settings:
|
|
490
|
+
|
|
491
|
+
```json
|
|
492
|
+
{
|
|
493
|
+
"ports": {
|
|
494
|
+
"count": 2,
|
|
495
|
+
"services": ["api", "frontend"]
|
|
496
|
+
},
|
|
497
|
+
"install": "uv sync && cd frontend && npm install",
|
|
498
|
+
"validate": {
|
|
499
|
+
"start": "docker-compose up -d",
|
|
500
|
+
"healthCheck": "curl -sf http://localhost:{{PORT}}/health",
|
|
501
|
+
"stop": "docker-compose down"
|
|
502
|
+
},
|
|
503
|
+
"copyDirs": [".agents", ".env.example", "data/fixtures"]
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
If this file exists, use its settings. Otherwise, auto-detect.
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## Parallel Worktree Creation
|
|
512
|
+
|
|
513
|
+
When creating multiple worktrees, use subagents for parallelization:
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
User: "Spin up worktrees for feature/a, feature/b, feature/c"
|
|
517
|
+
|
|
518
|
+
You:
|
|
519
|
+
1. Allocate ports for ALL worktrees upfront (6 ports total)
|
|
520
|
+
2. Spawn 3 subagents, one per worktree
|
|
521
|
+
3. Each subagent:
|
|
522
|
+
- Creates its worktree
|
|
523
|
+
- Installs deps
|
|
524
|
+
- Validates
|
|
525
|
+
- Registers (with its pre-allocated ports)
|
|
526
|
+
- Launches agent
|
|
527
|
+
4. Collect results from all subagents
|
|
528
|
+
5. Report unified summary with any failures noted
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Safety Guidelines
|
|
534
|
+
|
|
535
|
+
1. **Before cleanup**, check PR status:
|
|
536
|
+
- PR merged → safe to clean everything
|
|
537
|
+
- PR open → warn user, confirm before proceeding
|
|
538
|
+
- No PR → warn about unsubmitted work
|
|
539
|
+
|
|
540
|
+
2. **Before deleting branches**, confirm if:
|
|
541
|
+
- PR not merged
|
|
542
|
+
- No PR exists
|
|
543
|
+
- Worktree has uncommitted changes
|
|
544
|
+
|
|
545
|
+
3. **Port conflicts**: If port in use by non-worktree process, pick different port
|
|
546
|
+
|
|
547
|
+
4. **Orphaned worktrees**: If original repo deleted, mark as `orphaned` in status
|
|
548
|
+
|
|
549
|
+
5. **Max worktrees**: With 100-port pool and 2 ports each, max ~50 concurrent worktrees
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## Script Reference
|
|
554
|
+
|
|
555
|
+
Scripts are in `~/.claude/skills/worktree-manager/scripts/`
|
|
556
|
+
|
|
557
|
+
### allocate-ports.sh
|
|
558
|
+
```bash
|
|
559
|
+
~/.claude/skills/worktree-manager/scripts/allocate-ports.sh <count>
|
|
560
|
+
# Returns: space-separated port numbers (e.g., "8100 8101")
|
|
561
|
+
# Automatically updates registry
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### register.sh
|
|
565
|
+
```bash
|
|
566
|
+
~/.claude/skills/worktree-manager/scripts/register.sh \
|
|
567
|
+
<project> <branch> <branch-slug> <worktree-path> <repo-path> <ports> [task]
|
|
568
|
+
# Example:
|
|
569
|
+
~/.claude/skills/worktree-manager/scripts/register.sh \
|
|
570
|
+
"my-project" "feature/auth" "feature-auth" \
|
|
571
|
+
"$HOME/tmp/worktrees/my-project/feature-auth" \
|
|
572
|
+
"/path/to/repo" "8100,8101" "Implement OAuth"
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### launch-agent.sh
|
|
576
|
+
```bash
|
|
577
|
+
~/.claude/skills/worktree-manager/scripts/launch-agent.sh <worktree-path> [task]
|
|
578
|
+
# Opens new terminal window (Ghostty by default) with Claude Code
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### status.sh
|
|
582
|
+
```bash
|
|
583
|
+
~/.claude/skills/worktree-manager/scripts/status.sh [--project <name>]
|
|
584
|
+
# Shows all worktrees, or filtered by project
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### cleanup.sh
|
|
588
|
+
```bash
|
|
589
|
+
~/.claude/skills/worktree-manager/scripts/cleanup.sh <project> <branch> [--delete-branch]
|
|
590
|
+
# Kills ports, removes worktree, updates registry
|
|
591
|
+
# --delete-branch also removes local and remote git branches
|
|
592
|
+
|
|
593
|
+
# Or cleanup ALL merged worktrees at once:
|
|
594
|
+
~/.claude/skills/worktree-manager/scripts/cleanup.sh --merged [--delete-branch]
|
|
595
|
+
# Finds all worktrees with merged PRs and cleans them up
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### sync.sh
|
|
599
|
+
```bash
|
|
600
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh [--quiet] [--fix]
|
|
601
|
+
# Reconciles registry with actual worktrees and PR status
|
|
602
|
+
# --quiet: Only show issues, not OK entries
|
|
603
|
+
# --fix: Automatically remove missing entries and update PR numbers/status
|
|
604
|
+
|
|
605
|
+
# Example: Check status without changing anything
|
|
606
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh
|
|
607
|
+
|
|
608
|
+
# Example: Auto-fix registry issues
|
|
609
|
+
~/.claude/skills/worktree-manager/scripts/sync.sh --fix
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### release-ports.sh
|
|
613
|
+
```bash
|
|
614
|
+
~/.claude/skills/worktree-manager/scripts/release-ports.sh <port1> [port2] ...
|
|
615
|
+
# Releases ports back to pool
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
---
|
|
619
|
+
|
|
620
|
+
## Skill Config
|
|
621
|
+
|
|
622
|
+
Location: `~/.claude/skills/worktree-manager/config.json`
|
|
623
|
+
|
|
624
|
+
```json
|
|
625
|
+
{
|
|
626
|
+
"terminal": "ghostty",
|
|
627
|
+
"shell": "fish",
|
|
628
|
+
"claudeCommand": "claude",
|
|
629
|
+
"portPool": {
|
|
630
|
+
"start": 8100,
|
|
631
|
+
"end": 8199
|
|
632
|
+
},
|
|
633
|
+
"portsPerWorktree": 2,
|
|
634
|
+
"worktreeBase": "~/tmp/worktrees",
|
|
635
|
+
"defaultCopyDirs": [".agents", ".env.example"]
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
**Terminal options**: `ghostty`, `iterm2`, `tmux`, `wezterm`, `kitty`, `alacritty`
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## Common Issues
|
|
644
|
+
|
|
645
|
+
### "Worktree already exists"
|
|
646
|
+
```bash
|
|
647
|
+
git worktree list
|
|
648
|
+
git worktree remove <path> --force
|
|
649
|
+
git worktree prune
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### "Branch already exists"
|
|
653
|
+
```bash
|
|
654
|
+
# Use existing branch (omit -b flag)
|
|
655
|
+
git worktree add <path> <branch>
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### "Port already in use"
|
|
659
|
+
```bash
|
|
660
|
+
lsof -i :<port>
|
|
661
|
+
# Kill if stale, or pick different port
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### Registry out of sync
|
|
665
|
+
```bash
|
|
666
|
+
# Compare registry to actual worktrees
|
|
667
|
+
cat ~/.claude/worktree-registry.json | jq '.worktrees[].worktreePath'
|
|
668
|
+
find ~/tmp/worktrees -maxdepth 2 -type d
|
|
669
|
+
|
|
670
|
+
# Remove orphaned entries or add missing ones
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Validation failed
|
|
674
|
+
1. Check stderr/logs for error message
|
|
675
|
+
2. Common issues: missing env vars, database not running, wrong port
|
|
676
|
+
3. Report to user with details
|
|
677
|
+
4. Continue with other worktrees
|
|
678
|
+
5. User can fix and re-validate manually
|
|
679
|
+
|
|
680
|
+
---
|
|
681
|
+
|
|
682
|
+
## Example Session
|
|
683
|
+
|
|
684
|
+
**User:** "Spin up 2 worktrees for feature/dark-mode and fix/login-bug"
|
|
685
|
+
|
|
686
|
+
**You:**
|
|
687
|
+
1. Detect project: `obsidian-ai-agent` (from git remote)
|
|
688
|
+
2. Detect package manager: `uv` (found uv.lock)
|
|
689
|
+
3. Allocate 4 ports: `~/.claude/skills/worktree-manager/scripts/allocate-ports.sh 4` → `8100 8101 8102 8103`
|
|
690
|
+
4. Create worktrees:
|
|
691
|
+
```bash
|
|
692
|
+
mkdir -p ~/tmp/worktrees/obsidian-ai-agent
|
|
693
|
+
git worktree add ~/tmp/worktrees/obsidian-ai-agent/feature-dark-mode -b feature/dark-mode
|
|
694
|
+
git worktree add ~/tmp/worktrees/obsidian-ai-agent/fix-login-bug -b fix/login-bug
|
|
695
|
+
```
|
|
696
|
+
5. Copy .agents/:
|
|
697
|
+
```bash
|
|
698
|
+
cp -r .agents ~/tmp/worktrees/obsidian-ai-agent/feature-dark-mode/
|
|
699
|
+
cp -r .agents ~/tmp/worktrees/obsidian-ai-agent/fix-login-bug/
|
|
700
|
+
```
|
|
701
|
+
6. Install deps in each worktree:
|
|
702
|
+
```bash
|
|
703
|
+
(cd ~/tmp/worktrees/obsidian-ai-agent/feature-dark-mode && uv sync)
|
|
704
|
+
(cd ~/tmp/worktrees/obsidian-ai-agent/fix-login-bug && uv sync)
|
|
705
|
+
```
|
|
706
|
+
7. Validate each (start server, health check, stop)
|
|
707
|
+
8. Register both worktrees in `~/.claude/worktree-registry.json`
|
|
708
|
+
9. Launch agents:
|
|
709
|
+
```bash
|
|
710
|
+
~/.claude/skills/worktree-manager/scripts/launch-agent.sh \
|
|
711
|
+
~/tmp/worktrees/obsidian-ai-agent/feature-dark-mode "Implement dark mode toggle"
|
|
712
|
+
~/.claude/skills/worktree-manager/scripts/launch-agent.sh \
|
|
713
|
+
~/tmp/worktrees/obsidian-ai-agent/fix-login-bug "Fix login redirect bug"
|
|
714
|
+
```
|
|
715
|
+
10. Report:
|
|
716
|
+
```
|
|
717
|
+
Created 2 worktrees with agents:
|
|
718
|
+
|
|
719
|
+
| Branch | Ports | Path | Task |
|
|
720
|
+
|--------|-------|------|------|
|
|
721
|
+
| feature/dark-mode | 8100, 8101 | ~/tmp/worktrees/.../feature-dark-mode | Implement dark mode |
|
|
722
|
+
| fix/login-bug | 8102, 8103 | ~/tmp/worktrees/.../fix-login-bug | Fix login redirect |
|
|
723
|
+
|
|
724
|
+
Both agents running in Ghostty windows.
|
|
725
|
+
```
|