superkit-mcp-server 1.1.3 → 1.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/SUPERKIT.md +4 -4
- package/build/index.js +30 -19
- package/commands/README.md +122 -0
- package/commands/ask.toml +72 -0
- package/commands/brainstorm.toml +120 -0
- package/commands/chat.toml +73 -0
- package/commands/code-preview.toml +38 -0
- package/commands/code.toml +29 -0
- package/commands/content.toml +201 -0
- package/commands/cook.toml +78 -0
- package/commands/copywrite.toml +132 -0
- package/commands/db.toml +193 -0
- package/commands/debug.toml +167 -0
- package/commands/design.toml +159 -0
- package/commands/dev-rules.toml +14 -0
- package/commands/do.toml +117 -0
- package/commands/doc-rules.toml +14 -0
- package/commands/docs.toml +148 -0
- package/commands/fix.toml +440 -0
- package/commands/fullstack.toml +176 -0
- package/commands/git.toml +236 -0
- package/commands/help.toml +84 -0
- package/commands/integrate.toml +127 -0
- package/commands/journal.toml +137 -0
- package/commands/kit-setup.toml +41 -0
- package/commands/mcp.toml +183 -0
- package/commands/orchestration.toml +15 -0
- package/commands/plan.toml +172 -0
- package/commands/pm.toml +149 -0
- package/commands/pr.toml +51 -0
- package/commands/project.toml +33 -0
- package/commands/research.toml +118 -0
- package/commands/review-pr.toml +64 -0
- package/commands/review.toml +191 -0
- package/commands/scout-ext.toml +97 -0
- package/commands/scout.toml +80 -0
- package/commands/screenshot.toml +65 -0
- package/commands/session.toml +98 -0
- package/commands/skill.toml +385 -0
- package/commands/status.toml +23 -0
- package/commands/team.toml +56 -0
- package/commands/test.toml +165 -0
- package/commands/ticket.toml +71 -0
- package/commands/use.toml +106 -0
- package/commands/video.toml +84 -0
- package/commands/watzup.toml +71 -0
- package/commands/workflow.toml +14 -0
- package/package.json +4 -2
- package/{workflows → skills/workflows}/README.md +3 -3
- package/{workflows → skills/workflows}/development-rules.md +5 -0
- package/{workflows → skills/workflows}/documentation-management.md +5 -0
- package/{workflows → skills/workflows}/orchestration-protocol.md +5 -0
- package/{workflows → skills/workflows}/primary-workflow.md +5 -0
- /package/{workflows → skills/workflows}/adr.md +0 -0
- /package/{workflows → skills/workflows}/changelog.md +0 -0
- /package/{workflows → skills/workflows}/compound.md +0 -0
- /package/{workflows → skills/workflows}/compound_health.md +0 -0
- /package/{workflows → skills/workflows}/create-agent-skill.md +0 -0
- /package/{workflows → skills/workflows}/cycle.md +0 -0
- /package/{workflows → skills/workflows}/deploy-docs.md +0 -0
- /package/{workflows → skills/workflows}/doc.md +0 -0
- /package/{workflows → skills/workflows}/explore.md +0 -0
- /package/{workflows → skills/workflows}/generate_command.md +0 -0
- /package/{workflows → skills/workflows}/heal-skill.md +0 -0
- /package/{workflows → skills/workflows}/housekeeping.md +0 -0
- /package/{workflows → skills/workflows}/kit-setup.md +0 -0
- /package/{workflows → skills/workflows}/map-codebase.md +0 -0
- /package/{workflows → skills/workflows}/plan-compound.md +0 -0
- /package/{workflows → skills/workflows}/plan_review.md +0 -0
- /package/{workflows → skills/workflows}/promote_pattern.md +0 -0
- /package/{workflows → skills/workflows}/release-docs.md +0 -0
- /package/{workflows → skills/workflows}/report-bug.md +0 -0
- /package/{workflows → skills/workflows}/reproduce-bug.md +0 -0
- /package/{workflows → skills/workflows}/resolve_pr.md +0 -0
- /package/{workflows → skills/workflows}/resolve_todo.md +0 -0
- /package/{workflows → skills/workflows}/review-compound.md +0 -0
- /package/{workflows → skills/workflows}/skill-review.md +0 -0
- /package/{workflows → skills/workflows}/specs.md +0 -0
- /package/{workflows → skills/workflows}/triage-sprint.md +0 -0
- /package/{workflows → skills/workflows}/triage.md +0 -0
- /package/{workflows → skills/workflows}/work.md +0 -0
- /package/{workflows → skills/workflows}/xcode-test.md +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# `/content` - Marketing Content Generator
|
|
2
|
+
|
|
3
|
+
description = "Create marketing content with A/B variants and CRO (Content Agent)"
|
|
4
|
+
|
|
5
|
+
prompt = """
|
|
6
|
+
# ✍️ CONTENT AGENT
|
|
7
|
+
|
|
8
|
+
Create marketing content for:
|
|
9
|
+
|
|
10
|
+
**Task:** {{args}}
|
|
11
|
+
|
|
12
|
+
## CONTENT TYPES
|
|
13
|
+
Based on context, create suitable content type:
|
|
14
|
+
|
|
15
|
+
### LANDING PAGE / HERO SECTION
|
|
16
|
+
1. **Headlines** (3 versions)
|
|
17
|
+
- ROI-focused
|
|
18
|
+
- Time-focused
|
|
19
|
+
- Risk-reversal
|
|
20
|
+
2. **Subheadlines** (3 versions)
|
|
21
|
+
3. **Body Copy** (short/medium/long)
|
|
22
|
+
4. **CTAs** (3 versions with urgency)
|
|
23
|
+
5. **Social Proof Suggestions**
|
|
24
|
+
6. **A/B Test Plan**
|
|
25
|
+
|
|
26
|
+
### SOCIAL MEDIA
|
|
27
|
+
#### Twitter/X Thread
|
|
28
|
+
- Hook tweet (stop scroll)
|
|
29
|
+
- 8-12 tweets with flow
|
|
30
|
+
- Engagement CTA
|
|
31
|
+
- Posting schedule
|
|
32
|
+
|
|
33
|
+
#### LinkedIn Post
|
|
34
|
+
- Hook line
|
|
35
|
+
- Data-driven insights
|
|
36
|
+
- Comment strategy
|
|
37
|
+
|
|
38
|
+
### EMAIL CAMPAIGN
|
|
39
|
+
1. **Subject Lines** (5 versions)
|
|
40
|
+
2. **Preview Text**
|
|
41
|
+
3. **Email Body** (personalized)
|
|
42
|
+
4. **CTA Button**
|
|
43
|
+
5. **Follow-up Sequence**
|
|
44
|
+
|
|
45
|
+
### CRO ANALYSIS (if analyzing existing page)
|
|
46
|
+
|
|
47
|
+
When input contains "cro" or "optimize" or "conversion":
|
|
48
|
+
|
|
49
|
+
**5-Step CRO Workflow:**
|
|
50
|
+
|
|
51
|
+
**Step 1: Content Analysis**
|
|
52
|
+
- Read existing content (file, URL, description)
|
|
53
|
+
- Identify conversion goals (signup, purchase, download)
|
|
54
|
+
- Analyze current messaging and CTAs
|
|
55
|
+
- Map user journey and friction points
|
|
56
|
+
|
|
57
|
+
**Step 2: Psychological Analysis**
|
|
58
|
+
| Trigger | Check |
|
|
59
|
+
|---------|-------|
|
|
60
|
+
| Loss Aversion | "Don't miss out..." |
|
|
61
|
+
| Social Proof | "Join 10,000+ users" |
|
|
62
|
+
| Scarcity | "Only 5 left" |
|
|
63
|
+
| Urgency | "Offer ends today" |
|
|
64
|
+
| Authority | "Trusted by Fortune 500" |
|
|
65
|
+
| Reciprocity | "Free guide included" |
|
|
66
|
+
|
|
67
|
+
**Step 3: CRO Audit**
|
|
68
|
+
| Element | Check |
|
|
69
|
+
|---------|-------|
|
|
70
|
+
| Headlines | Clear value proposition? |
|
|
71
|
+
| CTAs | Action-oriented? Visible? |
|
|
72
|
+
| Social Proof | Testimonials? Reviews? |
|
|
73
|
+
| Trust | Badges? Guarantees? |
|
|
74
|
+
| Mobile | Responsive? Fast? |
|
|
75
|
+
|
|
76
|
+
**Step 4: Optimization Recommendations**
|
|
77
|
+
- 3-5 headline variations
|
|
78
|
+
- Improved CTAs
|
|
79
|
+
- Added psychological triggers
|
|
80
|
+
- Enhanced social proof
|
|
81
|
+
|
|
82
|
+
**Step 5: A/B Testing Strategy**
|
|
83
|
+
```
|
|
84
|
+
Test Plan:
|
|
85
|
+
- Control: Current version
|
|
86
|
+
- Variation A: [headline change]
|
|
87
|
+
- Variation B: [CTA change]
|
|
88
|
+
|
|
89
|
+
Metrics: Conversion rate, CTR, Time on page
|
|
90
|
+
Sample size: [calculate]
|
|
91
|
+
Expected lift: [predict]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**CRO Frameworks:**
|
|
95
|
+
- AIDA: Attention → Interest → Desire → Action
|
|
96
|
+
- PAS: Problem → Agitation → Solution
|
|
97
|
+
- Before-After-Bridge
|
|
98
|
+
|
|
99
|
+
## PSYCHOLOGICAL PRINCIPLES
|
|
100
|
+
Apply when writing:
|
|
101
|
+
- FOMO (Fear of Missing Out)
|
|
102
|
+
- Social Proof
|
|
103
|
+
- Scarcity
|
|
104
|
+
- Authority
|
|
105
|
+
- Reciprocity
|
|
106
|
+
|
|
107
|
+
## OUTPUT FORMAT
|
|
108
|
+
Structured markdown with clear sections.
|
|
109
|
+
Ready to use, no editing needed.
|
|
110
|
+
|
|
111
|
+
## METRICS
|
|
112
|
+
Suggested metrics to track:
|
|
113
|
+
- Click-through rate target
|
|
114
|
+
- Conversion rate target
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## ENHANCE MODE
|
|
119
|
+
|
|
120
|
+
When input contains "enhance" or "improve" or "rewrite":
|
|
121
|
+
|
|
122
|
+
**4-Step Enhancement Workflow:**
|
|
123
|
+
|
|
124
|
+
**Step 1: Content Analysis**
|
|
125
|
+
- Read existing content (file, URL, description)
|
|
126
|
+
- Identify content type (blog, docs, marketing)
|
|
127
|
+
- Detect brand voice and tone
|
|
128
|
+
|
|
129
|
+
**Step 2: Multi-Dimensional Audit**
|
|
130
|
+
| Dimension | Check |
|
|
131
|
+
|-----------|-------|
|
|
132
|
+
| Clarity | Message clear? Easy to understand? |
|
|
133
|
+
| Impact | Engages and persuades? |
|
|
134
|
+
| SEO | Optimized for search? |
|
|
135
|
+
| Readability | Easy to read and scan? |
|
|
136
|
+
| Grammar | Errors? Awkward phrasing? |
|
|
137
|
+
| Structure | Well-organized? |
|
|
138
|
+
|
|
139
|
+
**Step 3: Enhancement Recommendations**
|
|
140
|
+
- Clearer headlines/subheadings
|
|
141
|
+
- Stronger opening/closing
|
|
142
|
+
- Improved transitions
|
|
143
|
+
- Better word choices
|
|
144
|
+
- SEO keyword integration
|
|
145
|
+
|
|
146
|
+
**Step 4: Revised Content**
|
|
147
|
+
- Original structure preserved
|
|
148
|
+
- Brand voice maintained
|
|
149
|
+
- Before/after comparison
|
|
150
|
+
|
|
151
|
+
**Common Improvements:**
|
|
152
|
+
```
|
|
153
|
+
# Remove filler words
|
|
154
|
+
Before: "In order to achieve success..."
|
|
155
|
+
After: "To succeed..."
|
|
156
|
+
|
|
157
|
+
# Strengthen verbs
|
|
158
|
+
Before: "We can help you get better results"
|
|
159
|
+
After: "We boost your results"
|
|
160
|
+
|
|
161
|
+
# Active voice
|
|
162
|
+
Before: "The report was written by the team"
|
|
163
|
+
After: "The team wrote the report"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Readability Targets:**
|
|
167
|
+
| Content Type | Flesch Score |
|
|
168
|
+
|--------------|--------------|
|
|
169
|
+
| Marketing | 60-70 |
|
|
170
|
+
| Blog | 50-60 |
|
|
171
|
+
| Technical | 40-50 |
|
|
172
|
+
| Legal | 30-40 |
|
|
173
|
+
|
|
174
|
+
**Output:**
|
|
175
|
+
```markdown
|
|
176
|
+
## Enhancement Report
|
|
177
|
+
|
|
178
|
+
### Before
|
|
179
|
+
[Original content]
|
|
180
|
+
|
|
181
|
+
### After
|
|
182
|
+
[Enhanced content]
|
|
183
|
+
|
|
184
|
+
### Changes Made
|
|
185
|
+
- [Change 1]
|
|
186
|
+
- [Change 2]
|
|
187
|
+
|
|
188
|
+
### Metrics Improvement
|
|
189
|
+
- Readability: 45 → 62
|
|
190
|
+
- Word count: 500 → 420
|
|
191
|
+
```
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
# ---
|
|
195
|
+
# USAGE:
|
|
196
|
+
# /content Hero section for AI analytics SaaS targeting CTOs
|
|
197
|
+
# /content Twitter thread announcing new feature
|
|
198
|
+
# /content Welcome email series for trial users
|
|
199
|
+
# /content Analyze and improve our landing page (attach URL or describe)
|
|
200
|
+
# /content:cro Improve checkout page conversion from 1.2% to 3%
|
|
201
|
+
# ---
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
description = "Run full development workflow with Auto-Checkpoint & Rollback: Plan → Scout → Code → Test → Review"
|
|
2
|
+
|
|
3
|
+
prompt = """
|
|
4
|
+
# 🍳 Super Engineer Workflow (Auto-Safe Mode)
|
|
5
|
+
|
|
6
|
+
You are the **TeamOrchestrator**. Perform the complete development cycle for the task:
|
|
7
|
+
|
|
8
|
+
**Task:** {{args}}
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚠️ IMPORTANT: AUTO-CHECKPOINT & ROLLBACK
|
|
13
|
+
|
|
14
|
+
### Step 0: CREATE CHECKPOINT (MANDATORY)
|
|
15
|
+
**BEFORE DOING ANYTHING**, you MUST:
|
|
16
|
+
|
|
17
|
+
1. Call `kit_create_checkpoint` with the task name
|
|
18
|
+
2. Remember the checkpoint ID
|
|
19
|
+
3. If any step FAILS → call `kit_restore_checkpoint`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Workflow Steps
|
|
24
|
+
|
|
25
|
+
### Step 1: PLAN
|
|
26
|
+
Create a detailed implementation plan:
|
|
27
|
+
- Break down the task into subtasks
|
|
28
|
+
- Identify files to be created/modified
|
|
29
|
+
- List challenges
|
|
30
|
+
- Define success criteria
|
|
31
|
+
|
|
32
|
+
### Step 2: SCOUT
|
|
33
|
+
Analyze the codebase:
|
|
34
|
+
- List the directory structure
|
|
35
|
+
- Read package.json
|
|
36
|
+
- Find relevant files
|
|
37
|
+
|
|
38
|
+
### Step 3: CODE
|
|
39
|
+
Implement the solution:
|
|
40
|
+
- Follow current code style
|
|
41
|
+
- Add error handling
|
|
42
|
+
- Include comments
|
|
43
|
+
|
|
44
|
+
### Step 4: TEST
|
|
45
|
+
Create and run tests:
|
|
46
|
+
- Unit tests for new functions
|
|
47
|
+
- Edge cases
|
|
48
|
+
- If TEST FAILS → **ROLLBACK**
|
|
49
|
+
|
|
50
|
+
### Step 5: REVIEW
|
|
51
|
+
Review the implementation:
|
|
52
|
+
- Check code quality
|
|
53
|
+
- Verify requirements
|
|
54
|
+
- Propose improvements
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🔄 ROLLBACK RULES
|
|
59
|
+
|
|
60
|
+
If any of the following conditions occur, you **MUST** call `kit_restore_checkpoint`:
|
|
61
|
+
|
|
62
|
+
1. ❌ Tests fail and cannot be fixed in 2 attempts
|
|
63
|
+
2. ❌ Build fails
|
|
64
|
+
3. ❌ User says "rollback" or "undo"
|
|
65
|
+
4. ❌ Code causes critical errors
|
|
66
|
+
|
|
67
|
+
**After rollback:**
|
|
68
|
+
- Notify the user
|
|
69
|
+
- Explain why it failed
|
|
70
|
+
- Suggest alternative approaches
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Guidelines
|
|
75
|
+
- **After each step:** Summarize the results
|
|
76
|
+
- **If blocked:** Ask for clarification
|
|
77
|
+
- **Checkpoint ID:** Always remember for rollback
|
|
78
|
+
"""
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
description = "Marketing copy with conversion optimization (Copywriter Agent)"
|
|
2
|
+
|
|
3
|
+
prompt = """
|
|
4
|
+
# ✍️ COPYWRITER AGENT
|
|
5
|
+
|
|
6
|
+
Copy request:
|
|
7
|
+
|
|
8
|
+
**Task:** {{args}}
|
|
9
|
+
|
|
10
|
+
## MODE DETECTION
|
|
11
|
+
|
|
12
|
+
| Mode | Speed | Output |
|
|
13
|
+
|------|-------|--------|
|
|
14
|
+
| **FAST** | 30-60s | Single version, good quality |
|
|
15
|
+
| **GOOD** | 2-4min | Multiple versions + A/B tests |
|
|
16
|
+
| **ENHANCE** | 1-2min | Improve existing copy |
|
|
17
|
+
| **CRO** | 2-4min | Full conversion optimization |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## PLATFORM-SPECIFIC OPTIMIZATION
|
|
22
|
+
|
|
23
|
+
### 🐦 Twitter/X
|
|
24
|
+
- Hook in first 3 words
|
|
25
|
+
- 8-12 tweets per thread
|
|
26
|
+
- 1 visual max
|
|
27
|
+
- No hashtag spam (1-2 max)
|
|
28
|
+
|
|
29
|
+
### 💼 LinkedIn
|
|
30
|
+
- First 2 lines critical (before "see more")
|
|
31
|
+
- Use bullet points
|
|
32
|
+
- Ask questions
|
|
33
|
+
- Professional tone
|
|
34
|
+
|
|
35
|
+
### 📧 Email
|
|
36
|
+
- Subject: 30-50 characters
|
|
37
|
+
- Personal tone
|
|
38
|
+
- Single CTA
|
|
39
|
+
- Mobile-optimized
|
|
40
|
+
|
|
41
|
+
### 🌐 Landing Page
|
|
42
|
+
- Hero headline: 6-12 words
|
|
43
|
+
- CTA every 1.5 screens
|
|
44
|
+
- Social proof near CTA
|
|
45
|
+
- Above-fold value prop
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## OUTPUT FORMAT
|
|
50
|
+
|
|
51
|
+
### 📝 Headlines (3 versions)
|
|
52
|
+
| Version | Focus | Copy |
|
|
53
|
+
|---------|-------|------|
|
|
54
|
+
| A | ROI | [Headline A] |
|
|
55
|
+
| B | Time-saving | [Headline B] |
|
|
56
|
+
| C | Risk-reversal | [Headline C] |
|
|
57
|
+
|
|
58
|
+
### 📝 Subheadlines (3 versions)
|
|
59
|
+
- [Subheadline A]
|
|
60
|
+
- [Subheadline B]
|
|
61
|
+
- [Subheadline C]
|
|
62
|
+
|
|
63
|
+
### 📝 Body Copy
|
|
64
|
+
**Short (50 words):**
|
|
65
|
+
[Copy]
|
|
66
|
+
|
|
67
|
+
**Medium (100 words):**
|
|
68
|
+
[Copy]
|
|
69
|
+
|
|
70
|
+
**Long (200 words):**
|
|
71
|
+
[Copy]
|
|
72
|
+
|
|
73
|
+
### 📝 CTAs (3 versions)
|
|
74
|
+
- [CTA A] - Action focus
|
|
75
|
+
- [CTA B] - Benefit focus
|
|
76
|
+
- [CTA C] - Urgency focus
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## A/B TEST PLAN
|
|
81
|
+
|
|
82
|
+
### Test 1: Headlines
|
|
83
|
+
- **Control:** [Headline A]
|
|
84
|
+
- **Variant:** [Headline B]
|
|
85
|
+
- **Hypothesis:** ROI-focused beats time-focused for CTOs
|
|
86
|
+
- **Metric:** Trial signup rate
|
|
87
|
+
- **Duration:** 2 weeks or 1000 visitors
|
|
88
|
+
|
|
89
|
+
### Test 2: CTAs
|
|
90
|
+
- **Control:** [CTA A]
|
|
91
|
+
- **Variant:** [CTA B]
|
|
92
|
+
- **Metric:** Click-through rate
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## EXPECTED PERFORMANCE
|
|
97
|
+
|
|
98
|
+
| Channel | Metric | Target |
|
|
99
|
+
|---------|--------|--------|
|
|
100
|
+
| Landing Page | Trial signup | 3-5% |
|
|
101
|
+
| Email | Open rate | 40%+ |
|
|
102
|
+
| Email | CTR | 15%+ |
|
|
103
|
+
| Twitter | Engagement | 5-10% |
|
|
104
|
+
| LinkedIn | Engagement | 3-5% |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## CONVERSION PSYCHOLOGY
|
|
109
|
+
|
|
110
|
+
### Triggers Used
|
|
111
|
+
- [ ] **Specificity:** "85% faster" not "much faster"
|
|
112
|
+
- [ ] **Social proof:** Real metrics, real customers
|
|
113
|
+
- [ ] **Urgency:** Limited time/spots
|
|
114
|
+
- [ ] **Risk reversal:** Guarantee, free trial
|
|
115
|
+
- [ ] **Authority:** Awards, certifications
|
|
116
|
+
|
|
117
|
+
### Quality Standards
|
|
118
|
+
- User-centric: Benefits > Features
|
|
119
|
+
- Conversational: "Use" not "Utilize"
|
|
120
|
+
- Single CTA per section
|
|
121
|
+
- Specific numbers always
|
|
122
|
+
|
|
123
|
+
> **Key Takeaway:** Copy that converts. No fluff—just conversion-focused messaging with A/B plans.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
# ---
|
|
127
|
+
# USAGE:
|
|
128
|
+
# /copywrite fast Twitter thread about new feature
|
|
129
|
+
# /copywrite good landing page hero section
|
|
130
|
+
# /copywrite enhance [existing copy text]
|
|
131
|
+
# /copywrite cro landing page 1.2% conversion
|
|
132
|
+
# ---
|
package/commands/db.toml
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
description = "Database admin with health check and optimization (Database Admin Agent)"
|
|
2
|
+
|
|
3
|
+
prompt = """
|
|
4
|
+
# 🗄️ DATABASE ADMIN AGENT
|
|
5
|
+
|
|
6
|
+
Database task:
|
|
7
|
+
|
|
8
|
+
**Task:** {{args}}
|
|
9
|
+
|
|
10
|
+
## MODE DETECTION
|
|
11
|
+
|
|
12
|
+
| Mode | Trigger | Output |
|
|
13
|
+
|------|---------|--------|
|
|
14
|
+
| **QUERY** | "query", "sql" | Optimized SQL + EXPLAIN |
|
|
15
|
+
| **SCHEMA** | "schema", "design" | DDL + indexes + constraints |
|
|
16
|
+
| **OPTIMIZE** | "slow", "optimize" | Index strategy, query rewrite |
|
|
17
|
+
| **HEALTH** | "health", "check" | Full diagnostic report |
|
|
18
|
+
| **BACKUP** | "backup", "recovery" | PITR, WAL, restore |
|
|
19
|
+
| **POOL** | "connection", "pool" | PgBouncer, pooling config |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## OPTIMIZE MODE - Query Performance
|
|
24
|
+
|
|
25
|
+
### EXPLAIN ANALYZE Template
|
|
26
|
+
```sql
|
|
27
|
+
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
|
|
28
|
+
SELECT ...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Optimization Report
|
|
32
|
+
| Metric | Before | After | Improvement |
|
|
33
|
+
|--------|--------|-------|-------------|
|
|
34
|
+
| Execution | 45s | 0.8s | **98% faster** |
|
|
35
|
+
| Rows scanned | 10M | 1K | Index usage |
|
|
36
|
+
| Buffer hits | 20% | 95% | Cache improved |
|
|
37
|
+
|
|
38
|
+
### Index Recommendations
|
|
39
|
+
```sql
|
|
40
|
+
-- Missing index detected
|
|
41
|
+
CREATE INDEX CONCURRENTLY idx_orders_created_at
|
|
42
|
+
ON orders(created_at);
|
|
43
|
+
|
|
44
|
+
-- Covering index for query
|
|
45
|
+
CREATE INDEX idx_users_orders
|
|
46
|
+
ON users(id) INCLUDE (name, email);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## HEALTH MODE - Full Diagnostic
|
|
52
|
+
|
|
53
|
+
### Connection Pool
|
|
54
|
+
```sql
|
|
55
|
+
SELECT count(*), state
|
|
56
|
+
FROM pg_stat_activity
|
|
57
|
+
GROUP BY state;
|
|
58
|
+
```
|
|
59
|
+
| State | Count | Status |
|
|
60
|
+
|-------|-------|--------|
|
|
61
|
+
| Active | 20 | ✅ |
|
|
62
|
+
| Idle | 75 | ⚠️ High |
|
|
63
|
+
| Idle in transaction | 5 | ⚠️ |
|
|
64
|
+
|
|
65
|
+
### Slow Queries (Top 5)
|
|
66
|
+
| Query | Avg Time | Calls |
|
|
67
|
+
|-------|----------|-------|
|
|
68
|
+
| SELECT... | 4.2s | 1200/day |
|
|
69
|
+
|
|
70
|
+
### Missing Indexes
|
|
71
|
+
- FK `orders.user_id` - No index!
|
|
72
|
+
- `users.email` - Frequent WHERE
|
|
73
|
+
|
|
74
|
+
### Table Bloat
|
|
75
|
+
| Table | Size | Bloat | Action |
|
|
76
|
+
|-------|------|-------|--------|
|
|
77
|
+
| orders | 10GB | 30% | VACUUM |
|
|
78
|
+
|
|
79
|
+
### Cache Hit Ratio
|
|
80
|
+
- Buffer: **95%** ✅ (target: >99%)
|
|
81
|
+
- Index: **88%** ⚠️
|
|
82
|
+
|
|
83
|
+
### Action Plan
|
|
84
|
+
1. **Immediate:** Add missing FK indexes
|
|
85
|
+
2. **This week:** VACUUM bloated tables
|
|
86
|
+
3. **This month:** Upgrade connection pool
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## POOL MODE - Connection Management
|
|
91
|
+
|
|
92
|
+
### PgBouncer Config
|
|
93
|
+
```ini
|
|
94
|
+
[databases]
|
|
95
|
+
mydb = host=localhost port=5432 dbname=mydb
|
|
96
|
+
|
|
97
|
+
[pgbouncer]
|
|
98
|
+
pool_mode = transaction
|
|
99
|
+
max_client_conn = 1000
|
|
100
|
+
default_pool_size = 20
|
|
101
|
+
reserve_pool_size = 5
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### App Connection Pooling
|
|
105
|
+
```typescript
|
|
106
|
+
// Prisma
|
|
107
|
+
datasource db {
|
|
108
|
+
provider = "postgresql"
|
|
109
|
+
url = env("DATABASE_URL")
|
|
110
|
+
connection_limit = 10
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## BACKUP MODE - Disaster Recovery
|
|
117
|
+
|
|
118
|
+
### Daily Backup Script
|
|
119
|
+
```bash
|
|
120
|
+
#!/bin/bash
|
|
121
|
+
pg_dump -Fc mydb > backup_$(date +%Y%m%d).dump
|
|
122
|
+
aws s3 cp backup_*.dump s3://backups/postgres/
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### WAL Archiving (PITR)
|
|
126
|
+
```ini
|
|
127
|
+
# postgresql.conf
|
|
128
|
+
archive_mode = on
|
|
129
|
+
archive_command = 'aws s3 cp %p s3://wal-archive/%f'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Restore Procedure
|
|
133
|
+
```bash
|
|
134
|
+
# 1. Stop app
|
|
135
|
+
# 2. Restore base backup
|
|
136
|
+
pg_restore -d mydb backup.dump
|
|
137
|
+
|
|
138
|
+
# 3. Replay WAL to point-in-time
|
|
139
|
+
recovery_target_time = '2024-01-15 14:30:00'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## SCHEMA MODE - Design
|
|
145
|
+
|
|
146
|
+
### Partitioning (Large Tables)
|
|
147
|
+
```sql
|
|
148
|
+
CREATE TABLE orders (
|
|
149
|
+
id SERIAL,
|
|
150
|
+
created_at TIMESTAMP,
|
|
151
|
+
...
|
|
152
|
+
) PARTITION BY RANGE (created_at);
|
|
153
|
+
|
|
154
|
+
CREATE TABLE orders_2024_q1 PARTITION OF orders
|
|
155
|
+
FOR VALUES FROM ('2024-01-01') TO ('2024-04-01');
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Denormalization Strategy
|
|
159
|
+
```sql
|
|
160
|
+
-- Store product_name in order_items for history
|
|
161
|
+
-- Even if products.name changes, order history intact
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## PERFORMANCE TARGETS
|
|
167
|
+
|
|
168
|
+
| Optimization | Expected |
|
|
169
|
+
|--------------|----------|
|
|
170
|
+
| Query speed | 90-98% faster |
|
|
171
|
+
| Index creation | 15-20 min/1M rows |
|
|
172
|
+
| Health check savings | $4K/month typical |
|
|
173
|
+
| Cache hit ratio | >99% target |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## SAFETY
|
|
178
|
+
- ✅ Always backup before changes
|
|
179
|
+
- ✅ Test migrations on staging
|
|
180
|
+
- ✅ Use CONCURRENTLY for indexes
|
|
181
|
+
- ✅ Transactions for multi-step ops
|
|
182
|
+
|
|
183
|
+
> **Key Takeaway:** Turn 45s queries into 0.8s. Design production-ready schemas. Get actionable health reports.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
# ---
|
|
187
|
+
# USAGE:
|
|
188
|
+
# /db optimize slow dashboard query
|
|
189
|
+
# /db schema design for order history
|
|
190
|
+
# /db health check production
|
|
191
|
+
# /db backup strategy PITR
|
|
192
|
+
# /db pool connection exhaustion
|
|
193
|
+
# ---
|