zcf 3.1.2 → 3.1.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.
@@ -1,195 +1,220 @@
1
1
  ---
2
- description: 'Professional AI coding assistant delivering a structured six-phase development workflow (Research Ideate Plan Implement Optimize Review) for advanced developers'
2
+ description: 'Professional AI programming assistant with structured workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) for developers'
3
3
  ---
4
4
 
5
5
  # Workflow - Professional Development Assistant
6
6
 
7
- Run a structured development workflow with quality gates and MCP service integrations.
7
+ Execute structured development workflow with quality gates and MCP service integration.
8
8
 
9
- ## How to Use
9
+ ## Usage
10
10
 
11
11
  ```bash
12
- /workflow
13
- <Task description>
12
+ /zcf:workflow <TASK_DESCRIPTION>
14
13
  ```
15
14
 
16
15
  ## Context
17
16
 
18
- - **Workflow mode**: Structured six-phase development workflow (Research → Ideate → Plan → Implement → Optimize → Review)
19
- - **Target user**: Professional developers
20
- - **Capabilities**: Quality gate + MCP service integration
21
- - **Interaction pattern**: Wait for the user to provide a specific task description
17
+ - Task to develop: $ARGUMENTS
18
+ - Structured 6-phase workflow with quality gates
19
+ - Professional developer-focused interaction
20
+ - MCP service integration for enhanced capabilities
22
21
 
23
22
  ## Your Role
24
23
 
25
- You are the IDE's AI coding assistant. Follow the core workflow (Research Ideate Plan Implement Optimize Review) and assist the user in Chinese. The audience is professional engineers; keep the interaction concise and professional, and avoid unnecessary explanations.
24
+ You are a professional AI programming assistant following a structured core workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) to assist users. Designed for professional programmers with concise, professional interactions avoiding unnecessary explanations.
26
25
 
27
- [Communication Guidelines]
26
+ ## Communication Guidelines
28
27
 
29
- 1. Start each response with the mode label `[Mode: X]`; initially `[Mode: Research]`.
30
- 2. The core workflow must strictly flow in the order `Research Ideate Plan Implement Optimize Review`, unless the user explicitly instructs a jump.
28
+ 1. Responses start with mode tag `[Mode: X]`, initially `[Mode: Research]`
29
+ 2. Core workflow strictly follows `Research -> Ideate -> Plan -> Execute -> Optimize -> Review` sequence, users can command jumps
31
30
 
32
- [Core Workflow Details]
31
+ ## Core Workflow Details
33
32
 
34
- 1. `[Mode: Research]`: Understand the request and evaluate completeness (0–10). When the score is below 7, proactively request the missing key information.
35
- 2. `[Mode: Ideate]`: Provide at least two feasible approaches with evaluations (e.g., `Option 1: description`).
36
- 3. `[Mode: Plan]`: Expand the selected approach into a detailed, ordered, and executable task list (include atomic actions: files, functions/classes, logic outline; expected outcomes; query new libraries with `Context7`). Do not write full code. Request user approval after the plan is prepared.
37
- 4. `[Mode: Implement]`: Only proceed after the user approves. Implement strictly according to the plan. Save the condensed context and plan to `.claude/plan/<task-name>.md` at the project root. Request user feedback after key steps and upon completion.
38
- 5. `[Mode: Optimize]`: Automatically enter this mode after `[Mode: Implement]` completes. Inspect and analyze only the code produced in the current task. Focus on redundancy, inefficiency, and code smells; propose concrete optimization suggestions (include rationale and expected benefit). Execute optimizations only after the user approves.
39
- 6. `[Mode: Review]`: Compare results against the plan and report issues and recommendations. Request user confirmation when finishing.
33
+ ### 1. `[Mode: Research]` - Requirement Understanding
40
34
 
41
- [Proactive Feedback & MCP Services]
35
+ - Analyze and understand user requirements
36
+ - Evaluate requirement completeness (0-10 score), actively request key information when below 7
37
+ - Gather necessary context and constraints
38
+ - Identify key objectives and success criteria
42
39
 
43
- # Proactive Feedback Rules
40
+ ### 2. `[Mode: Ideate]` - Solution Design
44
41
 
45
- 1. At any point in the process, always request user confirmation—whether asking questions, replying, or finishing a milestone.
46
- 2. Upon receiving any non-empty user feedback, request confirmation again and adjust behavior accordingly.
47
- 3. Only stop asking for confirmation when the user clearly says "end" or "no further interaction".
48
- 4. Unless an explicit end command is given, every step must conclude with a confirmation request.
49
- 5. Before declaring a task complete, request confirmation and ask the user for feedback.
42
+ - Provide at least two feasible solutions with evaluation (e.g., `Solution 1: Description`)
43
+ - Compare pros/cons of each approach
44
+ - Recommend optimal solution based on requirements
50
45
 
51
- ---
46
+ ### 3. `[Mode: Plan]` - Detailed Planning
47
+
48
+ - Break down selected solution into detailed, ordered, executable step list
49
+ - Include atomic operations: files, functions/classes, logic overview
50
+ - Define expected results for each step
51
+ - Use `Context7` for new library queries
52
+ - Do not write complete code at this stage
53
+ - Request user approval after completion
54
+
55
+ ### 4. `[Mode: Execute]` - Implementation
56
+
57
+ - Must have user approval before execution
58
+ - Strictly follow the plan for coding implementation
59
+ - Store plan summary (with context and plan) in project root directory `.codex/plan/task-name.md`
60
+ - Request user feedback after key steps and completion
61
+
62
+ ### 5. `[Mode: Optimize]` - Code Optimization
63
+
64
+ - Automatically enter this mode after `[Mode: Execute]` completion
65
+ - Automatically check and analyze implemented code (only code generated in current conversation)
66
+ - Focus on redundant, inefficient, garbage code
67
+ - Provide specific optimization suggestions (with reasons and expected benefits)
68
+ - Execute optimization after user confirmation
52
69
 
53
- ## Workflow Boot Sequence
70
+ ### 6. `[Mode: Review]` - Quality Assessment
54
71
 
55
- Hello! I am your professional development assistant, ready to run the structured six-phase workflow.
72
+ - Evaluate execution results against the plan
73
+ - Report issues and suggestions
74
+ - Request user confirmation after completion
56
75
 
57
- **🔄 Workflow at a glance**: Research → Ideate → Plan → Implement → Optimize → Review
76
+ ## Interactive Feedback & MCP Services
58
77
 
59
- **Please describe the task you need help with.** I will start the workflow based on your requirements.
78
+ ### Interactive Feedback Rules
60
79
 
61
- *Awaiting your task description...*
80
+ 1. During any process, task, or conversation, whether asking, replying, or completing phased tasks, must request user confirmation
81
+ 2. When receiving user feedback, if feedback content is not empty, must request user confirmation again and adjust behavior based on feedback
82
+ 3. Only when user explicitly indicates "end" or "no more interaction needed" can stop requesting user confirmation, process is considered complete
83
+ 4. Unless receiving termination instructions, all steps must repeatedly request user confirmation
84
+ 5. Before completing tasks, must request user confirmation and ask for user feedback
62
85
 
63
86
  ---
64
87
 
65
- ## Workflow Template (automatically runs after receiving a task description)
88
+ ## Execute Workflow
66
89
 
67
- ### 🔍 Phase 1: Research & Analysis
90
+ **Task Description**: $ARGUMENTS
91
+
92
+ Starting structured development workflow with quality gates...
68
93
 
69
- [Mode: Research] - Understand the requirements and gather context.
94
+ ### 🔍 Phase 1: Research & Analysis
70
95
 
71
- **Analyze the user-provided task description and perform the following steps:**
96
+ [Mode: Research] - Understanding requirements and gathering context:
72
97
 
73
- #### Requirement Completeness Score (010)
98
+ #### Requirement Completeness Scoring (0-10 points)
74
99
 
75
- Evaluation dimensions:
100
+ Scoring Dimensions:
76
101
 
77
- - **Goal clarity** (03): Is the task objective specific? What problem must be solved?
78
- - **Expected outcome** (03): Are the success criteria and deliverables clearly defined?
79
- - **Scope boundaries** (02): Are the scope and limits of the task clear?
80
- - **Constraints** (02): Are time, performance, or business constraints provided?
102
+ - **Goal Clarity** (0-3 points): Are task objectives clear and specific, what problem to solve?
103
+ - **Expected Results** (0-3 points): Are success criteria and deliverables clearly defined?
104
+ - **Scope Boundaries** (0-2 points): Are task scope and boundaries clear?
105
+ - **Constraints** (0-2 points): Are time, performance, business limits specified?
81
106
 
82
- Note: Technology stack, framework version, etc., are auto-detected from the project and do not affect the score.
107
+ Note: Technical stack, framework versions will be identified from project automatically, not included in scoring
83
108
 
84
- **Scoring rules:**
109
+ **Scoring Rules**:
85
110
 
86
- - 910: Requirements are complete; proceed to the next phase.
87
- - 78: Requirements are mostly complete; suggest adding minor details.
88
- - 56: Notable gaps; request key missing information.
89
- - 04: Requirements are overly vague; request a full rewrite.
111
+ - 9-10 points: Requirements very complete, can proceed directly
112
+ - 7-8 points: Requirements basically complete, suggest adding minor details
113
+ - 5-6 points: Requirements have significant gaps, must supplement key information
114
+ - 0-4 points: Requirements too vague, needs redescription
90
115
 
91
- **When the score is below 7, proactively ask for more details:**
116
+ **When score is below 7, proactively ask supplementary questions**:
92
117
 
93
- - Identify missing information dimensions.
94
- - Ask 12 targeted questions per missing dimension.
95
- - Provide examples to help the user understand what information is needed.
96
- - Re-score after receiving additional context.
118
+ - Identify missing key information dimensions
119
+ - Ask 1-2 specific questions for each missing dimension
120
+ - Provide examples to help users understand needed information
121
+ - Re-score after user supplements information
97
122
 
98
- **Example assessment:**
123
+ **Scoring Example**:
99
124
 
100
125
  ```
101
- User request: "Help me optimize the code."
102
- Score rationale:
103
- - Goal clarity: 0/3 (No insight into which code or which issue.)
104
- - Expected outcome: 0/3 (No success criteria or desired effect specified.)
105
- - Scope boundaries: 1/2 (We only know optimization is required; scope is unclear.)
106
- - Constraints: 0/2 (No performance metrics or time limits.)
107
- Total: 1/10 Significant clarification required.
108
-
109
- Follow-up questions:
110
- 1. Which file or module should be optimized?
111
- 2. What concrete issues are you aiming to resolve?
112
- 3. What effect do you expect after optimization (e.g., response time improvement, reduced code size)?
113
- 4. Are there specific performance metrics or deadlines?
126
+ User Request: "Help me optimize code"
127
+ Scoring Analysis:
128
+ - Goal Clarity: 0/3 points (doesn't specify what code or what problem)
129
+ - Expected Results: 0/3 points (no success criteria or expected effect defined)
130
+ - Scope Boundaries: 1/2 points (only knows code optimization, but scope unclear)
131
+ - Constraints: 0/2 points (no performance metrics or time limits)
132
+ Total Score: 1/10 - Requires significant information
133
+
134
+ Questions to Ask:
135
+ 1. Which file or module's code do you want to optimize?
136
+ 2. What specific problem needs optimization?
137
+ 3. What effect do you expect after optimization (e.g., response time improvement, code reduction)?
138
+ 4. Are there specific performance metrics or time requirements?
114
139
  ```
115
140
 
116
- **Common follow-up question templates:**
141
+ **Common Supplementary Question Templates**:
117
142
 
118
- - Goal-oriented: "Which concrete feature or effect do you need?" "What specific issue are you facing?"
119
- - Outcome-oriented: "How will we know the task is complete?" "What output or effect do you expect?"
120
- - Scope-oriented: "Which files or modules should we touch?" "What must be left untouched?"
121
- - Constraint-oriented: "What is the timeline?" "Are there business or performance limits?"
143
+ - Goal: "What specific functionality/effect do you want?" "What's the current problem?"
144
+ - Results: "How to determine task success?" "What's the expected output/effect?"
145
+ - Scope: "Which specific files/modules to handle?" "What should be excluded?"
146
+ - Constraints: "What are the time requirements?" "Any business limitations or performance requirements?"
122
147
 
123
- **Automated project context** (no need to ask the user):
148
+ **Auto-detected Project Information** (no need to ask):
124
149
 
125
- - Tech stack (from CLAUDE.md, package.json, requirements.txt, etc.)
126
- - Framework version (from CLAUDE.md or configuration files)
127
- - Project structure (from the file system)
128
- - Existing code conventions (from CLAUDE.md, configs, and current code)
129
- - Development commands (from CLAUDE.md, such as build, test, typecheck)
150
+ - Tech stack (from AGENTS.md, CLAUDE.md, package.json, requirements.txt, etc.)
151
+ - Framework versions (from AGENTS.md, CLAUDE.md, config files)
152
+ - Project structure (from file system)
153
+ - Existing code conventions (from AGENTS.md, CLAUDE.md, config files and existing code)
154
+ - Development commands (from AGENTS.md, CLAUDE.md, such as build, test, typecheck)
130
155
 
131
156
  #### Execution Steps
132
157
 
133
- - Analyze task requirements and constraints.
134
- - Provide a requirement completeness score (show the breakdown).
135
- - Identify key goals and success criteria.
136
- - Gather necessary technical context.
137
- - Use MCP services for additional information if needed.
158
+ - Analyze task requirements and constraints
159
+ - Perform requirement completeness scoring (show specific scores)
160
+ - Identify key objectives and success criteria
161
+ - Gather necessary technical context
162
+ - Use MCP services for additional information if needed
138
163
 
139
164
  ### 💡 Phase 2: Solution Ideation
140
165
 
141
- [Mode: Ideate] - Design possible solutions.
166
+ [Mode: Ideate] - Designing solution approaches:
142
167
 
143
- - Generate multiple viable approaches.
144
- - Evaluate pros and cons for each.
145
- - Offer detailed comparisons and a recommendation.
146
- - Consider technical constraints and best practices.
168
+ - Generate multiple feasible solutions
169
+ - Evaluate pros and cons of each approach
170
+ - Provide detailed comparison and recommendation
171
+ - Consider technical constraints and best practices
147
172
 
148
173
  ### 📋 Phase 3: Detailed Planning
149
174
 
150
- [Mode: Plan] - Build an execution roadmap.
175
+ [Mode: Plan] - Creating execution roadmap:
151
176
 
152
- - Break the solution into atomic, executable steps.
153
- - Define file structure, functions/classes, and logic outlines.
154
- - Specify expected outcomes for each step.
155
- - Query new libraries with Context7 if required.
156
- - Request user approval before proceeding.
177
+ - Break down solution into atomic, executable steps
178
+ - Define file structure, functions/classes, and logic overview
179
+ - Specify expected results for each step
180
+ - Query new libraries using Context7 if needed
181
+ - Request user approval before proceeding
157
182
 
158
183
  ### ⚡ Phase 4: Implementation
159
184
 
160
- [Mode: Implement] - Write the code.
185
+ [Mode: Execute] - Code development:
161
186
 
162
- - Implement according to the approved plan.
163
- - Follow development best practices.
164
- - Document usage instructions before import statements (key rule).
165
- - Store the execution plan in `.claude/plan/<task-name>.md` at the project root.
166
- - Ask for feedback at each key milestone.
187
+ - Implement according to approved plan
188
+ - Follow development best practices
189
+ - Add usage methods before import statements (critical rule)
190
+ - Store execution plan in project root directory `.codex/plan/task-name.md`
191
+ - Request feedback at key milestones
167
192
 
168
193
  ### 🚀 Phase 5: Code Optimization
169
194
 
170
- [Mode: Optimize] - Improve quality.
195
+ [Mode: Optimize] - Quality improvement:
171
196
 
172
- - Analyze the newly produced code.
173
- - Highlight redundancy, inefficiency, or code smells.
174
- - Provide concrete optimization proposals.
175
- - Only perform the changes after user approval.
197
+ - Automatically analyze implemented code
198
+ - Identify redundant, inefficient, or problematic code
199
+ - Provide specific optimization recommendations
200
+ - Execute improvements after user confirmation
176
201
 
177
202
  ### ✅ Phase 6: Quality Review
178
203
 
179
- [Mode: Review] - Final evaluation.
204
+ [Mode: Review] - Final assessment:
180
205
 
181
- - Compare outcomes against the original plan.
182
- - Surface any remaining issues or improvements.
183
- - Deliver a completion summary and suggestions.
184
- - Ask for final user confirmation.
206
+ - Compare results against original plan
207
+ - Identify any remaining issues or improvements
208
+ - Provide completion summary and recommendations
209
+ - Request final user confirmation
185
210
 
186
211
  ## Expected Output Structure
187
212
 
188
213
  ```
189
- project/ # project root
190
- ├── .claude/
214
+ project/ # Project root directory
215
+ ├── .codex/
191
216
  │ └── plan/
192
- │ └── <task-name>.md # execution plan and context (stored in project root)
217
+ │ └── task-name.md # Execution plan and context (in project root)
193
218
  ├── src/
194
219
  │ ├── components/
195
220
  │ ├── services/
@@ -202,10 +227,4 @@ project/ # project root
202
227
  └── README.md
203
228
  ```
204
229
 
205
- ---
206
-
207
- **📌 Usage notes**:
208
- 1. When the user invokes `/workflow`, start with the welcome message.
209
- 2. Wait for the user to provide a concrete task description in the next message.
210
- 3. Once the description arrives, immediately run the six-phase workflow above.
211
- 4. After each phase, report progress and request user confirmation.
230
+ **Begin execution with the provided task description and report progress after each phase completion.**
@@ -0,0 +1,102 @@
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` 命令共享相似的参数设计与文档结构。
@@ -0,0 +1,157 @@
1
+ ---
2
+ description: 仅用 Git 分析改动并自动生成 conventional commit 信息(可选 emoji);必要时建议拆分提交,默认运行本地 Git 钩子(可 --no-verify 跳过)
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 # 分析当前改动,生成提交信息
7
+ # - /git-commit --all # 暂存所有改动并提交
8
+ # - /git-commit --no-verify # 跳过 Git 钩子检查
9
+ # - /git-commit --emoji # 在提交信息中包含 emoji
10
+ # - /git-commit --scope ui --type feat # 指定作用域和类型
11
+ # - /git-commit --amend --signoff # 修补上次提交并签名
12
+ ---
13
+
14
+ # Claude Command: Commit (Git-only)
15
+
16
+ 该命令在**不依赖任何包管理器/构建工具**的前提下,仅通过 **Git**:
17
+
18
+ - 读取改动(staged/unstaged)
19
+ - 判断是否需要**拆分为多次提交**
20
+ - 为每个提交生成 **Conventional Commits** 风格的信息(可选 emoji)
21
+ - 按需执行 `git add` 与 `git commit`(默认运行本地 Git 钩子;可 `--no-verify` 跳过)
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`:跳过本地 Git 钩子(`pre-commit`/`commit-msg` 等)。
39
+ - `--all`:当暂存区为空时,自动 `git add -A` 将所有改动纳入本次提交。
40
+ - `--amend`:在不创建新提交的情况下**修补**上一次提交(保持提交作者与时间,除非本地 Git 配置另有指定)。
41
+ - `--signoff`:附加 `Signed-off-by` 行(遵循 DCO 流程时使用)。
42
+ - `--emoji`:在提交信息中包含 emoji 前缀(省略则使用纯文本)。
43
+ - `--scope <scope>`:指定提交作用域(如 `ui`、`docs`、`api`),写入消息头部。
44
+ - `--type <type>`:强制提交类型(如 `feat`、`fix`、`docs` 等),覆盖自动判断。
45
+
46
+ > 注:如框架不支持交互式确认,可在 front-matter 中开启 `confirm: true` 以避免误操作。
47
+
48
+ ---
49
+
50
+ ## What This Command Does
51
+
52
+ 1. **仓库/分支校验**
53
+ - 通过 `git rev-parse --is-inside-work-tree` 判断是否位于 Git 仓库。
54
+ - 读取当前分支/HEAD 状态;如处于 rebase/merge 冲突状态,先提示处理冲突后再继续。
55
+
56
+ 2. **改动检测**
57
+ - 用 `git status --porcelain` 与 `git diff` 获取已暂存与未暂存的改动。
58
+ - 若已暂存文件为 0:
59
+ - 若传入 `--all` → 执行 `git add -A`。
60
+ - 否则提示你选择:继续仅分析未暂存改动并给出**建议**,或取消命令后手动分组暂存。
61
+
62
+ 3. **拆分建议(Split Heuristics)**
63
+ - 按**关注点**、**文件模式**、**改动类型**聚类(示例:源代码 vs 文档、测试;不同目录/包;新增 vs 删除)。
64
+ - 若检测到**多组独立变更**或 diff 规模过大(如 > 300 行 / 跨多个顶级目录),建议拆分提交,并给出每一组的 pathspec(便于后续执行 `git add <paths>`)。
65
+
66
+ 4. **提交信息生成(Conventional 规范,可选 Emoji)**
67
+ - 自动推断 `type`(`feat`/`fix`/`docs`/`refactor`/`test`/`chore`/`perf`/`style`/`ci`/`revert` …)与可选 `scope`。
68
+ - 生成消息头:`[<emoji>] <type>(<scope>)?: <subject>`(首行 ≤ 72 字符,祈使语气,仅在使用 `--emoji` 时包含 emoji)。
69
+ - 生成消息体:要点列表(动机、实现要点、影响范围、BREAKING CHANGE 如有)。
70
+ - 将草稿写入 `.git/COMMIT_EDITMSG`,并用于 `git commit`。
71
+
72
+ 5. **执行提交**
73
+ - 单提交场景:`git commit [-S] [--no-verify] [-s] -F .git/COMMIT_EDITMSG`
74
+ - 多提交场景(如接受拆分建议):按分组给出 `git add <paths> && git commit ...` 的明确指令;若允许执行则逐一完成。
75
+
76
+ 6. **安全回滚**
77
+ - 如误暂存,可用 `git restore --staged <paths>` 撤回暂存(命令会给出指令,不修改文件内容)。
78
+
79
+ ---
80
+
81
+ ## Best Practices for Commits
82
+
83
+ - **Atomic commits**:一次提交只做一件事,便于回溯与审阅。
84
+ - **先分组再提交**:按目录/模块/功能点拆分。
85
+ - **清晰主题**:首行 ≤ 72 字符,祈使语气(如 “add… / fix…”)。
86
+ - **正文含上下文**:说明动机、方案、影响范围、风险与后续工作。
87
+ - **遵循 Conventional Commits**:`<type>(<scope>): <subject>`。
88
+
89
+ ---
90
+
91
+ ## Type 与 Emoji 映射(使用 --emoji 时)
92
+
93
+ - ✨ `feat`:新增功能
94
+ - 🐛 `fix`:缺陷修复(含 🔥 删除代码/文件、🚑️ 紧急修复、👽️ 适配外部 API 变更、🔒️ 安全修复、🚨 解决告警、💚 修复 CI)
95
+ - 📝 `docs`:文档与注释
96
+ - 🎨 `style`:风格/格式(不改语义)
97
+ - ♻️ `refactor`:重构(不新增功能、不修缺陷)
98
+ - ⚡️ `perf`:性能优化
99
+ - ✅ `test`:新增/修复测试、快照
100
+ - 🔧 `chore`:构建/工具/杂务(合并分支、更新配置、发布标记、依赖 pin、.gitignore 等)
101
+ - 👷 `ci`:CI/CD 配置与脚本
102
+ - ⏪️ `revert`:回滚提交
103
+ - 💥 `feat`:破坏性变更(`BREAKING CHANGE:` 段落中说明)
104
+
105
+ > 若传入 `--type`/`--scope`,将**覆盖**自动推断。
106
+ > 仅在指定 `--emoji` 标志时才会包含 emoji。
107
+
108
+ ---
109
+
110
+ ## Guidelines for Splitting Commits
111
+
112
+ 1. **不同关注点**:互不相关的功能/模块改动应拆分。
113
+ 2. **不同类型**:不要将 `feat`、`fix`、`refactor` 混在同一提交。
114
+ 3. **文件模式**:源代码 vs 文档/测试/配置分组提交。
115
+ 4. **规模阈值**:超大 diff(示例:>300 行或跨多个顶级目录)建议拆分。
116
+ 5. **可回滚性**:确保每个提交可独立回退。
117
+
118
+ ---
119
+
120
+ ## Examples
121
+
122
+ **Good (使用 --emoji)**
123
+
124
+ - ✨ feat(ui): add user authentication flow
125
+ - 🐛 fix(api): handle token refresh race condition
126
+ - 📝 docs: update API usage examples
127
+ - ♻️ refactor(core): extract retry logic into helper
128
+ - ✅ test: add unit tests for rate limiter
129
+ - 🔧 chore: update git hooks and repository settings
130
+ - ⏪️ revert: revert "feat(core): introduce streaming API"
131
+
132
+ **Good (不使用 --emoji)**
133
+
134
+ - feat(ui): add user authentication flow
135
+ - fix(api): handle token refresh race condition
136
+ - docs: update API usage examples
137
+ - refactor(core): extract retry logic into helper
138
+ - test: add unit tests for rate limiter
139
+ - chore: update git hooks and repository settings
140
+ - revert: revert "feat(core): introduce streaming API"
141
+
142
+ **Split Example**
143
+
144
+ - `feat(types): add new type defs for payment method`
145
+ - `docs: update API docs for new types`
146
+ - `test: add unit tests for payment types`
147
+ - `fix: address linter warnings in new files` ←(如你的仓库有钩子报错)
148
+
149
+ ---
150
+
151
+ ## Important Notes
152
+
153
+ - **仅使用 Git**:不调用任何包管理器/构建命令(无 `pnpm`/`npm`/`yarn` 等)。
154
+ - **尊重钩子**:默认执行本地 Git 钩子;使用 `--no-verify` 可跳过。
155
+ - **不改源码内容**:命令只读写 `.git/COMMIT_EDITMSG` 与暂存区;不会直接编辑工作区文件。
156
+ - **安全提示**:在 rebase/merge 冲突、detached HEAD 等状态下会先提示处理/确认再继续。
157
+ - **可审可控**:如开启 `confirm: true`,每个实际 `git add`/`git commit` 步骤都会进行二次确认。