cursor-devops-commands 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 +165 -0
- package/bin/cli.js +312 -0
- package/commands/deployment/metrics-report.md +272 -0
- package/commands/deployment/post-deploy-check.md +150 -0
- package/commands/git/auto-rebase.md +220 -0
- package/commands/git/decision-record.md +302 -0
- package/commands/git/find-shared.md +104 -0
- package/commands/git/suggest-reviewers.md +237 -0
- package/commands/security/rollback-impact.md +215 -0
- package/commands/security/security-audit.md +238 -0
- package/package.json +36 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate velocity, DORA metrics, AI impact, and ROI report for tickets/sprints
|
|
3
|
+
category: Ops & Monitoring
|
|
4
|
+
aliases: [metrics, velocity, roi-calc, report]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Metrics Report - Development Velocity & ROI Tracking
|
|
8
|
+
|
|
9
|
+
Generate measurable business outcomes for engineering work.
|
|
10
|
+
|
|
11
|
+
## ⚠️ Confidence Bounds
|
|
12
|
+
|
|
13
|
+
AI-related metrics are **estimated** and **directional**:
|
|
14
|
+
|
|
15
|
+
- AI attribution is heuristic-based, not deterministic
|
|
16
|
+
- Numbers are approximate indicators, not hard KPIs
|
|
17
|
+
- Use for personal measurement and trend analysis
|
|
18
|
+
- **Do not** use for performance reviews or metric gaming
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
/metrics-report {TICKET_ID}
|
|
24
|
+
/metrics-report --sprint current
|
|
25
|
+
/metrics-report --team @YourOrg/team-a
|
|
26
|
+
/metrics-report --period 30d
|
|
27
|
+
/roi-calc # Alias: AI ROI focus
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## What This Does
|
|
31
|
+
|
|
32
|
+
1. **Collects metrics** - Time, velocity, quality data
|
|
33
|
+
2. **Calculates DORA** - Key engineering metrics
|
|
34
|
+
3. **Tracks AI-assisted work** - Cursor/copilot impact
|
|
35
|
+
4. **Generates ROI** - Business value of changes
|
|
36
|
+
5. **Creates report** - Shareable with leadership
|
|
37
|
+
|
|
38
|
+
## DORA Metrics (2025 Standard)
|
|
39
|
+
|
|
40
|
+
| Metric | Definition | Target |
|
|
41
|
+
| ------------------------- | ------------------- | ----------- |
|
|
42
|
+
| **Lead Time** | Commit → Production | < 24 hours |
|
|
43
|
+
| **Deployment Frequency** | Deploys per day | > 1 per day |
|
|
44
|
+
| **Change Failure Rate** | Failed deploy % | < 5% |
|
|
45
|
+
| **Mean Time to Recovery** | Incident resolution | < 1 hour |
|
|
46
|
+
|
|
47
|
+
## Output Format
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
📋 Generating metrics report for TICKET-123...
|
|
51
|
+
|
|
52
|
+
════════════════════════════════════════════════════════════════
|
|
53
|
+
TICKET SUMMARY
|
|
54
|
+
════════════════════════════════════════════════════════════════
|
|
55
|
+
|
|
56
|
+
Ticket: TICKET-123 - Marketing texts for protection packages
|
|
57
|
+
Type: Story (Feature)
|
|
58
|
+
Priority: Medium
|
|
59
|
+
Sprint: 2024-12-W51
|
|
60
|
+
|
|
61
|
+
════════════════════════════════════════════════════════════════
|
|
62
|
+
⏱️ VELOCITY METRICS
|
|
63
|
+
════════════════════════════════════════════════════════════════
|
|
64
|
+
|
|
65
|
+
## Timeline
|
|
66
|
+
|
|
67
|
+
| Phase | Start | End | Duration |
|
|
68
|
+
|-------|-------|-----|----------|
|
|
69
|
+
| Created | Dec 18 | - | - |
|
|
70
|
+
| In Progress | Dec 20 | Dec 23 | 3 days |
|
|
71
|
+
| In Review | Dec 23 | Dec 23 | 4 hours |
|
|
72
|
+
| Merged | Dec 23 | - | - |
|
|
73
|
+
| Deployed | Dec 23 | - | 2 hours |
|
|
74
|
+
|
|
75
|
+
## DORA Metrics
|
|
76
|
+
|
|
77
|
+
| Metric | Value | Target | Status |
|
|
78
|
+
|--------|-------|--------|--------|
|
|
79
|
+
| Lead Time | 5 days | < 7 days | ✅ Good |
|
|
80
|
+
| Cycle Time | 3 days | < 5 days | ✅ Excellent |
|
|
81
|
+
| Review Time | 4 hours | < 8 hours | ✅ Excellent |
|
|
82
|
+
| Time to Deploy | 2 hours | < 4 hours | ✅ Excellent |
|
|
83
|
+
|
|
84
|
+
## Comparison to Team Average
|
|
85
|
+
|
|
86
|
+
| Metric | This Ticket | Team Avg | Delta |
|
|
87
|
+
|--------|-------------|----------|-------|
|
|
88
|
+
| Lead Time | 5 days | 7.2 days | -31% ✅ |
|
|
89
|
+
| Lines Changed | 156 | 234 | -33% ✅ |
|
|
90
|
+
| Files Touched | 7 | 12 | -42% ✅ |
|
|
91
|
+
| PR Revisions | 2 | 3.5 | -43% ✅ |
|
|
92
|
+
|
|
93
|
+
════════════════════════════════════════════════════════════════
|
|
94
|
+
📊 QUALITY METRICS
|
|
95
|
+
════════════════════════════════════════════════════════════════
|
|
96
|
+
|
|
97
|
+
## Code Quality
|
|
98
|
+
|
|
99
|
+
| Metric | Value | Threshold | Status |
|
|
100
|
+
|--------|-------|-----------|--------|
|
|
101
|
+
| Test Coverage | 78% | > 70% | ✅ Pass |
|
|
102
|
+
| Mutation Score | 71% | > 65% | ✅ Pass |
|
|
103
|
+
| Lint Issues | 0 | 0 | ✅ Pass |
|
|
104
|
+
| Type Coverage | 100% | 100% | ✅ Pass |
|
|
105
|
+
|
|
106
|
+
## Post-Deployment
|
|
107
|
+
|
|
108
|
+
| Metric | Before | After | Change |
|
|
109
|
+
|--------|--------|-------|--------|
|
|
110
|
+
| Error Rate | 0.02% | 0.02% | 0% ✅ |
|
|
111
|
+
| LCP | 2.1s | 2.1s | 0% ✅ |
|
|
112
|
+
| Bundle Size | 245KB | 246KB | +0.4% ✅ |
|
|
113
|
+
|
|
114
|
+
## Review Quality
|
|
115
|
+
|
|
116
|
+
| Metric | Value |
|
|
117
|
+
|--------|-------|
|
|
118
|
+
| Comments | 5 |
|
|
119
|
+
| Blocking issues | 0 |
|
|
120
|
+
| Suggestions | 3 |
|
|
121
|
+
| Approvals | 2 |
|
|
122
|
+
| Time to first review | 45 min |
|
|
123
|
+
|
|
124
|
+
════════════════════════════════════════════════════════════════
|
|
125
|
+
🤖 AI-ASSISTED DEVELOPMENT METRICS
|
|
126
|
+
════════════════════════════════════════════════════════════════
|
|
127
|
+
|
|
128
|
+
## Cursor/Copilot Usage
|
|
129
|
+
|
|
130
|
+
| Metric | Value |
|
|
131
|
+
|--------|-------|
|
|
132
|
+
| AI-generated code | 42% |
|
|
133
|
+
| AI suggestions accepted | 78% |
|
|
134
|
+
| Commands used | 12 |
|
|
135
|
+
| Time saved (estimated) | 4.5 hours |
|
|
136
|
+
|
|
137
|
+
## Commands Used
|
|
138
|
+
|
|
139
|
+
| Command | Times | Outcome |
|
|
140
|
+
|---------|-------|---------|
|
|
141
|
+
| /full-flow | 1 | Workflow orchestration |
|
|
142
|
+
| /gather-context | 2 | Requirements gathering |
|
|
143
|
+
| /pr-review | 1 | Self-review |
|
|
144
|
+
| /jira-test | 1 | How to Test comment |
|
|
145
|
+
| /jira-docs | 1 | Confluence page |
|
|
146
|
+
|
|
147
|
+
## AI ROI
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Without AI Assistance (Estimated):
|
|
152
|
+
Development: 16 hours
|
|
153
|
+
Testing: 4 hours
|
|
154
|
+
Documentation: 2 hours
|
|
155
|
+
Total: 22 hours
|
|
156
|
+
|
|
157
|
+
With AI Assistance (Actual):
|
|
158
|
+
Development: 9 hours
|
|
159
|
+
Testing: 2 hours
|
|
160
|
+
Documentation: 0.5 hours
|
|
161
|
+
Total: 11.5 hours
|
|
162
|
+
|
|
163
|
+
Time Saved: 10.5 hours (48%)
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
════════════════════════════════════════════════════════════════
|
|
168
|
+
💰 BUSINESS VALUE
|
|
169
|
+
════════════════════════════════════════════════════════════════
|
|
170
|
+
|
|
171
|
+
## Feature Impact
|
|
172
|
+
|
|
173
|
+
| Metric | Value |
|
|
174
|
+
|--------|-------|
|
|
175
|
+
| Users Affected | ~50,000/day |
|
|
176
|
+
| Conversion Impact | TBD (A/B test) |
|
|
177
|
+
| Revenue Impact | TBD (post-rollout) |
|
|
178
|
+
|
|
179
|
+
## Engineering Investment
|
|
180
|
+
|
|
181
|
+
| Category | Hours | Cost (est.) |
|
|
182
|
+
|----------|-------|-------------|
|
|
183
|
+
| Development | 11.5 | €1,150 |
|
|
184
|
+
| Review | 1.5 | €150 |
|
|
185
|
+
| Testing | 2 | €200 |
|
|
186
|
+
| **Total** | **15** | **€1,500** |
|
|
187
|
+
|
|
188
|
+
## ROI Calculation
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Investment: €1,500 (15 engineer hours)
|
|
193
|
+
Expected Return: €4,500/month (improved conversion)
|
|
194
|
+
Payback Period: ~10 days
|
|
195
|
+
Annual ROI: 3,500%
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
════════════════════════════════════════════════════════════════
|
|
200
|
+
📈 TRENDS
|
|
201
|
+
════════════════════════════════════════════════════════════════
|
|
202
|
+
|
|
203
|
+
## Your Velocity (Last 30 Days)
|
|
204
|
+
|
|
205
|
+
| Week | Tickets | Avg Lead Time | Quality |
|
|
206
|
+
|------|---------|---------------|---------|
|
|
207
|
+
| W49 | 3 | 6.2 days | 92% |
|
|
208
|
+
| W50 | 4 | 5.8 days | 95% |
|
|
209
|
+
| W51 | 3 | 5.0 days | 97% |
|
|
210
|
+
|
|
211
|
+
Trend: ↑ Improving (+19% velocity, +5% quality)
|
|
212
|
+
|
|
213
|
+
## Team Comparison
|
|
214
|
+
|
|
215
|
+
| Developer | Tickets | Velocity | Quality |
|
|
216
|
+
|-----------|---------|----------|---------|
|
|
217
|
+
| You | 10 | ████████ 92% | ██████████ 95% |
|
|
218
|
+
| Team Avg | 8 | ██████ 78% | ████████ 88% |
|
|
219
|
+
|
|
220
|
+
════════════════════════════════════════════════════════════════
|
|
221
|
+
📋 EXECUTIVE SUMMARY
|
|
222
|
+
════════════════════════════════════════════════════════════════
|
|
223
|
+
|
|
224
|
+
## TICKET-123 Metrics at a Glance
|
|
225
|
+
|
|
226
|
+
| Category | Score | Details |
|
|
227
|
+
|----------|-------|---------|
|
|
228
|
+
| Velocity | ⭐⭐⭐⭐⭐ | 31% faster than average |
|
|
229
|
+
| Quality | ⭐⭐⭐⭐ | 78% coverage, 0 regressions |
|
|
230
|
+
| AI Impact | ⭐⭐⭐⭐⭐ | 48% time saved |
|
|
231
|
+
| Business Value | ⭐⭐⭐⭐ | High (user-facing feature) |
|
|
232
|
+
|
|
233
|
+
**Key Highlights:**
|
|
234
|
+
- Feature delivered 2 days ahead of estimate
|
|
235
|
+
- Zero production issues post-deploy
|
|
236
|
+
- AI assistance reduced development time by ~50%
|
|
237
|
+
- Comprehensive documentation created automatically
|
|
238
|
+
|
|
239
|
+
**Recommendation:**
|
|
240
|
+
Continue using AI-assisted workflow for similar tickets.
|
|
241
|
+
Consider as template for team adoption.
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Data Sources
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Get ticket timeline from Jira
|
|
248
|
+
jira issue view {TICKET} --plain
|
|
249
|
+
|
|
250
|
+
# Get PR metrics from GitHub
|
|
251
|
+
gh pr view {PR} --json createdAt,mergedAt,reviews,comments
|
|
252
|
+
|
|
253
|
+
# Get deployment info
|
|
254
|
+
gh api repos/YourCompany/com.yourcompany.web.public/deployments
|
|
255
|
+
|
|
256
|
+
# Get code metrics
|
|
257
|
+
git log --oneline --after="2024-12-01" --author="$USER" | wc -l
|
|
258
|
+
|
|
259
|
+
# Get coverage
|
|
260
|
+
pnpm test:coverage -- --coverageReporters=json-summary
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## AI Execution
|
|
264
|
+
|
|
265
|
+
When user runs `/metrics-report {TICKET}`:
|
|
266
|
+
|
|
267
|
+
1. **Collect data** - Jira, GitHub, monitoring
|
|
268
|
+
2. **Calculate DORA** - Lead time, deployment freq, etc.
|
|
269
|
+
3. **Track AI usage** - Commands, time saved
|
|
270
|
+
4. **Estimate ROI** - Business value projection
|
|
271
|
+
5. **Compare trends** - Historical performance
|
|
272
|
+
6. **Generate report** - Executive-ready summary
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Monitor feature health after deploy - errors, metrics, rollout status
|
|
3
|
+
category: Ops & Monitoring
|
|
4
|
+
aliases: [deploy-check, monitor, verify-deploy]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Post-Deploy Check - Verify Feature Health After Deployment
|
|
8
|
+
|
|
9
|
+
Monitor and verify the health of a feature after deployment using observability tools.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
/post-deploy-check {TICKET_ID}
|
|
15
|
+
/post-deploy-check {TICKET_ID} --env production
|
|
16
|
+
/post-deploy-check {TICKET_ID} --duration 30m
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What This Does
|
|
20
|
+
|
|
21
|
+
1. **Identifies deployed changes** - Maps ticket to deployed commits
|
|
22
|
+
2. **Monitors error rates** - Checks for spikes in Sentry/Instana
|
|
23
|
+
3. **Tracks performance metrics** - Bundle size, LCP, FID
|
|
24
|
+
4. **Validates feature flags** - Confirms Statsig rollout status
|
|
25
|
+
5. **Generates health report** - Pass/Fail with recommendations
|
|
26
|
+
|
|
27
|
+
## Monitoring Integration
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
31
|
+
│ MONITORING SOURCES │
|
|
32
|
+
├─────────────────────────────────────────────────────────────┤
|
|
33
|
+
│ Instana → Error rates, latency, traces │
|
|
34
|
+
│ Sentry → JavaScript errors, breadcrumbs │
|
|
35
|
+
│ Statsig → Feature flag status, experiment results │
|
|
36
|
+
│ CloudWatch → Lambda metrics, API gateway │
|
|
37
|
+
│ GitHub → Deployment status, commit info │
|
|
38
|
+
└─────────────────────────────────────────────────────────────┘
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Health Check Dimensions
|
|
42
|
+
|
|
43
|
+
| Dimension | Metrics | Threshold |
|
|
44
|
+
| --------------- | ---------------------- | --------------- |
|
|
45
|
+
| **Errors** | Error rate, new errors | < 0.1% increase |
|
|
46
|
+
| **Performance** | LCP, FID, CLS | No regression |
|
|
47
|
+
| **Bundle** | JS size, chunk sizes | < 5% increase |
|
|
48
|
+
| **API** | Latency, 5xx rate | < p95 baseline |
|
|
49
|
+
| **Feature** | Flag status, rollout % | As configured |
|
|
50
|
+
|
|
51
|
+
## Output Format
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
📋 Post-Deploy Check for TICKET-123...
|
|
55
|
+
|
|
56
|
+
════════════════════════════════════════════════════════════════
|
|
57
|
+
DEPLOYMENT INFO
|
|
58
|
+
════════════════════════════════════════════════════════════════
|
|
59
|
+
|
|
60
|
+
Ticket: TICKET-123 - Marketing texts for protection packages
|
|
61
|
+
Commit: ed304bcf4fb
|
|
62
|
+
Deployed: 2024-12-23 15:30:00 UTC
|
|
63
|
+
Environment: Production (EU)
|
|
64
|
+
Duration: 30 minutes monitored
|
|
65
|
+
|
|
66
|
+
════════════════════════════════════════════════════════════════
|
|
67
|
+
HEALTH METRICS
|
|
68
|
+
════════════════════════════════════════════════════════════════
|
|
69
|
+
|
|
70
|
+
## Error Rate
|
|
71
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
72
|
+
│ Before: 0.02% │ After: 0.02% │ Change: +0.00% │ ✅ │
|
|
73
|
+
└──────────────────────────────────────────────────────────────┘
|
|
74
|
+
|
|
75
|
+
## New Errors (Sentry)
|
|
76
|
+
✅ No new errors detected in affected components
|
|
77
|
+
|
|
78
|
+
## Performance (Web Vitals)
|
|
79
|
+
| Metric | Before | After | Change | Status |
|
|
80
|
+
|--------|--------|-------|--------|--------|
|
|
81
|
+
| LCP | 2.1s | 2.1s | +0.00s | ✅ |
|
|
82
|
+
| FID | 45ms | 44ms | -1ms | ✅ |
|
|
83
|
+
| CLS | 0.05 | 0.05 | +0.00 | ✅ |
|
|
84
|
+
|
|
85
|
+
## Bundle Size
|
|
86
|
+
| Chunk | Before | After | Change | Status |
|
|
87
|
+
|-------|--------|-------|--------|--------|
|
|
88
|
+
| rent-checkout | 245KB | 246KB | +0.4% | ✅ |
|
|
89
|
+
| business-modules | 128KB | 128KB | +0.0% | ✅ |
|
|
90
|
+
|
|
91
|
+
## Feature Flags (Statsig)
|
|
92
|
+
| Flag | Status | Rollout | Exposures |
|
|
93
|
+
|------|--------|---------|-----------|
|
|
94
|
+
| rent_frictionless_checkout_v2 | ✅ Active | 100% | 12,340 |
|
|
95
|
+
|
|
96
|
+
## API Health
|
|
97
|
+
| Endpoint | p50 | p95 | 5xx Rate |
|
|
98
|
+
|----------|-----|-----|----------|
|
|
99
|
+
| /booking/v2 | 120ms | 350ms | 0.01% |
|
|
100
|
+
|
|
101
|
+
════════════════════════════════════════════════════════════════
|
|
102
|
+
VERDICT: ✅ HEALTHY
|
|
103
|
+
════════════════════════════════════════════════════════════════
|
|
104
|
+
|
|
105
|
+
All metrics within acceptable thresholds.
|
|
106
|
+
Feature deployed successfully with no regressions.
|
|
107
|
+
|
|
108
|
+
Recommended: Continue monitoring for 24h before closing ticket.
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Commands Used
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Get deployment info from GitHub
|
|
115
|
+
gh api repos/YourCompany/com.yourcompany.web.public/deployments \
|
|
116
|
+
--jq '.[] | select(.environment == "production") | {sha, created_at}'
|
|
117
|
+
|
|
118
|
+
# Check Sentry for new issues (requires SENTRY_API_TOKEN)
|
|
119
|
+
curl -H "Authorization: Bearer $SENTRY_API_TOKEN" \
|
|
120
|
+
"https://sentry.io/api/0/projects/yourcompany/web-public/issues/?query=firstSeen:>=$DEPLOY_TIME"
|
|
121
|
+
|
|
122
|
+
# Check bundle size from CI artifacts
|
|
123
|
+
gh run view {RUN_ID} --json jobs \
|
|
124
|
+
--jq '.jobs[] | select(.name == "bundle-analysis") | .steps[].outputs'
|
|
125
|
+
|
|
126
|
+
# Check Statsig feature status
|
|
127
|
+
curl -H "STATSIG-API-KEY: $STATSIG_KEY" \
|
|
128
|
+
"https://statsigapi.net/console/v1/gates/rent_frictionless_checkout_v2"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Alerting Rules
|
|
132
|
+
|
|
133
|
+
| Condition | Action |
|
|
134
|
+
| -------------------------- | --------------------------- |
|
|
135
|
+
| Error rate > 0.5% increase | 🔴 Alert + suggest rollback |
|
|
136
|
+
| LCP regression > 500ms | 🟠 Warning + investigate |
|
|
137
|
+
| New Sentry errors > 10 | 🟠 Warning + triage |
|
|
138
|
+
| Bundle size > 10% increase | 🟡 Note for review |
|
|
139
|
+
| Feature flag disabled | 🔴 Alert + investigate |
|
|
140
|
+
|
|
141
|
+
## AI Execution
|
|
142
|
+
|
|
143
|
+
When user runs `/post-deploy-check {TICKET_ID}`:
|
|
144
|
+
|
|
145
|
+
1. **Map ticket to deployment** - Find commit SHA from PR
|
|
146
|
+
2. **Identify baseline** - Metrics before deployment
|
|
147
|
+
3. **Collect current metrics** - Query monitoring tools
|
|
148
|
+
4. **Compare and analyze** - Calculate deltas
|
|
149
|
+
5. **Generate report** - Health status with recommendations
|
|
150
|
+
6. **Alert if needed** - Trigger rollback suggestion if critical
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Automatically rebase branch, detect and resolve conflicts with master
|
|
3
|
+
category: PR Management
|
|
4
|
+
aliases: [rebase, sync, update-branch]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Auto-Rebase - Keep PRs Up to Date
|
|
8
|
+
|
|
9
|
+
Automatically detect and resolve conflicts with master.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
/auto-rebase
|
|
15
|
+
/auto-rebase {PR_NUMBER}
|
|
16
|
+
/auto-rebase --check-only
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What This Does
|
|
20
|
+
|
|
21
|
+
1. **Detects** when your branch is behind master
|
|
22
|
+
2. **Attempts** automatic rebase
|
|
23
|
+
3. **Flags** conflicts for manual resolution
|
|
24
|
+
4. **Re-runs** CI after successful rebase
|
|
25
|
+
|
|
26
|
+
## Automatic Detection
|
|
27
|
+
|
|
28
|
+
When running `/full-flow` or `/pr-fix`, I check:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Check if behind master
|
|
32
|
+
git fetch origin
|
|
33
|
+
BEHIND=$(git rev-list --count HEAD..origin/master)
|
|
34
|
+
|
|
35
|
+
if [ $BEHIND -gt 0 ]; then
|
|
36
|
+
echo "Branch is $BEHIND commits behind master"
|
|
37
|
+
fi
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Detection Output
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
════════════════════════════════════════════════════════════════
|
|
44
|
+
⚠️ BRANCH BEHIND MASTER
|
|
45
|
+
════════════════════════════════════════════════════════════════
|
|
46
|
+
|
|
47
|
+
Your branch: TICKET-123-display-name-charges
|
|
48
|
+
Behind master by: 12 commits
|
|
49
|
+
|
|
50
|
+
Recent master commits:
|
|
51
|
+
- abc1234: feat(TICKET-321): Add connector profile
|
|
52
|
+
- def5678: fix(TICKET-456): Fix tooltip positioning
|
|
53
|
+
- ghi9012: chore: Update dependencies
|
|
54
|
+
|
|
55
|
+
Potential conflicts detected in:
|
|
56
|
+
❌ src/features/checkout/src/components/PackagesV2.tsx
|
|
57
|
+
✅ src/components/src/ProtectionPackageCard.tsx (clean)
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
1. Auto-rebase (attempt automatic merge)
|
|
61
|
+
2. Manual rebase (I'll guide you)
|
|
62
|
+
3. Skip (continue with conflicts)
|
|
63
|
+
|
|
64
|
+
Choose: (1/2/3)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Auto-Rebase Flow
|
|
68
|
+
|
|
69
|
+
### Step 1: Stash Local Changes
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git stash push -m "auto-rebase-$(date +%s)"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 2: Attempt Rebase
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git fetch origin master
|
|
79
|
+
git rebase origin/master
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Step 3: Handle Results
|
|
83
|
+
|
|
84
|
+
**If clean rebase:**
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
✅ Rebase successful!
|
|
88
|
+
- Rebased 3 commits onto latest master
|
|
89
|
+
- No conflicts detected
|
|
90
|
+
- Pushing to origin...
|
|
91
|
+
|
|
92
|
+
git push --force-with-lease origin HEAD
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**If conflicts:**
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
════════════════════════════════════════════════════════════════
|
|
99
|
+
⚠️ CONFLICTS DETECTED
|
|
100
|
+
════════════════════════════════════════════════════════════════
|
|
101
|
+
|
|
102
|
+
Conflicts in 2 files:
|
|
103
|
+
|
|
104
|
+
1. src/features/checkout/src/components/PackagesV2.tsx
|
|
105
|
+
Lines 45-67: Both branches modified getLineItems()
|
|
106
|
+
|
|
107
|
+
2. src/features/checkout/src/types/index.ts
|
|
108
|
+
Lines 12-15: Type definition changed
|
|
109
|
+
|
|
110
|
+
Options:
|
|
111
|
+
A) Show me the conflicts (I'll help resolve)
|
|
112
|
+
B) Abort rebase, keep original state
|
|
113
|
+
C) Open in VS Code merge tool
|
|
114
|
+
|
|
115
|
+
Choose: (a/b/c)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Step 4: Resolve Conflicts (If Needed)
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
════════════════════════════════════════════════════════════════
|
|
122
|
+
CONFLICT: PackagesV2.tsx (lines 45-67)
|
|
123
|
+
════════════════════════════════════════════════════════════════
|
|
124
|
+
|
|
125
|
+
<<<<<<< HEAD (your changes)
|
|
126
|
+
const lineItems = getModifiedLineItems(
|
|
127
|
+
rawLineItems,
|
|
128
|
+
false,
|
|
129
|
+
rent_frictionless_checkout_v2,
|
|
130
|
+
countryAlpha2
|
|
131
|
+
);
|
|
132
|
+
=======
|
|
133
|
+
const lineItems = rawLineItems.map(item => ({
|
|
134
|
+
...item,
|
|
135
|
+
displayName: item.display_name || item.name
|
|
136
|
+
}));
|
|
137
|
+
>>>>>>> origin/master
|
|
138
|
+
|
|
139
|
+
Analysis:
|
|
140
|
+
- Your version: Uses helper function (cleaner)
|
|
141
|
+
- Master version: Inline mapping (simpler but duplicative)
|
|
142
|
+
|
|
143
|
+
Recommendation: Keep YOUR version (helper function)
|
|
144
|
+
Reason: Follows DRY principle, helper already handles edge cases
|
|
145
|
+
|
|
146
|
+
Apply recommendation? (y/n)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Step 5: Complete & Push
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# After conflicts resolved
|
|
153
|
+
git add -A
|
|
154
|
+
git rebase --continue
|
|
155
|
+
git push --force-with-lease origin HEAD
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## CI Re-run
|
|
159
|
+
|
|
160
|
+
After successful rebase:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
✅ Rebase complete
|
|
164
|
+
✅ Pushed to origin
|
|
165
|
+
|
|
166
|
+
CI Status:
|
|
167
|
+
⏳ Waiting for CI to start...
|
|
168
|
+
🔄 Running: lint, test, build
|
|
169
|
+
|
|
170
|
+
I'll notify you when CI completes.
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Commands Reference
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Check rebase status
|
|
177
|
+
git status
|
|
178
|
+
|
|
179
|
+
# View conflicts
|
|
180
|
+
git diff --name-only --diff-filter=U
|
|
181
|
+
|
|
182
|
+
# Abort if needed
|
|
183
|
+
git rebase --abort
|
|
184
|
+
|
|
185
|
+
# Force push after rebase
|
|
186
|
+
git push --force-with-lease origin HEAD
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Safety Features
|
|
190
|
+
|
|
191
|
+
1. **Stash before rebase** - Never lose local changes
|
|
192
|
+
2. **force-with-lease** - Prevents overwriting others' work
|
|
193
|
+
3. **Conflict preview** - Shows what will conflict before attempting
|
|
194
|
+
4. **Easy abort** - Can always return to original state
|
|
195
|
+
|
|
196
|
+
## Integration with /full-flow
|
|
197
|
+
|
|
198
|
+
During state detection:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
════════════════════════════════════════════════════════════════
|
|
202
|
+
STATE DETECTION
|
|
203
|
+
════════════════════════════════════════════════════════════════
|
|
204
|
+
|
|
205
|
+
Branch: ✅ TICKET-123-display-name-charges
|
|
206
|
+
Commits: ✅ 3 commits ahead
|
|
207
|
+
Behind Master: ⚠️ 12 commits behind
|
|
208
|
+
PR: ✅ #23043 (draft)
|
|
209
|
+
|
|
210
|
+
⚠️ Your branch is behind master. Rebase recommended before continuing.
|
|
211
|
+
|
|
212
|
+
Auto-rebase now? (y/n)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Best Practices
|
|
216
|
+
|
|
217
|
+
1. **Rebase frequently** - Don't let branch drift too far
|
|
218
|
+
2. **Rebase before review** - Fresh code is easier to review
|
|
219
|
+
3. **Rebase after review** - Incorporate latest changes before merge
|
|
220
|
+
4. **Never rebase shared branches** - Only your feature branches
|