@slamb2k/mad-skills 2.0.6 → 2.0.8
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/.claude-plugin/marketplace.json +30 -0
- package/.claude-plugin/plugin.json +18 -0
- package/README.md +101 -25
- package/agents/ship-analyzer.md +91 -0
- package/hooks/hooks.json +18 -0
- package/hooks/session-guard-prompt.sh +59 -0
- package/hooks/session-guard.sh +406 -0
- package/package.json +6 -7
- package/skills/brace/SKILL.md +243 -17
- package/skills/brace/assets/gitignore-template +0 -3
- package/skills/brace/references/phase-prompts.md +37 -0
- package/skills/brace/references/report-template.md +5 -1
- package/skills/build/SKILL.md +295 -16
- package/skills/distil/SKILL.md +261 -10
- package/skills/manifest.json +26 -16
- package/skills/prime/SKILL.md +79 -11
- package/skills/rig/SKILL.md +168 -10
- package/skills/ship/SKILL.md +193 -22
- package/skills/speccy/SKILL.md +165 -0
- package/skills/speccy/references/interview-guide.md +96 -0
- package/skills/speccy/tests/evals.json +34 -0
- package/skills/sync/SKILL.md +178 -20
- package/skills/brace/instructions.md +0 -229
- package/skills/build/instructions.md +0 -293
- package/skills/distil/instructions.md +0 -255
- package/skills/prime/instructions.md +0 -73
- package/skills/rig/instructions.md +0 -162
- package/skills/ship/instructions.md +0 -192
- package/skills/sync/instructions.md +0 -178
- package/src/cli.js +0 -419
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: speccy
|
|
3
|
+
description: Deep-dive interview skill for creating comprehensive specifications. Reviews existing code and docs, then interviews the user through multiple rounds of targeted questions covering technical implementation, UI/UX, concerns, and tradeoffs. Produces a structured spec via create-specification. Use when starting a new feature, system, or major change that needs a spec.
|
|
4
|
+
argument-hint: Goal, feature, or high-level description to specify
|
|
5
|
+
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Speccy - Interview-Driven Specification Builder
|
|
9
|
+
|
|
10
|
+
When this skill is invoked, IMMEDIATELY output the banner below before doing anything else.
|
|
11
|
+
Pick ONE tagline at random — vary your choice each time.
|
|
12
|
+
CRITICAL: Reproduce the banner EXACTLY character-for-character. The first line of the art has 4 leading spaces — you MUST preserve them.
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
{tagline}
|
|
16
|
+
|
|
17
|
+
⠀ ██╗███████╗██████╗ ███████╗ ██████╗ ██████╗██╗ ██╗
|
|
18
|
+
██╔╝██╔════╝██╔══██╗██╔════╝██╔════╝██╔════╝╚██╗ ██╔╝
|
|
19
|
+
██╔╝ ███████╗██████╔╝█████╗ ██║ ██║ ╚████╔╝
|
|
20
|
+
██╔╝ ╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ╚██╔╝
|
|
21
|
+
██╔╝ ███████║██║ ███████╗╚██████╗╚██████╗ ██║
|
|
22
|
+
╚═╝ ╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Taglines:
|
|
26
|
+
- 🔍 Tell me everything...
|
|
27
|
+
- 🧠 Let's think this through!
|
|
28
|
+
- 📋 Spec it before you wreck it!
|
|
29
|
+
- 🎤 Interview mode: ACTIVATED
|
|
30
|
+
- 💡 Great specs start with great questions!
|
|
31
|
+
- 🏗️ Measure twice, code once!
|
|
32
|
+
- 📝 No assumption left behind!
|
|
33
|
+
- 🎯 Precision engineering starts here!
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Interview the user through multiple rounds of targeted questions to build
|
|
38
|
+
a comprehensive specification. Then hand off to the `create-specification`
|
|
39
|
+
skill to produce the final structured spec document.
|
|
40
|
+
|
|
41
|
+
Interview prompts and question guidelines: `references/interview-guide.md`
|
|
42
|
+
|
|
43
|
+
## Pre-flight
|
|
44
|
+
|
|
45
|
+
Before starting, check all dependencies in this table:
|
|
46
|
+
|
|
47
|
+
| Dependency | Type | Check | Required | Resolution | Detail |
|
|
48
|
+
|-----------|------|-------|----------|------------|--------|
|
|
49
|
+
| create-specification | skill | `~/.claude/skills/create-specification/SKILL.md` or `~/.agents/skills/create-specification/SKILL.md` | yes | ask | This skill is needed to format the final spec. Install with: `npx skills add slamb2k/mad-skills --skill create-specification` |
|
|
50
|
+
|
|
51
|
+
For each row, in order:
|
|
52
|
+
1. Test file existence (check both paths for symlinked skills)
|
|
53
|
+
2. If found: continue silently
|
|
54
|
+
3. If missing: apply Resolution strategy
|
|
55
|
+
- **ask**: Notify user the skill is missing, offer to install it. If they
|
|
56
|
+
decline, halt execution — the final spec cannot be produced without it.
|
|
57
|
+
4. After all checks: proceed to context gathering
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Stage 1: Context Gathering
|
|
62
|
+
|
|
63
|
+
Before asking any questions, build a thorough understanding of the project:
|
|
64
|
+
|
|
65
|
+
1. **Capture GOAL** — the user's argument describing what needs to be specified
|
|
66
|
+
2. **Scan the project**:
|
|
67
|
+
- Read `CLAUDE.md` if present (project conventions, structure, domain)
|
|
68
|
+
- Read goal/spec manifests: `goals/manifest.md`, `spec/` directory
|
|
69
|
+
- Scan existing specs and design docs for context
|
|
70
|
+
- Read relevant source code that relates to the GOAL
|
|
71
|
+
- Check memory for prior decisions or open questions related to the GOAL
|
|
72
|
+
3. **Identify knowledge gaps** — what must you learn from the user to write
|
|
73
|
+
a complete, unambiguous specification?
|
|
74
|
+
|
|
75
|
+
Group gaps into interview categories:
|
|
76
|
+
- **Architecture & Technical Design** — stack, patterns, data flow, integrations
|
|
77
|
+
- **Requirements & Scope** — what's in, what's out, must-haves vs nice-to-haves
|
|
78
|
+
- **UI & UX** — user flows, interaction patterns, accessibility, responsive
|
|
79
|
+
- **Security & Auth** — authentication, authorization, data protection
|
|
80
|
+
- **Infrastructure & Deployment** — hosting, CI/CD, environments, IaC
|
|
81
|
+
- **Data & Storage** — schemas, persistence, migrations, caching
|
|
82
|
+
- **Testing & Quality** — test strategy, coverage, acceptance criteria
|
|
83
|
+
- **Concerns & Tradeoffs** — known risks, alternatives considered, constraints
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Stage 2: Interview Rounds
|
|
88
|
+
|
|
89
|
+
Conduct multiple rounds of questions using `AskUserQuestion`. Continue until
|
|
90
|
+
all knowledge gaps are resolved.
|
|
91
|
+
|
|
92
|
+
### Question Rules
|
|
93
|
+
|
|
94
|
+
1. **4 questions per round maximum** (AskUserQuestion limit)
|
|
95
|
+
2. **Non-obvious questions only** — don't ask things you can determine from
|
|
96
|
+
reading the code or docs. The user's time is valuable.
|
|
97
|
+
3. **Recommendations** — where you have an informed opinion based on the
|
|
98
|
+
codebase, project conventions, or industry best practice, mark one option
|
|
99
|
+
as recommended by listing it first and appending `(Recommended)` to its label.
|
|
100
|
+
At least one question per round should have a recommendation where possible.
|
|
101
|
+
4. **Concise options** — 2-4 options per question, each with a clear
|
|
102
|
+
description of implications and tradeoffs
|
|
103
|
+
5. **Progressive depth** — start with high-level architecture and scope,
|
|
104
|
+
then drill into implementation details in later rounds
|
|
105
|
+
6. **Build on answers** — use previous round answers to inform next questions.
|
|
106
|
+
Don't re-ask decided topics.
|
|
107
|
+
7. **Track decisions** — maintain a running list of all decisions made.
|
|
108
|
+
Present this list at the start of each round so the user can see progress.
|
|
109
|
+
|
|
110
|
+
### Round Structure
|
|
111
|
+
|
|
112
|
+
Each round follows this pattern:
|
|
113
|
+
|
|
114
|
+
1. **Progress update** — brief summary of decisions made so far (after round 1)
|
|
115
|
+
2. **Category label** — which interview category this round covers
|
|
116
|
+
3. **Questions** — 3-4 targeted questions via AskUserQuestion
|
|
117
|
+
4. **Evaluate** — after answers, determine if more questions are needed
|
|
118
|
+
|
|
119
|
+
### Completion Criteria
|
|
120
|
+
|
|
121
|
+
Stop interviewing when ALL of the following are true:
|
|
122
|
+
- All identified knowledge gaps have been addressed
|
|
123
|
+
- No answer has raised new unresolved questions
|
|
124
|
+
- You have enough information to write every section of the spec template
|
|
125
|
+
- The user has confirmed scope boundaries (what's in and what's out)
|
|
126
|
+
|
|
127
|
+
When complete, briefly present a **Decision Summary** — a numbered list of
|
|
128
|
+
all decisions made across all rounds — and confirm with the user before
|
|
129
|
+
proceeding to spec generation.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Stage 3: Generate Specification
|
|
134
|
+
|
|
135
|
+
Once the interview is complete and decisions are confirmed:
|
|
136
|
+
|
|
137
|
+
1. **Invoke the `create-specification` skill** using the Skill tool:
|
|
138
|
+
```
|
|
139
|
+
Skill(skill: "create-specification")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
2. **Provide the full context** to the skill as input:
|
|
143
|
+
- The original GOAL
|
|
144
|
+
- All decisions from the interview rounds
|
|
145
|
+
- Any relevant code/architecture context discovered in Stage 1
|
|
146
|
+
- The spec purpose should match the GOAL description
|
|
147
|
+
|
|
148
|
+
3. The `create-specification` skill will handle formatting, naming, and
|
|
149
|
+
saving the spec file according to its own template and conventions.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Output
|
|
154
|
+
|
|
155
|
+
After the spec is created, report to the user:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
Spec complete!
|
|
159
|
+
|
|
160
|
+
File: {spec file path}
|
|
161
|
+
Sections: {count of sections written}
|
|
162
|
+
Decisions: {count of interview decisions captured}
|
|
163
|
+
Rounds: {count of interview rounds conducted}
|
|
164
|
+
Questions: {total questions asked}
|
|
165
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Interview Guide
|
|
2
|
+
|
|
3
|
+
Reference material for conducting effective specification interviews.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Question Categories & Example Topics
|
|
8
|
+
|
|
9
|
+
### Architecture & Technical Design
|
|
10
|
+
- Compute model (serverless vs hosted vs edge)
|
|
11
|
+
- Frontend framework and rendering strategy
|
|
12
|
+
- API design (REST vs GraphQL, versioning)
|
|
13
|
+
- State management approach
|
|
14
|
+
- Caching strategy
|
|
15
|
+
- Real-time requirements (WebSockets, SSE, polling)
|
|
16
|
+
- Monorepo vs multi-repo structure
|
|
17
|
+
|
|
18
|
+
### Requirements & Scope
|
|
19
|
+
- Core user stories and acceptance criteria
|
|
20
|
+
- Feature phasing (MVP vs full implementation)
|
|
21
|
+
- Must-have vs nice-to-have features
|
|
22
|
+
- Known limitations or explicit non-goals
|
|
23
|
+
- Backward compatibility requirements
|
|
24
|
+
|
|
25
|
+
### UI & UX
|
|
26
|
+
- Navigation model (wizard, tabs, SPA routing)
|
|
27
|
+
- Theme and visual design (light/dark, brand)
|
|
28
|
+
- Component library choice
|
|
29
|
+
- Responsive and mobile requirements
|
|
30
|
+
- Accessibility standards (WCAG level)
|
|
31
|
+
- Loading states and error presentation
|
|
32
|
+
- Dashboard and data visualisation approach
|
|
33
|
+
|
|
34
|
+
### Security & Auth
|
|
35
|
+
- Authentication method (SSO, OAuth, API keys)
|
|
36
|
+
- Authorization model (RBAC, ABAC, per-resource)
|
|
37
|
+
- Data sensitivity and encryption requirements
|
|
38
|
+
- Audit logging needs
|
|
39
|
+
- Session management
|
|
40
|
+
|
|
41
|
+
### Infrastructure & Deployment
|
|
42
|
+
- Hosting platform (Azure, AWS, GCP, self-hosted)
|
|
43
|
+
- IaC tooling (Bicep, Terraform, Pulumi)
|
|
44
|
+
- CI/CD pipeline design
|
|
45
|
+
- Environment strategy (dev, staging, prod)
|
|
46
|
+
- Monitoring and alerting
|
|
47
|
+
- Cost constraints
|
|
48
|
+
|
|
49
|
+
### Data & Storage
|
|
50
|
+
- Primary data store (SQL, NoSQL, blob, file)
|
|
51
|
+
- Data retention and lifecycle policies
|
|
52
|
+
- Migration strategy
|
|
53
|
+
- Caching layers
|
|
54
|
+
- Data import/export formats
|
|
55
|
+
|
|
56
|
+
### Testing & Quality
|
|
57
|
+
- Test framework and tooling
|
|
58
|
+
- Coverage targets
|
|
59
|
+
- Integration and E2E test approach
|
|
60
|
+
- Performance testing requirements
|
|
61
|
+
- Linting and formatting standards
|
|
62
|
+
|
|
63
|
+
### Concerns & Tradeoffs
|
|
64
|
+
- Known technical risks
|
|
65
|
+
- Alternatives considered and why rejected
|
|
66
|
+
- Performance vs complexity tradeoffs
|
|
67
|
+
- Build vs buy decisions
|
|
68
|
+
- Technical debt acceptance
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Anti-Patterns to Avoid
|
|
73
|
+
|
|
74
|
+
- **Don't ask what you can read** — if the codebase already answers it, don't ask
|
|
75
|
+
- **Don't ask leading questions** — present options neutrally (except recommendations)
|
|
76
|
+
- **Don't ask compound questions** — one decision per question
|
|
77
|
+
- **Don't ask about implementation details too early** — architecture first
|
|
78
|
+
- **Don't assume technology** — let the user confirm even if it seems obvious
|
|
79
|
+
- **Don't skip the "why"** — understanding rationale prevents spec rot
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Recommendation Guidelines
|
|
84
|
+
|
|
85
|
+
When marking an option as `(Recommended)`:
|
|
86
|
+
|
|
87
|
+
1. **Base it on evidence** — codebase patterns, project conventions, or the
|
|
88
|
+
specific constraints you've discovered
|
|
89
|
+
2. **Explain why in the description** — the recommendation reason should be
|
|
90
|
+
clear from the option's description text
|
|
91
|
+
3. **Don't force it** — if you genuinely don't have a strong opinion, don't
|
|
92
|
+
recommend. Quality over quantity.
|
|
93
|
+
4. **Respect existing choices** — if the project already uses a technology
|
|
94
|
+
or pattern, recommending consistency is usually right
|
|
95
|
+
5. **Consider the user's context** — team size, timeline, and expertise
|
|
96
|
+
matter more than theoretical best practice
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "speccy-invocation-banner",
|
|
4
|
+
"prompt": "Run the speccy skill with no arguments",
|
|
5
|
+
"assertions": [
|
|
6
|
+
{
|
|
7
|
+
"type": "contains",
|
|
8
|
+
"value": "SPECCY"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "contains",
|
|
12
|
+
"value": "██"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "speccy-interview-categories",
|
|
18
|
+
"prompt": "What question categories does the speccy skill use?",
|
|
19
|
+
"assertions": [
|
|
20
|
+
{
|
|
21
|
+
"type": "contains",
|
|
22
|
+
"value": "Architecture"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "contains",
|
|
26
|
+
"value": "Requirements"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "contains",
|
|
30
|
+
"value": "Security"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
package/skills/sync/SKILL.md
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sync
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
uncommitted changes, fetches and pulls origin/main, restores stash, and cleans
|
|
7
|
-
up stale local branches (merged or with deleted remotes). Invoke when switching
|
|
8
|
-
contexts or preparing for new feature work.
|
|
3
|
+
description: Sync local repository with origin/main. Use before starting new work, after completing a PR, or when needing latest upstream changes. Safely stashes uncommitted changes, fetches and pulls origin/main, restores stash, and cleans up stale local branches (merged or with deleted remotes). Invoke when switching contexts or preparing for new feature work.
|
|
4
|
+
argument-hint: --no-stash, --no-cleanup, --no-rebase (optional flags)
|
|
5
|
+
allowed-tools: Bash
|
|
9
6
|
---
|
|
10
7
|
|
|
11
8
|
# Sync - Repository Synchronization
|
|
12
9
|
|
|
13
10
|
When this skill is invoked, IMMEDIATELY output the banner below before doing anything else.
|
|
14
|
-
Pick ONE tagline at random — vary your choice each time
|
|
11
|
+
Pick ONE tagline at random — vary your choice each time.
|
|
12
|
+
CRITICAL: Reproduce the banner EXACTLY character-for-character. The first line of the art has 4 leading spaces — you MUST preserve them.
|
|
15
13
|
|
|
16
14
|
```
|
|
17
15
|
{tagline}
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
⠀ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗
|
|
20
18
|
██╔╝██╔════╝╚██╗ ██╔╝████╗ ██║██╔════╝
|
|
21
19
|
██╔╝ ███████╗ ╚████╔╝ ██╔██╗ ██║██║
|
|
22
20
|
██╔╝ ╚════██║ ╚██╔╝ ██║╚██╗██║██║
|
|
23
21
|
██╔╝ ███████║ ██║ ██║ ╚████║╚██████╗
|
|
24
22
|
╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝
|
|
25
|
-
|
|
26
23
|
```
|
|
27
24
|
|
|
28
25
|
Taglines:
|
|
@@ -35,20 +32,181 @@ Taglines:
|
|
|
35
32
|
- 🔁 Rebase, merge, rinse, repeat!
|
|
36
33
|
- 🎬 Previously on main...
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Subagent Architecture
|
|
35
|
+
---
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
in the subagent context; the primary agent only sees the structured SYNC_REPORT.
|
|
37
|
+
Synchronize local repository with the remote default branch using a single
|
|
38
|
+
Bash subagent to isolate all git operations from the primary conversation.
|
|
45
39
|
|
|
46
40
|
## Flags
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
- `--no-
|
|
50
|
-
- `--no-
|
|
42
|
+
Parse optional flags from the request:
|
|
43
|
+
- `--no-stash`: Don't auto-stash uncommitted changes
|
|
44
|
+
- `--no-cleanup`: Don't delete stale local branches
|
|
45
|
+
- `--no-rebase`: Use merge instead of rebase when on a feature branch
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Pre-flight
|
|
50
|
+
|
|
51
|
+
Before starting, check all dependencies in this table:
|
|
52
|
+
|
|
53
|
+
| Dependency | Type | Check | Required | Resolution | Detail |
|
|
54
|
+
|-----------|------|-------|----------|------------|--------|
|
|
55
|
+
| git | cli | `git --version` | yes | stop | Install from https://git-scm.com |
|
|
56
|
+
|
|
57
|
+
For each row, in order:
|
|
58
|
+
1. Run the Check command (for cli/npm) or test file existence (for agent/skill)
|
|
59
|
+
2. If found: continue silently
|
|
60
|
+
3. If missing: apply Resolution strategy
|
|
61
|
+
- **stop**: notify user with Detail, halt execution
|
|
62
|
+
- **url**: notify user with Detail (install link), halt execution
|
|
63
|
+
- **install**: notify user, run the command in Detail, continue if successful
|
|
64
|
+
- **ask**: notify user, offer to run command in Detail, continue either way (or halt if required)
|
|
65
|
+
- **fallback**: notify user with Detail, continue with degraded behavior
|
|
66
|
+
4. After all checks: summarize what's available and what's degraded
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Pre-flight Detection
|
|
71
|
+
|
|
72
|
+
Before launching the subagent, detect the remote and default branch:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
REMOTE=$(git remote | head -1) # usually "origin"
|
|
76
|
+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/$REMOTE/HEAD 2>/dev/null | sed 's|.*/||')
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Fallback chain if `symbolic-ref` fails:
|
|
80
|
+
1. Check `git show-ref --verify refs/heads/main` → use `main`
|
|
81
|
+
2. Check `git show-ref --verify refs/heads/master` → use `master`
|
|
82
|
+
3. If neither exists, report error and stop
|
|
83
|
+
|
|
84
|
+
Pass `{REMOTE}` and `{DEFAULT_BRANCH}` into the subagent prompt.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Execution
|
|
89
|
+
|
|
90
|
+
Launch a **Bash subagent** (haiku — pure git commands, no code analysis needed):
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Task(
|
|
94
|
+
subagent_type: "Bash",
|
|
95
|
+
model: "haiku",
|
|
96
|
+
description: "Sync repo with {DEFAULT_BRANCH}",
|
|
97
|
+
prompt: <see prompt below>
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Subagent Prompt
|
|
51
102
|
|
|
52
|
-
|
|
103
|
+
```
|
|
104
|
+
Synchronize this git repository with {REMOTE}/{DEFAULT_BRANCH}. Execute the
|
|
105
|
+
following steps in order and report results.
|
|
106
|
+
|
|
107
|
+
Limit SYNC_REPORT to 15 lines maximum.
|
|
108
|
+
|
|
109
|
+
FLAGS: {flags from request, or "none"}
|
|
110
|
+
|
|
111
|
+
## Steps
|
|
112
|
+
|
|
113
|
+
1. **Check state**
|
|
114
|
+
BRANCH=$(git branch --show-current 2>/dev/null || echo "DETACHED")
|
|
115
|
+
CHANGES=$(git status --porcelain | head -20)
|
|
116
|
+
Record: current_branch=$BRANCH, has_changes=(non-empty CHANGES)
|
|
117
|
+
|
|
118
|
+
If BRANCH == "DETACHED":
|
|
119
|
+
Record error: "Detached HEAD — cannot sync. Checkout a branch first."
|
|
120
|
+
Skip to Output.
|
|
121
|
+
|
|
122
|
+
2. **Stash changes** (skip if --no-stash or no changes)
|
|
123
|
+
If has_changes and not --no-stash:
|
|
124
|
+
git stash push -m "sync-auto-stash-$(date +%Y%m%d-%H%M%S)"
|
|
125
|
+
Record: stash_created=true
|
|
126
|
+
|
|
127
|
+
3. **Sync {DEFAULT_BRANCH}**
|
|
128
|
+
git fetch {REMOTE}
|
|
129
|
+
If BRANCH != "{DEFAULT_BRANCH}":
|
|
130
|
+
git checkout {DEFAULT_BRANCH}
|
|
131
|
+
git pull {REMOTE} {DEFAULT_BRANCH} --ff-only
|
|
132
|
+
If pull fails (diverged):
|
|
133
|
+
git pull {REMOTE} {DEFAULT_BRANCH} --rebase
|
|
134
|
+
Record: main_commit=$(git rev-parse --short HEAD)
|
|
135
|
+
Record: main_message=$(git log -1 --format=%s)
|
|
136
|
+
|
|
137
|
+
4. **Return to branch and update** (skip if already on {DEFAULT_BRANCH})
|
|
138
|
+
If current_branch != "{DEFAULT_BRANCH}":
|
|
139
|
+
git checkout $BRANCH
|
|
140
|
+
If --no-rebase:
|
|
141
|
+
git merge {DEFAULT_BRANCH} --no-edit
|
|
142
|
+
Else:
|
|
143
|
+
git rebase {DEFAULT_BRANCH}
|
|
144
|
+
If rebase fails:
|
|
145
|
+
git rebase --abort
|
|
146
|
+
Record: rebase_status="conflict — aborted, branch unchanged"
|
|
147
|
+
|
|
148
|
+
5. **Restore stash** (if created in step 2)
|
|
149
|
+
If stash_created:
|
|
150
|
+
git stash pop
|
|
151
|
+
If pop fails (conflict):
|
|
152
|
+
Record: stash="conflict — run 'git stash show' to inspect"
|
|
153
|
+
Else:
|
|
154
|
+
Record: stash="restored"
|
|
155
|
+
|
|
156
|
+
6. **Cleanup branches** (skip if --no-cleanup)
|
|
157
|
+
git fetch --prune
|
|
158
|
+
|
|
159
|
+
# Delete branches whose remote is gone
|
|
160
|
+
for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do
|
|
161
|
+
if [ "$branch" != "$BRANCH" ]; then
|
|
162
|
+
git branch -d "$branch" 2>/dev/null && echo "Deleted: $branch"
|
|
163
|
+
fi
|
|
164
|
+
done
|
|
165
|
+
|
|
166
|
+
# Delete branches fully merged into {DEFAULT_BRANCH} (except current)
|
|
167
|
+
for branch in $(git branch --merged {DEFAULT_BRANCH} | grep -v '^\*' | grep -v '{DEFAULT_BRANCH}'); do
|
|
168
|
+
branch=$(echo "$branch" | xargs)
|
|
169
|
+
if [ "$branch" != "$BRANCH" ] && [ -n "$branch" ]; then
|
|
170
|
+
git branch -d "$branch" 2>/dev/null && echo "Deleted: $branch"
|
|
171
|
+
fi
|
|
172
|
+
done
|
|
173
|
+
|
|
174
|
+
Record: branches_cleaned={list of deleted branches, or "none"}
|
|
175
|
+
|
|
176
|
+
7. **Final state**
|
|
177
|
+
echo "Branch: $(git branch --show-current)"
|
|
178
|
+
echo "HEAD: $(git log -1 --format='%h %s')"
|
|
179
|
+
echo "Status: $(git status --short | wc -l) modified files"
|
|
180
|
+
|
|
181
|
+
## Output Format
|
|
182
|
+
|
|
183
|
+
SYNC_REPORT:
|
|
184
|
+
- status: success|failed
|
|
185
|
+
- remote: {REMOTE}
|
|
186
|
+
- default_branch: {DEFAULT_BRANCH}
|
|
187
|
+
- main_updated_to: {commit} - {message}
|
|
188
|
+
- current_branch: {branch}
|
|
189
|
+
- stash: restored|none|conflict
|
|
190
|
+
- rebase: success|conflict|skipped
|
|
191
|
+
- branches_cleaned: {list or "none"}
|
|
192
|
+
- errors: {any errors encountered}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Report to User
|
|
198
|
+
|
|
199
|
+
Parse the subagent's SYNC_REPORT and present a clean summary:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
Sync complete
|
|
203
|
+
Main: {commit} - {message}
|
|
204
|
+
Branch: {current_branch}
|
|
205
|
+
Stash: {status}
|
|
206
|
+
Cleaned: {branches or "none"}
|
|
207
|
+
```
|
|
53
208
|
|
|
54
|
-
|
|
209
|
+
If errors occurred, report them clearly with suggested resolution:
|
|
210
|
+
- Detached HEAD → suggest `git checkout <branch>`
|
|
211
|
+
- Rebase conflict → suggest `git rebase {DEFAULT_BRANCH}` manually and resolve
|
|
212
|
+
- Stash conflict → suggest `git stash show` and `git stash pop` manually
|