@selfagency/git-mcp 0.1.2 → 0.2.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 +173 -93
- package/index.js +3813 -1999
- package/index.js.map +1 -1
- package/package.json +4 -3
- package/skills/git-mcp-workflow/SKILL.md +218 -0
- package/skills/git-mcp-workflow/references/tooling-map.md +390 -0
- package/skills/git-mcp-workflow/references/workflow-playbooks.md +370 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# MCP-First Workflow Playbooks
|
|
2
|
+
|
|
3
|
+
These playbooks adapt common Git workflows to `git-mcp`.
|
|
4
|
+
|
|
5
|
+
> **Do not use `git` via the shell for any operation covered here.** Shell-invoked `git` requires precise quoting across `sh`/`bash`/`zsh` layers. LLMs routinely produce malformed quoting that silently truncates commit messages, misinterprets arguments as flags, and breaks paths with spaces. Every workflow below uses `git-mcp` tools exclusively, which pass arguments as typed arrays with no shell interpretation.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Simple feature branch flow
|
|
10
|
+
|
|
11
|
+
Use for standard GitHub Flow work.
|
|
12
|
+
|
|
13
|
+
1. Orient:
|
|
14
|
+
- `git_context action=summary`
|
|
15
|
+
- `git_status action=status`
|
|
16
|
+
- `git_history action=lg` — graph view of branch topology
|
|
17
|
+
2. Sync your base:
|
|
18
|
+
- `git_remotes action=fetch`
|
|
19
|
+
- `git_branches action=checkout ref=main`
|
|
20
|
+
- `git_remotes action=pull`
|
|
21
|
+
3. Create the branch:
|
|
22
|
+
- `git_branches action=create name=feat/my-feature from_ref=main create=true`
|
|
23
|
+
4. Inspect edits as you work:
|
|
24
|
+
- `git_status action=diff mode=unstaged` — changes not yet staged
|
|
25
|
+
- `git_status action=diff mode=staged` — after staging
|
|
26
|
+
5. Stage and commit:
|
|
27
|
+
- `git_commits action=add all=true` (or `paths=[...]` for specific files)
|
|
28
|
+
- `git_commits action=commit message="feat: describe the change"`
|
|
29
|
+
6. Publish:
|
|
30
|
+
- `git_remotes action=push set_upstream=true`
|
|
31
|
+
|
|
32
|
+
Guidance:
|
|
33
|
+
|
|
34
|
+
- Keep commits atomic and reviewable
|
|
35
|
+
- Use Conventional Commit messages
|
|
36
|
+
- Quick context save: `git_commits action=wip` stages and commits "WIP" in one call
|
|
37
|
+
- Undo the last unpublished commit without losing changes: `git_commits action=undo`
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 2. Review-fix cleanup flow
|
|
42
|
+
|
|
43
|
+
Use when a PR gets feedback and the branch needs cleanup.
|
|
44
|
+
|
|
45
|
+
1. Inspect branch state:
|
|
46
|
+
- `git_context action=summary`
|
|
47
|
+
- `git_status action=status`
|
|
48
|
+
- `git_history action=log`
|
|
49
|
+
2. Apply fixes and commit them normally
|
|
50
|
+
3. If the branch is still private and the user wants a cleaned-up history:
|
|
51
|
+
- `git_remotes action=fetch`
|
|
52
|
+
- `git_workspace action=rebase rebase_action=start rebase_upstream=origin/main`
|
|
53
|
+
4. Resolve conflicts, then:
|
|
54
|
+
- `git_commits action=add all=true`
|
|
55
|
+
- `git_workspace action=rebase rebase_action=continue`
|
|
56
|
+
5. Publish rewritten history safely:
|
|
57
|
+
- `git_remotes action=push force_with_lease=true`
|
|
58
|
+
|
|
59
|
+
Do not use this on shared/public branches unless the user clearly approves history rewriting.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 3. Safe recovery after reset, rebase, or detached HEAD
|
|
64
|
+
|
|
65
|
+
### Bad reset or rebase
|
|
66
|
+
|
|
67
|
+
1. Capture recovery state:
|
|
68
|
+
- `git_history action=reflog` — find the lost HEAD position
|
|
69
|
+
- `git_history action=log`
|
|
70
|
+
2. Identify the target SHA
|
|
71
|
+
3. Recover with one of:
|
|
72
|
+
- `git_commits action=reset mode=soft target=<SHA>` — soft reset to lost commit
|
|
73
|
+
- `git_workspace action=cherry_pick cherry_pick_action=start cherry_pick_refs=[<SHA>]` — replay onto current branch
|
|
74
|
+
4. Verify:
|
|
75
|
+
- `git_status action=status`
|
|
76
|
+
- `git_history action=log`
|
|
77
|
+
|
|
78
|
+
Prefer `cherry_pick` when you want a conservative recovery that does not move the branch pointer backward.
|
|
79
|
+
|
|
80
|
+
### Detached HEAD
|
|
81
|
+
|
|
82
|
+
1. Confirm state: `git_context action=summary`, `git_history action=log`
|
|
83
|
+
2. If work should be preserved, create a branch from the current SHA:
|
|
84
|
+
- `git_branches action=create name=recovery/<short-sha> from_ref=HEAD create=true`
|
|
85
|
+
3. Continue normal work from the new branch
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 4. Backport or selective fix flow
|
|
90
|
+
|
|
91
|
+
Use for hotfixes and maintenance branches.
|
|
92
|
+
|
|
93
|
+
1. Find the source commit:
|
|
94
|
+
- `git_history action=show ref=<SHA>` — inspect patch
|
|
95
|
+
- `git_history action=log` — find the right SHA
|
|
96
|
+
2. Switch to the target branch:
|
|
97
|
+
- `git_branches action=checkout ref=<maintenance-branch>`
|
|
98
|
+
3. Apply the fix:
|
|
99
|
+
- `git_workspace action=cherry_pick cherry_pick_action=start cherry_pick_refs=[<SHA>]`
|
|
100
|
+
4. If conflicts occur:
|
|
101
|
+
- `git_status action=status` — inspect
|
|
102
|
+
- resolve files in worktree
|
|
103
|
+
- `git_commits action=add all=true`
|
|
104
|
+
- `git_workspace action=cherry_pick cherry_pick_action=continue`
|
|
105
|
+
5. Validate and push:
|
|
106
|
+
- `git_history action=log`
|
|
107
|
+
- `git_remotes action=push`
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 5. Worktree isolation flow
|
|
112
|
+
|
|
113
|
+
### Directory strategy
|
|
114
|
+
|
|
115
|
+
Prefer this order when choosing a worktree location:
|
|
116
|
+
|
|
117
|
+
1. existing `.worktrees/`
|
|
118
|
+
2. existing `worktrees/`
|
|
119
|
+
3. a documented project preference
|
|
120
|
+
4. ask the user
|
|
121
|
+
|
|
122
|
+
### Safety checks
|
|
123
|
+
|
|
124
|
+
Before creating a project-local worktree:
|
|
125
|
+
|
|
126
|
+
- Inspect whether the directory already exists with workspace file tools
|
|
127
|
+
- Inspect `.gitignore` to confirm the directory is ignored
|
|
128
|
+
- If it is not ignored, fix that first
|
|
129
|
+
|
|
130
|
+
### Creation flow
|
|
131
|
+
|
|
132
|
+
1. Orient: `git_context action=summary`
|
|
133
|
+
2. Choose location and branch name
|
|
134
|
+
3. Create the worktree:
|
|
135
|
+
- `git_workspace action=worktree worktree_action=add path=<dir> branch=<branch>`
|
|
136
|
+
- For a detached worktree: add `worktree_detached=true`
|
|
137
|
+
4. Run project setup and baseline validation
|
|
138
|
+
5. Report the worktree path and baseline status
|
|
139
|
+
|
|
140
|
+
### Cleanup
|
|
141
|
+
|
|
142
|
+
- Remove: `git_workspace action=worktree worktree_action=remove path=<dir>`
|
|
143
|
+
- Lock while temporarily unused: `git_workspace action=worktree worktree_action=lock path=<dir> worktree_lock_reason="in-progress"`
|
|
144
|
+
- Prune stale entries: `git_workspace action=worktree worktree_action=prune`
|
|
145
|
+
- View all: `git_workspace action=worktree worktree_action=list`
|
|
146
|
+
|
|
147
|
+
Red flags:
|
|
148
|
+
|
|
149
|
+
- Never create a project-local worktree without checking ignore rules
|
|
150
|
+
- Never assume a directory convention when the repo already documents one
|
|
151
|
+
- Never start implementation from a worktree whose baseline is already failing without telling the user
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 6. Stash-driven context switch flow
|
|
156
|
+
|
|
157
|
+
Use when work is not ready to commit.
|
|
158
|
+
|
|
159
|
+
1. Inspect what would be stashed:
|
|
160
|
+
- `git_status action=status`
|
|
161
|
+
- `git_status action=diff mode=unstaged`
|
|
162
|
+
2. Stash everything including untracked (convenience shortcut):
|
|
163
|
+
- `git_workspace action=stash_all message="<description>"`
|
|
164
|
+
- Or granularly: `git_workspace action=stash stash_action=save message="<description>" include_untracked=true`
|
|
165
|
+
3. Switch branches or pull changes
|
|
166
|
+
4. Restore later:
|
|
167
|
+
- `git_workspace action=stash stash_action=list` — find the right stash index
|
|
168
|
+
- `git_workspace action=stash stash_action=pop index=0` — pop and remove
|
|
169
|
+
- Or `stash_action=apply` to keep the stash entry
|
|
170
|
+
5. Validate: `git_status action=status`, `git_status action=diff mode=unstaged`
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 7. Regression hunt with bisect
|
|
175
|
+
|
|
176
|
+
Use when you know a good state and a bad state.
|
|
177
|
+
|
|
178
|
+
1. Orient: `git_context action=summary`, `git_history action=log`
|
|
179
|
+
2. Begin bisect with known bounds:
|
|
180
|
+
- `git_workspace action=bisect bisect_action=start good_ref=<known-good-SHA> bad_ref=HEAD`
|
|
181
|
+
3. At each step, test the checked-out revision
|
|
182
|
+
4. Mark each step:
|
|
183
|
+
- `git_workspace action=bisect bisect_action=good` or `bisect_action=bad`
|
|
184
|
+
- Or skip a flaky commit: `bisect_action=skip ref=<SHA>`
|
|
185
|
+
5. When bisect identifies the culprit:
|
|
186
|
+
- `git_history action=show ref=<culprit-SHA>` — record the commit
|
|
187
|
+
6. End the session:
|
|
188
|
+
- `git_workspace action=bisect bisect_action=reset`
|
|
189
|
+
|
|
190
|
+
For automated test-driven bisect:
|
|
191
|
+
|
|
192
|
+
- `git_workspace action=bisect bisect_action=run command="pnpm test --silent"`
|
|
193
|
+
- The command must exit 0 for good, non-0 for bad
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 8. Release tagging and GitHub release flow
|
|
198
|
+
|
|
199
|
+
### Tagging with git-mcp
|
|
200
|
+
|
|
201
|
+
1. Confirm release readiness:
|
|
202
|
+
- `git_context action=summary`
|
|
203
|
+
- `git_status action=status`
|
|
204
|
+
- `git_history action=log`
|
|
205
|
+
2. Verify version files via workspace file reads or project tests
|
|
206
|
+
3. Create the annotated tag:
|
|
207
|
+
- `git_workspace action=tag tag_action=create name=v1.2.3 target=HEAD message="Release v1.2.3"`
|
|
208
|
+
- For signed tags: add `sign=true` and optionally `signing_key=<keyid>`
|
|
209
|
+
4. View all tags: `git_workspace action=tag tag_action=list`
|
|
210
|
+
5. Push the tag:
|
|
211
|
+
- `git_remotes action=push tags=true`
|
|
212
|
+
|
|
213
|
+
### GitHub release guidance
|
|
214
|
+
|
|
215
|
+
GitHub Releases are outside `git-mcp`. Use GitHub tooling for release objects.
|
|
216
|
+
|
|
217
|
+
Rules:
|
|
218
|
+
|
|
219
|
+
- Never delete a published GitHub release to retry it; fix forward with the next version
|
|
220
|
+
- For maintenance-branch releases, ensure the GitHub release is not marked as latest unless intended
|
|
221
|
+
- Create releases only after the correct commit and version files are verified
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 9. Branching strategy workflows
|
|
226
|
+
|
|
227
|
+
### GitHub Flow
|
|
228
|
+
|
|
229
|
+
Prefer for continuous delivery and short-lived branches.
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
git_remotes action=fetch
|
|
233
|
+
git_branches action=checkout ref=main
|
|
234
|
+
git_remotes action=pull
|
|
235
|
+
git_branches action=create name=feat/... from_ref=main create=true
|
|
236
|
+
# work...
|
|
237
|
+
git_commits action=add all=true
|
|
238
|
+
git_commits action=commit message="feat: ..."
|
|
239
|
+
git_remotes action=push set_upstream=true
|
|
240
|
+
# PR via GitHub tooling
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Git Flow (classic)
|
|
244
|
+
|
|
245
|
+
Prefer for scheduled releases and release branches.
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
# Initialize
|
|
249
|
+
git_flow action=init
|
|
250
|
+
|
|
251
|
+
# Inspect current flow state first
|
|
252
|
+
git_flow action=overview
|
|
253
|
+
|
|
254
|
+
# Feature
|
|
255
|
+
git_flow operation=topic topic_action=start topic=feature name=my-feature
|
|
256
|
+
git_flow operation=topic topic_action=finish topic=feature name=my-feature
|
|
257
|
+
|
|
258
|
+
# Release
|
|
259
|
+
git_flow operation=topic topic_action=start topic=release name=1.2.0
|
|
260
|
+
git_flow operation=topic topic_action=finish topic=release name=1.2.0
|
|
261
|
+
|
|
262
|
+
# Hotfix
|
|
263
|
+
git_flow operation=topic topic_action=start topic=hotfix name=1.1.1
|
|
264
|
+
git_flow operation=topic topic_action=finish topic=hotfix name=1.1.1
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### git-flow-next preset workflows
|
|
268
|
+
|
|
269
|
+
Use when the repository uses configured branch graphs instead of only the classic hardcoded branch families.
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
# Initialize with preset
|
|
273
|
+
git_flow operation=init preset=github # or classic, gitlab
|
|
274
|
+
|
|
275
|
+
# Inspect configured flow first
|
|
276
|
+
git_flow operation=overview
|
|
277
|
+
|
|
278
|
+
# Manage topic type config
|
|
279
|
+
git_flow operation=config config_action=add topic=chore prefix=chore/
|
|
280
|
+
git_flow operation=config config_action=list
|
|
281
|
+
|
|
282
|
+
# Start and finish a configured topic branch
|
|
283
|
+
git_flow operation=topic topic_action=start topic=chore name=update-deps
|
|
284
|
+
git_flow operation=topic topic_action=publish topic=chore name=update-deps
|
|
285
|
+
git_flow operation=topic topic_action=finish topic=chore name=update-deps
|
|
286
|
+
|
|
287
|
+
# List active branches for a topic type
|
|
288
|
+
git_flow operation=topic topic_action=list topic=feature
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### git_flow finish recovery
|
|
292
|
+
|
|
293
|
+
Use when a finish sequence pauses on merge conflicts.
|
|
294
|
+
|
|
295
|
+
1. `git_flow operation=topic topic_action=finish topic=feature name=<name>`
|
|
296
|
+
2. Resolve conflicts in the working tree
|
|
297
|
+
3. `git_commits action=add all=true`
|
|
298
|
+
4. `git_flow operation=control control_action=continue` — resume the paused finish
|
|
299
|
+
5. Or: `git_flow operation=control control_action=abort` — unwind the in-progress finish
|
|
300
|
+
|
|
301
|
+
### Hook-aware flow execution
|
|
302
|
+
|
|
303
|
+
Hook/filter execution is disabled by default. To enable:
|
|
304
|
+
|
|
305
|
+
- Set `GIT_ALLOW_FLOW_HOOKS=true` in the server environment only when repo hooks are trusted
|
|
306
|
+
- Run `git_flow operation=overview` before any mutating flow action
|
|
307
|
+
- When hooks are disabled, responses report skipped execution instead of running repository programs
|
|
308
|
+
|
|
309
|
+
### Trunk-based development
|
|
310
|
+
|
|
311
|
+
Keep branches extremely short-lived. Use the same MCP calls as GitHub Flow but merge within hours, not days.
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 10. Merge workflow
|
|
316
|
+
|
|
317
|
+
Use when merging a branch without rebasing.
|
|
318
|
+
|
|
319
|
+
1. Orient: `git_context action=summary`
|
|
320
|
+
2. Ensure local branch is up to date:
|
|
321
|
+
- `git_remotes action=fetch`
|
|
322
|
+
- `git_branches action=checkout ref=<target-branch>`
|
|
323
|
+
- `git_remotes action=pull`
|
|
324
|
+
3. Merge the source branch:
|
|
325
|
+
- `git_workspace action=merge merge_action=start merge_refs=[<source-branch>]`
|
|
326
|
+
- No-fast-forward for explicit merge commits: add `merge_no_ff=true`
|
|
327
|
+
- Squash merge: add `merge_squash=true`
|
|
328
|
+
4. If conflicts occur:
|
|
329
|
+
- `git_status action=status` — identify conflicted files
|
|
330
|
+
- Resolve files in worktree
|
|
331
|
+
- `git_commits action=add all=true`
|
|
332
|
+
- `git_workspace action=merge merge_action=continue`
|
|
333
|
+
5. Validate: `git_history action=log`
|
|
334
|
+
6. Push: `git_remotes action=push`
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 11. Hooks, CI, and commit discipline
|
|
339
|
+
|
|
340
|
+
- Do not bypass hooks by default
|
|
341
|
+
- If hooks fail, fix the underlying issue
|
|
342
|
+
- Use Conventional Commit messages
|
|
343
|
+
- Keep commits atomic
|
|
344
|
+
- Prefer small PRs with clear summaries and test notes
|
|
345
|
+
|
|
346
|
+
For this repository specifically:
|
|
347
|
+
|
|
348
|
+
- Pre-commit runs `pnpm exec lint-staged` and `pnpm typecheck`
|
|
349
|
+
- Before finishing work, run:
|
|
350
|
+
- `pnpm typecheck`
|
|
351
|
+
- `pnpm lint`
|
|
352
|
+
- `pnpm format:check`
|
|
353
|
+
- `pnpm test`
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## 12. When CLI is absolutely necessary
|
|
358
|
+
|
|
359
|
+
Use the shell only when a required capability is not exposed by `git-mcp`:
|
|
360
|
+
|
|
361
|
+
- Interactive rebase editing with manual squash/reword/drop choreography (requires text editor)
|
|
362
|
+
- Patch-mode staging (`git add -p`)
|
|
363
|
+
- Repository-wide history rewriting (`git filter-repo`)
|
|
364
|
+
- Project-specific hook installation commands
|
|
365
|
+
|
|
366
|
+
Even then:
|
|
367
|
+
|
|
368
|
+
- Capture `git_history action=reflog` first
|
|
369
|
+
- Explain the risk to the user
|
|
370
|
+
- Prefer the least destructive option
|