ccjk 3.7.3 → 3.7.4

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 (86) hide show
  1. package/dist/chunks/package.mjs +1 -1
  2. package/package.json +54 -54
  3. package/templates/CLAUDE.md +0 -219
  4. package/templates/claude-code/CLAUDE.md +0 -250
  5. package/templates/claude-code/common/settings.json +0 -37
  6. package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +0 -165
  7. package/templates/claude-code/en/workflow/common/agents/get-current-datetime.md +0 -29
  8. package/templates/claude-code/en/workflow/common/agents/init-architect.md +0 -114
  9. package/templates/claude-code/en/workflow/common/commands/init-project.md +0 -53
  10. package/templates/claude-code/en/workflow/essential/agents/get-current-datetime.md +0 -29
  11. package/templates/claude-code/en/workflow/essential/agents/init-architect.md +0 -114
  12. package/templates/claude-code/en/workflow/essential/agents/planner.md +0 -116
  13. package/templates/claude-code/en/workflow/essential/agents/ui-ux-designer.md +0 -91
  14. package/templates/claude-code/en/workflow/essential/commands/feat.md +0 -250
  15. package/templates/claude-code/en/workflow/essential/commands/init-project.md +0 -53
  16. package/templates/claude-code/en/workflow/plan/agents/planner.md +0 -116
  17. package/templates/claude-code/en/workflow/plan/agents/ui-ux-designer.md +0 -91
  18. package/templates/claude-code/en/workflow/plan/commands/feat.md +0 -105
  19. package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +0 -172
  20. package/templates/claude-code/zh-CN/workflow/common/agents/get-current-datetime.md +0 -29
  21. package/templates/claude-code/zh-CN/workflow/common/agents/init-architect.md +0 -114
  22. package/templates/claude-code/zh-CN/workflow/common/commands/init-project.md +0 -53
  23. package/templates/claude-code/zh-CN/workflow/essential/agents/get-current-datetime.md +0 -29
  24. package/templates/claude-code/zh-CN/workflow/essential/agents/init-architect.md +0 -114
  25. package/templates/claude-code/zh-CN/workflow/essential/agents/planner.md +0 -116
  26. package/templates/claude-code/zh-CN/workflow/essential/agents/ui-ux-designer.md +0 -91
  27. package/templates/claude-code/zh-CN/workflow/essential/commands/feat.md +0 -248
  28. package/templates/claude-code/zh-CN/workflow/essential/commands/init-project.md +0 -53
  29. package/templates/claude-code/zh-CN/workflow/plan/agents/planner.md +0 -116
  30. package/templates/claude-code/zh-CN/workflow/plan/agents/ui-ux-designer.md +0 -91
  31. package/templates/claude-code/zh-CN/workflow/plan/commands/feat.md +0 -105
  32. package/templates/codex/common/config.toml +0 -0
  33. package/templates/common/output-styles/en/casual-friendly.md +0 -97
  34. package/templates/common/output-styles/en/expert-concise.md +0 -93
  35. package/templates/common/output-styles/en/pair-programmer.md +0 -177
  36. package/templates/common/output-styles/en/senior-architect.md +0 -121
  37. package/templates/common/output-styles/en/speed-coder.md +0 -185
  38. package/templates/common/output-styles/en/teaching-mode.md +0 -102
  39. package/templates/common/output-styles/en/technical-precise.md +0 -101
  40. package/templates/common/output-styles/zh-CN/pair-programmer.md +0 -177
  41. package/templates/common/output-styles/zh-CN/senior-architect.md +0 -297
  42. package/templates/common/output-styles/zh-CN/speed-coder.md +0 -185
  43. package/templates/common/skills/code-review.md +0 -343
  44. package/templates/common/skills/en/agent-browser.md +0 -258
  45. package/templates/common/skills/en/brainstorming.md +0 -64
  46. package/templates/common/skills/en/code-review.md +0 -81
  47. package/templates/common/skills/en/documentation-gen.md +0 -808
  48. package/templates/common/skills/en/executing-plans.md +0 -75
  49. package/templates/common/skills/en/git-commit.md +0 -216
  50. package/templates/common/skills/en/interview.md +0 -223
  51. package/templates/common/skills/en/migration-assistant.md +0 -312
  52. package/templates/common/skills/en/performance-profiling.md +0 -576
  53. package/templates/common/skills/en/pr-review.md +0 -341
  54. package/templates/common/skills/en/refactoring.md +0 -384
  55. package/templates/common/skills/en/security-audit.md +0 -462
  56. package/templates/common/skills/en/systematic-debugging.md +0 -82
  57. package/templates/common/skills/en/tdd-workflow.md +0 -93
  58. package/templates/common/skills/en/verification.md +0 -81
  59. package/templates/common/skills/en/workflow.md +0 -370
  60. package/templates/common/skills/en/writing-plans.md +0 -78
  61. package/templates/common/skills/summarize.md +0 -312
  62. package/templates/common/skills/translate.md +0 -202
  63. package/templates/common/skills/zh-CN/agent-browser.md +0 -260
  64. package/templates/common/skills/zh-CN/documentation-gen.md +0 -807
  65. package/templates/common/skills/zh-CN/migration-assistant.md +0 -318
  66. package/templates/common/skills/zh-CN/performance-profiling.md +0 -746
  67. package/templates/common/skills/zh-CN/pr-review.md +0 -341
  68. package/templates/common/skills/zh-CN/refactoring.md +0 -384
  69. package/templates/common/skills/zh-CN/security-audit.md +0 -462
  70. package/templates/common/smart-guide/en/smart-guide.md +0 -72
  71. package/templates/common/smart-guide/zh-CN/smart-guide.md +0 -72
  72. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  73. package/templates/common/workflow/git/en/git-commit.md +0 -205
  74. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  75. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  76. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  77. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  78. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  79. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  80. package/templates/common/workflow/interview/en/interview.md +0 -212
  81. package/templates/common/workflow/interview/zh-CN/interview.md +0 -212
  82. package/templates/common/workflow/sixStep/en/workflow.md +0 -357
  83. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -357
  84. package/templates/industry/devops/en/ci-cd-pipeline.md +0 -410
  85. package/templates/industry/web-dev/en/api-design.md +0 -299
  86. package/templates/industry/web-dev/en/react-nextjs-setup.md +0 -236
@@ -1,205 +0,0 @@
1
- ---
2
- description: Analyze changes with Git only and auto-generate conventional commit messages with optional emoji; suggests splitting commits when needed, runs local Git hooks by default (use --no-verify to skip)
3
- allowed-tools: Read(**), Exec(git status, git diff, git add, git restore --staged, git commit, git rev-parse, git config), Write(.git/COMMIT_EDITMSG)
4
- argument-hint: [--no-verify] [--all] [--amend] [--signoff] [--emoji] [--scope <scope>] [--type <type>]
5
- # examples:
6
- # - /git-commit # Analyze current changes, generate commit message
7
- # - /git-commit --all # Stage all changes and commit
8
- # - /git-commit --no-verify # Skip Git hooks
9
- # - /git-commit --emoji # Include emoji in commit message
10
- # - /git-commit --scope ui --type feat # Specify scope and type
11
- # - /git-commit --amend --signoff # Amend last commit with signature
12
- ---
13
-
14
- # Claude Command: Commit (Git-only)
15
-
16
- This command works **without any package manager/build tools**, using only **Git** to:
17
-
18
- - Read changes (staged/unstaged)
19
- - Determine if changes should be **split into multiple commits**
20
- - Generate **Conventional Commits** style messages with optional emoji for each commit
21
- - Execute `git add` and `git commit` as needed (runs local Git hooks by default; use `--no-verify` to skip)
22
-
23
- ---
24
-
25
- ## Usage
26
-
27
- ```bash
28
- /git-commit
29
- /git-commit --no-verify
30
- /git-commit --emoji
31
- /git-commit --all --signoff
32
- /git-commit --amend
33
- /git-commit --scope ui --type feat --emoji
34
- ```
35
-
36
- ### Options
37
-
38
- - `--no-verify`: Skip local Git hooks (`pre-commit`/`commit-msg` etc.).
39
- - `--all`: When staging area is empty, automatically `git add -A` to include all changes in the commit.
40
- - `--amend`: **Amend** the last commit without creating a new one (preserves author and timestamp unless local Git config specifies otherwise).
41
- - `--signoff`: Add `Signed-off-by` line (use when following DCO process).
42
- - `--emoji`: Include emoji prefix in commit message (omit for plain text).
43
- - `--scope <scope>`: Specify commit scope (e.g., `ui`, `docs`, `api`), written to message header.
44
- - `--type <type>`: Force commit type (e.g., `feat`, `fix`, `docs`), overrides automatic detection.
45
-
46
- > Note: If the framework doesn't support interactive confirmation, enable `confirm: true` in front-matter to avoid mistakes.
47
-
48
- ---
49
-
50
- ## What This Command Does
51
-
52
- 1. **Repository/Branch Validation**
53
- - Check if in a Git repository using `git rev-parse --is-inside-work-tree`.
54
- - Read current branch/HEAD status; if in rebase/merge conflict state, prompt to resolve conflicts first.
55
-
56
- 2. **Change Detection**
57
- - Get staged and unstaged changes using `git status --porcelain` and `git diff`.
58
- - If staged files = 0:
59
- - If `--all` is passed → Execute `git add -A`.
60
- - Otherwise prompt choice: continue analyzing unstaged changes for **suggestions**, or cancel to manually group staging.
61
-
62
- 3. **Split Suggestions (Split Heuristics)**
63
- - Cluster by **concerns**, **file modes**, **change types** (e.g., source code vs docs/tests; different directories/packages; additions vs deletions).
64
- - If **multiple independent changesets** or large diff detected (e.g., > 300 lines / across multiple top-level directories), suggest splitting commits with pathspecs for each group (for subsequent `git add <paths>`).
65
-
66
- 4. **Commit Message Generation (Conventional with Optional Emoji)**
67
- - Auto-infer `type` (`feat`/`fix`/`docs`/`refactor`/`test`/`chore`/`perf`/`style`/`ci`/`revert`...) and optional `scope`.
68
- - Generate message header: `[<emoji>] <type>(<scope>)?: <subject>` (first line ≤ 72 chars, imperative mood, emoji included only with `--emoji` flag).
69
- - Generate message body:
70
- - Must have a blank line after the subject.
71
- - Use list format, each item starts with `-`.
72
- - Each item **must use imperative verb-first sentences** (e.g., "add…", "fix…", "update…").
73
- - **Colon-separated formats are prohibited** (e.g., ~~"Feature: description"~~, ~~"Impl: content"~~).
74
- - Describe the motivation, implementation details, or impact scope (3 items or fewer recommended).
75
- - Generate message footer (if any):
76
- - Must have a blank line after the Body.
77
- - **BREAKING CHANGE**: If there are breaking changes, must include `BREAKING CHANGE: <description>`, or add exclamation mark after type (e.g., `feat!:`).
78
- - Other footers use git trailer format (e.g., `Closes #123`, `Refs: #456`, `Reviewed-by: Name`).
79
- - Select message language to match the predominant language in Git history. Inspect recent commit subjects (e.g., `git log -n 50 --pretty=%s`) to decide Chinese vs English; if unclear, fall back to the repository's primary locale or English.
80
- - Write draft to `.git/COMMIT_EDITMSG` for use with `git commit`.
81
-
82
- 5. **Execute Commit**
83
- - Single commit scenario: `git commit [-S] [--no-verify] [-s] -F .git/COMMIT_EDITMSG`
84
- - Multiple commit scenario (if split accepted): Provide clear instructions for `git add <paths> && git commit ...` per group; execute sequentially if allowed.
85
-
86
- 6. **Safe Rollback**
87
- - If mistakenly staged, use `git restore --staged <paths>` to unstage (command provides instructions, doesn't modify file contents).
88
-
89
- ---
90
-
91
- ## Best Practices for Commits
92
-
93
- - **Atomic commits**: One commit does one thing, easier to trace and review.
94
- - **Group before committing**: Split by directory/module/feature.
95
- - **Clear subject**: First line ≤ 72 chars, imperative mood.
96
- - **Body with context**: Explain motivation, solution, and impact scope (colon-separated formats prohibited).
97
- - **Follow Conventional Commits**: `<type>(<scope>): <subject>`.
98
-
99
- ---
100
-
101
- ## Type to Emoji Mapping (When --emoji is Used)
102
-
103
- - ✨ `feat`: New feature
104
- - 🐛 `fix`: Bug fix (includes 🔥 remove code/files, 🚑️ hotfix, 👽️ adapt to external API changes, 🔒️ security fix, 🚨 fix warnings, 💚 fix CI)
105
- - 📝 `docs`: Documentation and comments
106
- - 🎨 `style`: Code style/formatting (no semantic changes)
107
- - ♻️ `refactor`: Refactoring (no new features, no bug fixes)
108
- - ⚡️ `perf`: Performance improvements
109
- - ✅ `test`: Add/fix tests, snapshots
110
- - 🔧 `chore`: Build/tools/misc tasks (merge branches, update configs, release tags, pin dependencies, .gitignore, etc.)
111
- - 👷 `ci`: CI/CD configuration and scripts
112
- - ⏪️ `revert`: Revert commits
113
- - 💥 `feat`: Breaking changes (explained in `BREAKING CHANGE:` section)
114
-
115
- > If `--type`/`--scope` is passed, it will **override** auto-detection.
116
- > Emoji is only included when `--emoji` flag is specified.
117
-
118
- ---
119
-
120
- ## Guidelines for Splitting Commits
121
-
122
- 1. **Different concerns**: Unrelated feature/module changes should be split.
123
- 2. **Different types**: Don't mix `feat`, `fix`, `refactor` in the same commit.
124
- 3. **File modes**: Source code vs docs/tests/configs should be grouped separately.
125
- 4. **Size threshold**: Large diffs (e.g., >300 lines or across multiple top-level directories) should be split.
126
- 5. **Revertability**: Ensure each commit can be independently reverted.
127
-
128
- ---
129
-
130
- ## Examples
131
-
132
- **Good (with --emoji)**
133
-
134
- ```text
135
- - ✨ feat(ui): add user authentication flow
136
- - 🐛 fix(api): handle token refresh race condition
137
- - 📝 docs: update API usage examples
138
- - ♻️ refactor(core): extract retry logic into helper
139
- - ✅ test: add unit tests for rate limiter
140
- - 🔧 chore: update git hooks and repository settings
141
- - ⏪️ revert: revert "feat(core): introduce streaming API"
142
- ```
143
-
144
- **Good (without --emoji)**
145
-
146
- ```text
147
- - feat(ui): add user authentication flow
148
- - fix(api): handle token refresh race condition
149
- - docs: update API usage examples
150
- - refactor(core): extract retry logic into helper
151
- - test: add unit tests for rate limiter
152
- - chore: update git hooks and repository settings
153
- - revert: revert "feat(core): introduce streaming API"
154
- ```
155
-
156
- **Good (with Body)**
157
-
158
- ```text
159
- feat(auth): add OAuth2 login flow
160
-
161
- - implement Google and GitHub third-party login
162
- - add user authorization callback handling
163
- - improve login state persistence logic
164
-
165
- Closes #42
166
- ```
167
-
168
- ```text
169
- fix(ui): fix button spacing on mobile devices
170
-
171
- - adjust button padding to fit small screens
172
- - fix styling issues on iOS Safari
173
- - optimize touch target size
174
- ```
175
-
176
- **Good (with BREAKING CHANGE)**
177
-
178
- ```text
179
- feat(api)!: redesign authentication API
180
-
181
- - migrate from session-based to JWT authentication
182
- - update all endpoint signatures
183
- - remove deprecated login methods
184
-
185
- BREAKING CHANGE: authentication API has been completely redesigned, all clients must update their integration
186
- ```
187
-
188
- **Split Example**
189
-
190
- ```text
191
- - `feat(types): add new type defs for payment method`
192
- - `docs: update API docs for new types`
193
- - `test: add unit tests for payment types`
194
- - `fix: address linter warnings in new files` ← (if your repo has hook errors)
195
- ```
196
-
197
- ---
198
-
199
- ## Important Notes
200
-
201
- - **Git only**: No package manager/build commands (`pnpm`/`npm`/`yarn` etc.).
202
- - **Respects hooks**: Executes local Git hooks by default; use `--no-verify` to skip.
203
- - **No source code changes**: Command only reads/writes `.git/COMMIT_EDITMSG` and staging area; doesn't directly edit working directory files.
204
- - **Safety prompts**: In rebase/merge conflicts, detached HEAD states, prompts to handle/confirm before continuing.
205
- - **Auditable and controllable**: If `confirm: true` is enabled, each actual `git add`/`git commit` step requires confirmation.
@@ -1,90 +0,0 @@
1
- ---
2
- description: Interactively rollback Git branch to historical version; lists branches, versions, then executes reset/revert after confirmation
3
- allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()
4
- argument-hint: [--branch <branch>] [--target <rev>] [--mode reset|revert] [--depth <n>] [--dry-run] [--yes]
5
- # examples:
6
- # - /git-rollback # Full interactive mode, dry-run
7
- # - /git-rollback --branch dev # Select dev directly, other interactive
8
- # - /git-rollback --branch dev --target v1.2.0 --mode reset --yes
9
- ---
10
-
11
- # Claude Command: Git Rollback
12
-
13
- **Purpose**: Safely and visually rollback a specified branch to an older version.
14
- Defaults to **read-only preview (`--dry-run`)**; actual execution requires `--yes` or interactive confirmation.
15
-
16
- ---
17
-
18
- ## Usage
19
-
20
- ```bash
21
- # Pure interactive: list branches → select branch → list recent 20 versions → select target → choose reset or revert → confirm
22
- /git-rollback
23
-
24
- # Specify branch, other interactive
25
- /git-rollback --branch feature/calculator
26
-
27
- # Specify branch and target commit, execute with hard-reset in one go (dangerous)
28
- /git-rollback --branch main --target 1a2b3c4d --mode reset --yes
29
-
30
- # Generate revert commit only (non-destructive rollback), preview
31
- /git-rollback --branch release/v2.1 --target v2.0.5 --mode revert --dry-run
32
- ```
33
-
34
- ### Options
35
-
36
- | Option | Description |
37
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------ |
38
- | `--branch <branch>` | Branch to rollback; interactively selected if omitted. |
39
- | `--target <rev>` | Target version (commit hash, tag, or reflog reference); interactively selects recent `--depth` entries if omitted. |
40
- | `--mode reset\|revert` | `reset`: Hard rollback history; `revert`: Generate reverse commits keeping history intact. Prompts by default. |
41
- | `--depth <n>` | List recent n versions in interactive mode (default 20). |
42
- | `--dry-run` | **Enabled by default**, only preview commands to be executed. |
43
- | `--yes` | Skip all confirmations and execute directly, suitable for CI/CD scripts. |
44
-
45
- ---
46
-
47
- ## Interactive Flow
48
-
49
- 1. **Sync remote** → `git fetch --all --prune`
50
- 2. **List branches** → `git branch -a` (local + remote, filter protected branches)
51
- 3. **Select branch** → User input or parameter
52
- 4. **List versions** → `git log --oneline -n <depth>` + `git tag --merged` + `git reflog -n <depth>`
53
- 5. **Select target** → User inputs commit hash / tag
54
- 6. **Select mode** → `reset` or `revert`
55
- 7. **Final confirmation** (unless `--yes`)
56
- 8. **Execute rollback**
57
- - `reset`: `git switch <branch> && git reset --hard <target>`
58
- - `revert`: `git switch <branch> && git revert --no-edit <target>..HEAD`
59
- 9. **Push suggestion** → Prompt whether to `git push --force-with-lease` (reset) or regular `git push` (revert)
60
-
61
- ---
62
-
63
- ## Safety Guards
64
-
65
- - **Backup**: Automatically records current HEAD in reflog before execution, recoverable with `git switch -c backup/<timestamp>`.
66
- - **Protected branches**: If protected branches like `main` / `master` / `production` are detected with `reset` mode enabled, requires additional confirmation.
67
- - **--dry-run enabled by default**: Prevents accidental operations.
68
- - **--force prohibited**: No `--force` provided; if force push needed, manually enter `git push --force-with-lease`.
69
-
70
- ---
71
-
72
- ## Use Case Examples
73
-
74
- | Scenario | Command Example |
75
- | --------------------------------------------------------------------------- | ---------------------------------------------------------------- |
76
- | Hotfix patch deployed with bug, need to rollback to tag `v1.2.0` | `/git-rollback --branch release/v1 --target v1.2.0 --mode reset` |
77
- | Ops colleague pushed debug logs by mistake, need to generate reverse commit | `/git-rollback --branch main --target 3f2e7c9 --mode revert` |
78
- | Research historical bugs, guide newcomers through branch history | `/git-rollback` (full interactive, dry-run) |
79
-
80
- ---
81
-
82
- ## Notes
83
-
84
- 1. **reset vs revert**
85
- - **reset** changes history, requires force push and may affect other collaborators, use with caution.
86
- - **revert** is safer, generates new commits preserving history, but adds one more record.
87
- 2. **Embedded repositories** often have large binary files; ensure LFS/submodule state consistency before rollback.
88
- 3. If repository has CI forced validation, rollback may trigger pipelines automatically; confirm control policies to avoid accidental deployment of old versions.
89
-
90
- ---
@@ -1,276 +0,0 @@
1
- ---
2
- description: Manage Git worktrees in project-level ../.ccjk/project-name/ directory with smart defaults, IDE integration and content migration
3
- allowed-tools: Read(**), Exec(git worktree add, git worktree list, git worktree remove, git worktree prune, git branch, git checkout, git rev-parse, git stash, git cp, detect-ide, open-ide, which, command, basename, dirname)
4
- argument-hint: <add|list|remove|prune|migrate> [path] [-b <branch>] [-o|--open] [--track] [--guess-remote] [--detach] [--checkout] [--lock] [--migrate-from <source-path>] [--migrate-stash]
5
- # examples:
6
- # - /git-worktree add feature-ui # create new branch 'feature-ui' from main/master
7
- # - /git-worktree add feature-ui -o # create worktree and open directly in IDE
8
- # - /git-worktree add hotfix -b fix/login -o # create new branch 'fix/login' with path 'hotfix'
9
- # - /git-worktree migrate feature-ui --from main # migrate uncommitted content from main to feature-ui
10
- # - /git-worktree migrate feature-ui --stash # migrate current stash to feature-ui
11
- ---
12
-
13
- # Claude Command: Git Worktree
14
-
15
- Manage Git worktrees with smart defaults, IDE integration and content migration in structured `../.ccjk/project-name/` paths.
16
-
17
- Execute commands directly and provide concise results.
18
-
19
- ---
20
-
21
- ## Usage
22
-
23
- ```bash
24
- # Basic operations
25
- /git-worktree add <path> # create new branch named <path> from main/master
26
- /git-worktree add <path> -b <branch> # create new branch with specified name
27
- /git-worktree add <path> -o # create and open directly in IDE
28
- /git-worktree list # show all worktree status
29
- /git-worktree remove <path> # remove specified worktree
30
- /git-worktree prune # clean invalid worktree references
31
-
32
- # Content migration
33
- /git-worktree migrate <target> --from <source> # migrate uncommitted content
34
- /git-worktree migrate <target> --stash # migrate stash content
35
- ```
36
-
37
- ### Options
38
-
39
- | Option | Description |
40
- | ------------------ | ------------------------------------------------------ |
41
- | `add [<path>]` | Add new worktree in `../.ccjk/project-name/<path>` |
42
- | `migrate <target>` | Migrate content to specified worktree |
43
- | `list` | List all worktrees and their status |
44
- | `remove <path>` | Remove worktree at specified path |
45
- | `prune` | Clean invalid worktree references |
46
- | `-b <branch>` | Create new branch and checkout to worktree |
47
- | `-o, --open` | Open directly in IDE after creation (skip prompt) |
48
- | `--from <source>` | Specify migration source path (migrate only) |
49
- | `--stash` | Migrate current stash content (migrate only) |
50
- | `--track` | Set new branch to track corresponding remote branch |
51
- | `--guess-remote` | Auto guess remote branch for tracking |
52
- | `--detach` | Create detached HEAD worktree |
53
- | `--checkout` | Checkout immediately after creation (default behavior) |
54
- | `--lock` | Lock worktree after creation |
55
-
56
- ---
57
-
58
- ## What This Command Does
59
-
60
- 1. **Environment Check**
61
- - Verify Git repository using `git rev-parse --is-inside-work-tree`
62
- - Detect whether in main repo or existing worktree for smart path calculation
63
-
64
- 2. **Smart Path Management**
65
- - Auto-calculate project name from main repository path using worktree detection
66
- - Create worktrees in structured `../.ccjk/project-name/<path>` directory
67
- - Handle both main repo and worktree execution contexts correctly
68
-
69
- ```bash
70
- # Core path calculation logic for worktree detection
71
- get_main_repo_path() {
72
- local git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
73
- local current_toplevel=$(git rev-parse --show-toplevel 2>/dev/null)
74
-
75
- # Check if in worktree
76
- if [[ "$git_common_dir" != "$current_toplevel/.git" ]]; then
77
- # In worktree, derive main repo path from git-common-dir
78
- dirname "$git_common_dir"
79
- else
80
- # In main repository
81
- echo "$current_toplevel"
82
- fi
83
- }
84
-
85
- MAIN_REPO_PATH=$(get_main_repo_path)
86
- PROJECT_NAME=$(basename "$MAIN_REPO_PATH")
87
- WORKTREE_BASE="$MAIN_REPO_PATH/../.ccjk/$PROJECT_NAME"
88
-
89
- # Always use absolute path to prevent nesting issues
90
- ABSOLUTE_WORKTREE_PATH="$WORKTREE_BASE/<path>"
91
- ```
92
-
93
- **Critical Fix**: Always use absolute paths when creating worktrees from within existing worktrees to prevent path nesting issues like `../.ccjk/project/.ccjk/project/path`.
94
-
95
- 3. **Worktree Operations**
96
- - **add**: Create new worktree with smart branch/path defaults
97
- - **list**: Display all worktrees with branches and status
98
- - **remove**: Safely remove worktree and clean references
99
- - **prune**: Clean orphaned worktree records
100
-
101
- 4. **Smart Defaults**
102
- - **Branch creation**: When no `-b` specified, create new branch using path name
103
- - **Base branch**: New branches created from main/master branch
104
- - **Path resolution**: Use branch name as path when unspecified
105
- - **IDE integration**: Auto-detect and prompt for IDE opening
106
-
107
- 5. **Content Migration**
108
- - Migrate uncommitted changes between worktrees
109
- - Apply stash content to target worktree
110
- - Safety checks to prevent conflicts
111
-
112
- 6. **Safety Features**
113
- - **Path conflict prevention**: Check for existing directories before creation
114
- - **Branch checkout validation**: Ensure branches aren't already in use
115
- - **Absolute path enforcement**: Prevent nested `.ccjk` directories when in worktree
116
- - **Auto-cleanup on removal**: Clean both directory and git references
117
- - **Clear status reporting**: Display worktree locations and branch status
118
-
119
- 7. **Environment File Handling**
120
- - **Auto-detection**: Scan `.gitignore` for environment variable file patterns
121
- - **Smart copying**: Copy `.env` and `.env.*` files that are listed in `.gitignore`
122
- - **Exclusion logic**: Skip `.env.example` and other template files
123
- - **Permission preservation**: Maintain original file permissions and timestamps
124
- - **User feedback**: Provide clear status on copied environment files
125
-
126
- ```bash
127
- # Environment file copying implementation
128
- copy_environment_files() {
129
- local main_repo="$MAIN_REPO_PATH"
130
- local target_worktree="$ABSOLUTE_WORKTREE_PATH"
131
- local gitignore_file="$main_repo/.gitignore"
132
-
133
- # Check if .gitignore exists
134
- if [[ ! -f "$gitignore_file" ]]; then
135
- return 0
136
- fi
137
-
138
- local copied_count=0
139
-
140
- # Detect .env file
141
- if [[ -f "$main_repo/.env" ]] && grep -q "^\.env$" "$gitignore_file"; then
142
- cp "$main_repo/.env" "$target_worktree/.env"
143
- echo "✅ Copied .env"
144
- ((copied_count++))
145
- fi
146
-
147
- # Detect .env.* pattern files (excluding .env.example)
148
- for env_file in "$main_repo"/.env.*; do
149
- if [[ -f "$env_file" ]] && [[ "$(basename "$env_file")" != ".env.example" ]]; then
150
- local filename=$(basename "$env_file")
151
- if grep -q "^\.env\.\*$" "$gitignore_file"; then
152
- cp "$env_file" "$target_worktree/$filename"
153
- echo "✅ Copied $filename"
154
- ((copied_count++))
155
- fi
156
- fi
157
- done
158
-
159
- if [[ $copied_count -gt 0 ]]; then
160
- echo "📋 Copied $copied_count environment file(s) from .gitignore"
161
- fi
162
- }
163
- ```
164
-
165
- ---
166
-
167
- ## Enhanced Features
168
-
169
- ### IDE Integration
170
-
171
- - **Auto-detection**: VS Code → Cursor → WebStorm → Sublime Text → Vim
172
- - **Smart prompting**: Ask to open in IDE after worktree creation
173
- - **Direct open**: Use `-o` flag to skip prompt and open immediately
174
- - **Custom configuration**: Configurable via git config
175
-
176
- ### Content Migration System
177
-
178
- ```bash
179
- # Migrate uncommitted changes
180
- /git-worktree migrate feature-ui --from main
181
- /git-worktree migrate hotfix --from ../other-worktree
182
-
183
- # Migrate stash content
184
- /git-worktree migrate feature-ui --stash
185
- ```
186
-
187
- **Migration Flow**:
188
-
189
- 1. Verify source has uncommitted content
190
- 2. Ensure target worktree is clean
191
- 3. Show changes to be migrated
192
- 4. Execute safe migration using git commands
193
- 5. Confirm results and suggest next steps
194
-
195
- ---
196
-
197
- ## Examples
198
-
199
- ```bash
200
- # Basic usage
201
- /git-worktree add feature-ui # create new branch 'feature-ui' from main/master
202
- /git-worktree add feature-ui -b my-feature # create new branch 'my-feature' with path 'feature-ui'
203
- /git-worktree add feature-ui -o # create and open in IDE directly
204
-
205
- # Content migration scenarios
206
- /git-worktree add feature-ui -b feature/new-ui # create new feature worktree
207
- /git-worktree migrate feature-ui --from main # migrate uncommitted changes
208
- /git-worktree migrate hotfix --stash # migrate stash content
209
-
210
- # Management operations
211
- /git-worktree list # view all worktrees
212
- /git-worktree remove feature-ui # remove unneeded worktree
213
- /git-worktree prune # clean invalid references
214
- ```
215
-
216
- **Example Output**:
217
-
218
- ```
219
- ✅ Worktree created at ../.ccjk/project-name/feature-ui
220
- ✅ Copied .env
221
- ✅ Copied .env.local
222
- 📋 Copied 2 environment file(s) from .gitignore
223
- 🖥️ Open ../.ccjk/project-name/feature-ui in IDE? [y/n]: y
224
- 🚀 Opening ../.ccjk/project-name/feature-ui in VS Code...
225
- ```
226
-
227
- ---
228
-
229
- ## Directory Structure
230
-
231
- ```
232
- parent-directory/
233
- ├── your-project/ # main project
234
- │ ├── .git/
235
- │ └── src/
236
- └── .ccjk/ # worktree management
237
- └── your-project/ # project worktrees
238
- ├── feature-ui/ # feature branch
239
- ├── hotfix/ # hotfix branch
240
- └── debug/ # debug worktree
241
- ```
242
-
243
- ---
244
-
245
- ## Configuration
246
-
247
- ### IDE Configuration
248
-
249
- - Supports VS Code, Cursor, WebStorm, Sublime Text, Vim
250
- - Configurable via git config for custom IDEs
251
- - Auto-detection with priority-based selection
252
-
253
- ### Custom IDE Setup
254
-
255
- ```bash
256
- # Configure custom IDE
257
- git config worktree.ide.custom.sublime "subl %s"
258
- git config worktree.ide.preferred "sublime"
259
-
260
- # Control auto-detection
261
- git config worktree.ide.autodetect true # default
262
- ```
263
-
264
- ---
265
-
266
- ## Notes
267
-
268
- - **Performance**: Worktrees share `.git` directory, saving disk space
269
- - **Safety**: Path conflict prevention and branch checkout validation
270
- - **Migration**: Only uncommitted changes; use `git cherry-pick` for commits
271
- - **IDE requirement**: Command-line tools must be in PATH
272
- - **Cross-platform**: Supports Windows, macOS, Linux
273
- - **Environment files**: Automatically copies environment files listed in `.gitignore` to new worktrees
274
- - **File exclusions**: Template files like `.env.example` are preserved in main repo only
275
-
276
- ---
@@ -1,102 +0,0 @@
1
- ---
2
- description: 安全查找并清理已合并或过期的 Git 分支,支持 dry-run 模式与自定义基准/保护分支
3
- allowed-tools: Read(**), Exec(git fetch, git config, git branch, git remote, git push, git for-each-ref, git log), Write()
4
- argument-hint: [--base <branch>] [--stale <days>] [--remote] [--force] [--dry-run] [--yes]
5
- # examples:
6
- # - /git-cleanBranches --dry-run
7
- # - /git-cleanBranches --base release/v2.1 --stale 90
8
- # - /git-cleanBranches --remote --yes
9
- ---
10
-
11
- # Claude Command: Clean Branches
12
-
13
- 该命令**安全地**识别并清理**已合并**或**长期未更新 (stale)** 的 Git 分支。
14
- 默认以**只读预览 (`--dry-run`)** 模式运行,需明确指令才会执行删除操作。
15
-
16
- ---
17
-
18
- ## Usage
19
-
20
- ```bash
21
- # [最安全] 预览将要清理的分支,不执行任何删除
22
- /git-cleanBranches --dry-run
23
-
24
- # 清理已合并到 main 且超过 90 天未动的本地分支 (需逐一确认)
25
- /git-cleanBranches --stale 90
26
-
27
- # 清理已合并到 release/v2.1 的本地与远程分支 (自动确认)
28
- /git-cleanBranches --base release/v2.1 --remote --yes
29
-
30
- # [危险] 强制删除一个未合并的本地分支
31
- /git-cleanBranches --force outdated-feature
32
- ```
33
-
34
- ### Options
35
-
36
- - `--base <branch>`:指定清理的基准分支(默认为仓库的 `main`/`master`)。
37
- - `--stale <days>`:清理超过指定天数未提交的分支(默认不启用)。
38
- - `--remote`:同时清理远程已合并/过期的分支。
39
- - `--dry-run`:**默认行为**。仅列出将要删除的分支,不执行任何操作。
40
- - `--yes`:跳过逐一确认的步骤,直接删除所有已识别的分支(适合 CI/CD)。
41
- - `--force`:使用 `-D` 强制删除本地分支(即使未合并)。
42
-
43
- ---
44
-
45
- ## What This Command Does
46
-
47
- 1. **配置与安全预检**
48
- - **更新信息**:自动执行 `git fetch --all --prune`,确保分支状态最新。
49
- - **读取保护分支**:从 Git 配置读取不应被清理的分支列表(见下文“Configuration”)。
50
- - **确定基准**:使用 `--base` 参数或自动识别的 `main`/`master` 作为比较基准。
51
-
52
- 2. **分析识别(Find)**
53
- - **已合并分支**:找出已完全合并到 `--base` 的本地(及远程,如加 `--remote`)分支。
54
- - **过期分支**:如指定 `--stale <days>`,找出最后一次提交在 N 天前的分支。
55
- - **排除保护分支**:从待清理列表中移除所有已配置的保护分支。
56
-
57
- 3. **报告预览(Report)**
58
- - 清晰列出“将要删除的已合并分支”与“将要删除的过期分支”。
59
- - 若无 `--yes` 参数,**命令到此结束**,等待用户确认后再次执行(不带 `--dry-run`)。
60
-
61
- 4. **执行清理(Execute)**
62
- - **仅在不带 `--dry-run` 且用户确认后**(或带 `--yes`)执行。
63
- - 逐一删除已识别的分支,除非用户在交互式确认中选择跳过。
64
- - 本地用 `git branch -d <branch>`;远程用 `git push origin --delete <branch>`。
65
- - 若指定 `--force`,本地删除会改用 `git branch -D <branch>`。
66
-
67
- ---
68
-
69
- ## Configuration (一次配置,永久生效)
70
-
71
- 为防止误删重要分支(如 `develop`, `release/*`),请在仓库的 Git 配置中添加保护规则。命令会自动读取。
72
-
73
- ```bash
74
- # 保护 develop 分支
75
- git config --add branch.cleanup.protected develop
76
-
77
- # 保护所有 release/ 开头的分支 (通配符)
78
- git config --add branch.cleanup.protected 'release/*'
79
-
80
- # 查看所有已配置的保护分支
81
- git config --get-all branch.cleanup.protected
82
- ```
83
-
84
- ---
85
-
86
- ## Best Practices for Embedded Devs
87
-
88
- - **优先 `--dry-run`**:养成先预览再执行的习惯。
89
- - **活用 `--base`**:维护长期 `release` 分支时,用它来清理已合并到该 release 的 `feature` 或 `hotfix` 分支。
90
- - **谨慎 `--force`**:除非你百分百确定某个未合并分支是无用功,否则不要强制删除。
91
- - **团队协作**:在清理共享的远程分支前,先在团队频道通知一声。
92
- - **定期运行**:每月或每季度运行一次,保持仓库清爽。
93
-
94
- ---
95
-
96
- ## Why This Version Is Better
97
-
98
- - ✅ **更安全**:默认只读预览,且有可配置的保护分支列表。
99
- - ✅ **更灵活**:支持自定义基准分支,完美适配 `release` / `develop` 工作流。
100
- - ✅ **更兼容**:避免了在不同系统上行为不一的 `date -d` 等命令。
101
- - ✅ **更直观**:将复杂的 16 步清单,浓缩成一个带安全选项的、可直接执行的命令。
102
- - ✅ **风格一致**:与 `/commit` 命令共享相似的参数设计与文档结构。