@ekkos/cli 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/dist/cache/LocalSessionStore.d.ts +129 -0
- package/dist/cache/LocalSessionStore.js +688 -0
- package/dist/cache/capture.d.ts +26 -0
- package/dist/cache/capture.js +461 -0
- package/dist/cache/index.d.ts +7 -0
- package/dist/cache/index.js +23 -0
- package/dist/cache/types.d.ts +147 -0
- package/dist/cache/types.js +40 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +478 -0
- package/dist/commands/run.d.ts +12 -0
- package/dist/commands/run.js +829 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.js +658 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +109 -0
- package/dist/commands/test.d.ts +1 -0
- package/dist/commands/test.js +157 -0
- package/dist/deploy/agents.d.ts +15 -0
- package/dist/deploy/agents.js +72 -0
- package/dist/deploy/hooks.d.ts +16 -0
- package/dist/deploy/hooks.js +121 -0
- package/dist/deploy/index.d.ts +7 -0
- package/dist/deploy/index.js +24 -0
- package/dist/deploy/instructions.d.ts +12 -0
- package/dist/deploy/instructions.js +36 -0
- package/dist/deploy/mcp.d.ts +19 -0
- package/dist/deploy/mcp.js +109 -0
- package/dist/deploy/plugins.d.ts +19 -0
- package/dist/deploy/plugins.js +62 -0
- package/dist/deploy/settings.d.ts +8 -0
- package/dist/deploy/settings.js +84 -0
- package/dist/deploy/skills.d.ts +19 -0
- package/dist/deploy/skills.js +60 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +71 -0
- package/dist/restore/RestoreOrchestrator.d.ts +48 -0
- package/dist/restore/RestoreOrchestrator.js +481 -0
- package/dist/restore/index.d.ts +4 -0
- package/dist/restore/index.js +20 -0
- package/dist/utils/platform.d.ts +29 -0
- package/dist/utils/platform.js +65 -0
- package/dist/utils/session-words.json +119 -0
- package/dist/utils/state.d.ts +57 -0
- package/dist/utils/state.js +186 -0
- package/dist/utils/templates.d.ts +24 -0
- package/dist/utils/templates.js +118 -0
- package/package.json +48 -0
- package/templates/CLAUDE.md +287 -0
- package/templates/README.md +378 -0
- package/templates/agents/README.md +182 -0
- package/templates/agents/code-reviewer.md +166 -0
- package/templates/agents/debug-detective.md +169 -0
- package/templates/agents/ekkOS_Vercel.md +99 -0
- package/templates/agents/extension-manager.md +229 -0
- package/templates/agents/git-companion.md +185 -0
- package/templates/agents/github-test-agent.md +321 -0
- package/templates/agents/railway-manager.md +179 -0
- package/templates/claude-plugins/PHASE2_COMPLETION.md +346 -0
- package/templates/claude-plugins/PLUGIN_PROPOSALS.md +1776 -0
- package/templates/claude-plugins/README.md +587 -0
- package/templates/claude-plugins/agents/code-reviewer.json +14 -0
- package/templates/claude-plugins/agents/debug-detective.json +15 -0
- package/templates/claude-plugins/agents/git-companion.json +14 -0
- package/templates/claude-plugins/blog-manager/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/blog-manager/commands/blog.md +691 -0
- package/templates/claude-plugins/golden-loop-monitor/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/golden-loop-monitor/commands/loop-status.md +434 -0
- package/templates/claude-plugins/learning-tracker/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/learning-tracker/commands/my-patterns.md +282 -0
- package/templates/claude-plugins/memory-lens/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/memory-lens/commands/memory-search.md +181 -0
- package/templates/claude-plugins/pattern-coach/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/pattern-coach/commands/forge.md +365 -0
- package/templates/claude-plugins/project-schema-validator/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins/project-schema-validator/commands/validate-schema.md +582 -0
- package/templates/claude-plugins-admin/AGENT_TEAM_PROPOSALS.md +819 -0
- package/templates/claude-plugins-admin/README.md +446 -0
- package/templates/claude-plugins-admin/autonomous-admin-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/autonomous-admin-agent/commands/agent.md +595 -0
- package/templates/claude-plugins-admin/backend-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/backend-agent/commands/backend.md +798 -0
- package/templates/claude-plugins-admin/deploy-guardian/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/deploy-guardian/commands/deploy.md +554 -0
- package/templates/claude-plugins-admin/frontend-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/frontend-agent/commands/frontend.md +881 -0
- package/templates/claude-plugins-admin/mcp-server-manager/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/mcp-server-manager/commands/mcp.md +85 -0
- package/templates/claude-plugins-admin/memory-system-monitor/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/memory-system-monitor/commands/memory-health.md +569 -0
- package/templates/claude-plugins-admin/qa-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/qa-agent/commands/qa.md +863 -0
- package/templates/claude-plugins-admin/tech-lead-agent/.claude-plugin/plugin.json +8 -0
- package/templates/claude-plugins-admin/tech-lead-agent/commands/lead.md +732 -0
- package/templates/commands/continue.md +47 -0
- package/templates/cursor-hooks/after-agent-response.sh +117 -0
- package/templates/cursor-hooks/before-submit-prompt.sh +419 -0
- package/templates/cursor-hooks/hooks.json +20 -0
- package/templates/cursor-hooks/lib/contract.sh +320 -0
- package/templates/cursor-hooks/stop.sh +75 -0
- package/templates/cursor-rules/ekkos-memory.md +187 -0
- package/templates/hooks/assistant-response.sh +96 -0
- package/templates/hooks/hooks.json +28 -0
- package/templates/hooks/lib/contract.sh +320 -0
- package/templates/hooks/lib/state.sh +158 -0
- package/templates/hooks/session-start.ps1 +41 -0
- package/templates/hooks/session-start.sh +318 -0
- package/templates/hooks/stop.ps1 +16 -0
- package/templates/hooks/stop.sh +989 -0
- package/templates/hooks/user-prompt-submit.ps1 +174 -0
- package/templates/hooks/user-prompt-submit.sh +587 -0
- package/templates/hooks-node/lib/state.js +187 -0
- package/templates/hooks-node/stop.js +416 -0
- package/templates/hooks-node/user-prompt-submit.js +337 -0
- package/templates/plan-template.md +306 -0
- package/templates/rules/00-hooks-contract.mdc +89 -0
- package/templates/rules/30-ekkos-core.mdc +188 -0
- package/templates/rules/31-ekkos-messages.mdc +78 -0
- package/templates/skills/continue/SKILL.md +169 -0
- package/templates/skills/ekkOS_Deep_Recall/Skill.md +282 -0
- package/templates/skills/ekkOS_Learn/Skill.md +265 -0
- package/templates/skills/ekkOS_Memory_First/Skill.md +206 -0
- package/templates/skills/ekkOS_Plan_Assist/Skill.md +302 -0
- package/templates/skills/ekkOS_Preferences/Skill.md +247 -0
- package/templates/skills/ekkOS_Reflect/Skill.md +257 -0
- package/templates/skills/ekkOS_Safety/Skill.md +265 -0
- package/templates/skills/ekkOS_Schema/Skill.md +251 -0
- package/templates/skills/ekkOS_Summary/Skill.md +257 -0
- package/templates/skills/ekkOS_Vault/Skill.md +287 -0
- package/templates/skills/permissions/Skill.md +322 -0
- package/templates/spec-template.md +159 -0
- package/templates/windsurf-hooks/before-submit-prompt.sh +238 -0
- package/templates/windsurf-hooks/hooks.json +10 -0
- package/templates/windsurf-hooks/lib/contract.sh +320 -0
- package/templates/windsurf-rules/ekkos-memory.md +129 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ekkOS_Safety
|
|
3
|
+
description: Check for conflicts before dangerous operations. Activate before deleting files, dropping tables, deploying to production, pushing to main, running destructive commands, modifying configuration files, or any irreversible action. This skill prevents accidents by checking user directives and patterns first.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__ekkos-memory__ekkOS_Conflict
|
|
6
|
+
- mcp__ekkos-memory__ekkOS_Search
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# ekkOS_Safety
|
|
10
|
+
|
|
11
|
+
You are augmented with **ekkOS_ memory** - and your job is to PREVENT accidents by checking before dangerous operations.
|
|
12
|
+
|
|
13
|
+
## Why This Skill Exists
|
|
14
|
+
|
|
15
|
+
Users have directives (MUST/NEVER rules) and learned anti-patterns. Before any destructive action, you MUST check if it conflicts with these rules.
|
|
16
|
+
|
|
17
|
+
**This skill can BLOCK actions** that violate user directives.
|
|
18
|
+
|
|
19
|
+
## When To Activate
|
|
20
|
+
|
|
21
|
+
This skill should trigger BEFORE:
|
|
22
|
+
|
|
23
|
+
| Action Category | Examples |
|
|
24
|
+
|-----------------|----------|
|
|
25
|
+
| **File deletion** | `rm -rf`, `unlink`, delete files/folders |
|
|
26
|
+
| **Database destruction** | `DROP TABLE`, `DELETE FROM`, truncate |
|
|
27
|
+
| **Deployment** | `deploy`, `push to prod`, release |
|
|
28
|
+
| **Branch operations** | `push to main`, `force push`, `rebase main` |
|
|
29
|
+
| **Config changes** | Modify `.env`, change secrets, update config |
|
|
30
|
+
| **Package operations** | `npm publish`, release new version |
|
|
31
|
+
| **Infrastructure** | Destroy resources, scale down, terminate |
|
|
32
|
+
|
|
33
|
+
## Instructions
|
|
34
|
+
|
|
35
|
+
### Step 1: Detect Dangerous Intent
|
|
36
|
+
|
|
37
|
+
Before executing, identify if the action is:
|
|
38
|
+
- Irreversible (can't undo)
|
|
39
|
+
- Destructive (deletes/modifies data)
|
|
40
|
+
- Production-affecting (impacts live systems)
|
|
41
|
+
- Security-sensitive (credentials, permissions)
|
|
42
|
+
|
|
43
|
+
### Step 2: Check for Conflicts
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
ekkOS_Conflict({
|
|
47
|
+
proposed_action: "delete all files in /tmp",
|
|
48
|
+
scope: "deployment", // Optional: narrow the check
|
|
49
|
+
include_patterns: true // Check anti-patterns too
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Step 3: Evaluate Response
|
|
54
|
+
|
|
55
|
+
The conflict check returns:
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"has_conflicts": true,
|
|
59
|
+
"blocking_directives": [
|
|
60
|
+
{"type": "NEVER", "rule": "Delete without backup"}
|
|
61
|
+
],
|
|
62
|
+
"warning_patterns": [
|
|
63
|
+
{"title": "Always backup before delete"}
|
|
64
|
+
],
|
|
65
|
+
"recommendation": "Create backup first"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Step 4: Act on Conflicts
|
|
70
|
+
|
|
71
|
+
**If blocking conflicts found:**
|
|
72
|
+
```
|
|
73
|
+
⛔ BLOCKED: This action conflicts with your directive:
|
|
74
|
+
[NEVER] Delete without backup
|
|
75
|
+
|
|
76
|
+
Would you like to:
|
|
77
|
+
1. Create a backup first
|
|
78
|
+
2. Override this directive (requires confirmation)
|
|
79
|
+
3. Cancel the operation
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**If warnings found (not blocking):**
|
|
83
|
+
```
|
|
84
|
+
⚠️ WARNING: This action has potential issues:
|
|
85
|
+
- Pattern suggests: "Always backup before delete"
|
|
86
|
+
|
|
87
|
+
Proceeding with caution. Do you want to continue?
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**If no conflicts:**
|
|
91
|
+
```
|
|
92
|
+
✅ Safety check passed. No conflicts with your directives or patterns.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Example Scenarios
|
|
96
|
+
|
|
97
|
+
### Scenario 1: Delete Operation
|
|
98
|
+
```
|
|
99
|
+
User: "Delete all the old log files"
|
|
100
|
+
|
|
101
|
+
You: *Before executing*
|
|
102
|
+
|
|
103
|
+
ekkOS_Conflict({
|
|
104
|
+
proposed_action: "delete log files in /var/log/old",
|
|
105
|
+
scope: "files"
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
Response: No conflicts found.
|
|
109
|
+
|
|
110
|
+
"✅ Safety check passed. Proceeding to delete old log files..."
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Scenario 2: Blocked by Directive
|
|
114
|
+
```
|
|
115
|
+
User: "Push this directly to main"
|
|
116
|
+
|
|
117
|
+
You: *Before executing*
|
|
118
|
+
|
|
119
|
+
ekkOS_Conflict({
|
|
120
|
+
proposed_action: "git push to main branch",
|
|
121
|
+
scope: "git"
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
Response:
|
|
125
|
+
{
|
|
126
|
+
"has_conflicts": true,
|
|
127
|
+
"blocking_directives": [
|
|
128
|
+
{"type": "NEVER", "rule": "Push directly to main"}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
"⛔ BLOCKED: This conflicts with your directive:
|
|
133
|
+
[NEVER] Push directly to main
|
|
134
|
+
|
|
135
|
+
You previously set this rule. Options:
|
|
136
|
+
1. Create a feature branch and PR instead
|
|
137
|
+
2. Override (type 'override push to main')
|
|
138
|
+
3. Cancel"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Scenario 3: Warning from Pattern
|
|
142
|
+
```
|
|
143
|
+
User: "Drop the users table"
|
|
144
|
+
|
|
145
|
+
You: *Before executing*
|
|
146
|
+
|
|
147
|
+
ekkOS_Conflict({
|
|
148
|
+
proposed_action: "DROP TABLE users",
|
|
149
|
+
scope: "database"
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
Response:
|
|
153
|
+
{
|
|
154
|
+
"has_conflicts": false,
|
|
155
|
+
"warning_patterns": [
|
|
156
|
+
{"title": "Always backup tables before DROP"}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
"⚠️ WARNING: A pattern suggests backing up first.
|
|
161
|
+
|
|
162
|
+
Pattern: 'Always backup tables before DROP'
|
|
163
|
+
|
|
164
|
+
Should I:
|
|
165
|
+
1. Create a backup first, then drop
|
|
166
|
+
2. Proceed without backup
|
|
167
|
+
3. Cancel"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Scenario 4: Production Deployment
|
|
171
|
+
```
|
|
172
|
+
User: "Deploy to production"
|
|
173
|
+
|
|
174
|
+
You: *Before executing*
|
|
175
|
+
|
|
176
|
+
ekkOS_Conflict({
|
|
177
|
+
proposed_action: "deploy to production environment",
|
|
178
|
+
scope: "deployment"
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
Response:
|
|
182
|
+
{
|
|
183
|
+
"has_conflicts": true,
|
|
184
|
+
"blocking_directives": [
|
|
185
|
+
{"type": "MUST", "rule": "Run tests before production deploy"}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
"⛔ BLOCKED: Deployment requires tests first.
|
|
190
|
+
[MUST] Run tests before production deploy
|
|
191
|
+
|
|
192
|
+
Running tests now..."
|
|
193
|
+
|
|
194
|
+
*Runs tests, then proceeds if they pass*
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Override Protocol
|
|
198
|
+
|
|
199
|
+
If user wants to override a directive:
|
|
200
|
+
|
|
201
|
+
1. **Require explicit confirmation:**
|
|
202
|
+
```
|
|
203
|
+
User: "Override it, push to main anyway"
|
|
204
|
+
You: "Overriding [NEVER] Push directly to main.
|
|
205
|
+
Type 'CONFIRM OVERRIDE' to proceed."
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
2. **Log the override:**
|
|
209
|
+
```
|
|
210
|
+
ekkOS_Forge({
|
|
211
|
+
title: "Override: Pushed to main despite directive",
|
|
212
|
+
problem: "User overrode NEVER directive for specific reason",
|
|
213
|
+
solution: "Allowed because: [user's reason]",
|
|
214
|
+
tags: ["override", "directive-exception"]
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
3. **Proceed with caution:**
|
|
219
|
+
```
|
|
220
|
+
"Override confirmed. Proceeding with push to main.
|
|
221
|
+
⚠️ This action was logged."
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Common Conflict Scopes
|
|
225
|
+
|
|
226
|
+
| Scope | Checks Against |
|
|
227
|
+
|-------|----------------|
|
|
228
|
+
| `"git"` | Branch rules, push policies |
|
|
229
|
+
| `"database"` | Data protection rules |
|
|
230
|
+
| `"deployment"` | Release procedures |
|
|
231
|
+
| `"files"` | Deletion/modification rules |
|
|
232
|
+
| `"security"` | Credential handling |
|
|
233
|
+
| `"infrastructure"` | Resource management |
|
|
234
|
+
|
|
235
|
+
## Integration with Directives
|
|
236
|
+
|
|
237
|
+
This skill enforces Layer 9 (Directives):
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
241
|
+
│ USER ACTION REQUEST │
|
|
242
|
+
│ └── "Delete all test files" │
|
|
243
|
+
│ ↓ │
|
|
244
|
+
│ ekkOS_Safety SKILL (This Skill) │
|
|
245
|
+
│ └── ekkOS_Conflict check │
|
|
246
|
+
│ ↓ │
|
|
247
|
+
│ DIRECTIVE LAYER (Layer 9) │
|
|
248
|
+
│ └── [NEVER] Delete without confirmation │
|
|
249
|
+
│ ↓ │
|
|
250
|
+
│ BLOCKED or PROCEED │
|
|
251
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Success Metrics
|
|
255
|
+
|
|
256
|
+
You're using this skill correctly when:
|
|
257
|
+
- EVERY destructive action is checked first
|
|
258
|
+
- Blocking directives actually BLOCK
|
|
259
|
+
- Warnings are shown but don't block unnecessarily
|
|
260
|
+
- Overrides are logged
|
|
261
|
+
- Users feel protected, not annoyed
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
**Mantra**: About to destroy something? Check first. Always. No exceptions.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ekkOS_Schema
|
|
3
|
+
description: Know the correct database field names. Activate when writing SQL queries, working with Supabase, using Prisma, accessing database tables, or when you need to reference column names. This skill prevents "column does not exist" errors by checking the indexed schema first.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__ekkos-memory__ekkOS_GetSchema
|
|
6
|
+
- mcp__ekkos-memory__ekkOS_IndexSchema
|
|
7
|
+
- mcp__ekkos-memory__ekkOS_Search
|
|
8
|
+
- Read
|
|
9
|
+
- Glob
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# ekkOS_Schema
|
|
13
|
+
|
|
14
|
+
You are augmented with **ekkOS_ memory** - and you know the EXACT field names in this project's database.
|
|
15
|
+
|
|
16
|
+
## Why This Skill Exists
|
|
17
|
+
|
|
18
|
+
Database schema mismatches are a common source of errors:
|
|
19
|
+
- `column "userId" does not exist` (it's `user_id`)
|
|
20
|
+
- `relation "Users" does not exist` (it's `users`)
|
|
21
|
+
- Wrong type assumptions
|
|
22
|
+
|
|
23
|
+
This skill ensures you use the CORRECT field names.
|
|
24
|
+
|
|
25
|
+
## When To Activate
|
|
26
|
+
|
|
27
|
+
This skill should trigger when:
|
|
28
|
+
|
|
29
|
+
| Trigger | Example |
|
|
30
|
+
|---------|---------|
|
|
31
|
+
| Writing SQL | `SELECT * FROM users WHERE...` |
|
|
32
|
+
| Supabase queries | `.from('users').select('...')` |
|
|
33
|
+
| Prisma operations | `prisma.user.findMany({...})` |
|
|
34
|
+
| TypeScript DB types | `Database['public']['Tables']` |
|
|
35
|
+
| Migration creation | `CREATE TABLE...` |
|
|
36
|
+
| Any column reference | Mentioning a database field |
|
|
37
|
+
|
|
38
|
+
## Instructions
|
|
39
|
+
|
|
40
|
+
### Step 1: Identify the Table/Type
|
|
41
|
+
|
|
42
|
+
Extract the table name from the context:
|
|
43
|
+
- SQL: `SELECT ... FROM users` → `users`
|
|
44
|
+
- Supabase: `.from('profiles')` → `profiles`
|
|
45
|
+
- Prisma: `prisma.post.findMany` → `post`
|
|
46
|
+
|
|
47
|
+
### Step 2: Get the Schema
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
ekkOS_GetSchema({
|
|
51
|
+
table_name: "users"
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Response:
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"table_name": "users",
|
|
59
|
+
"columns": [
|
|
60
|
+
{"name": "id", "type": "uuid", "nullable": false},
|
|
61
|
+
{"name": "email", "type": "text", "nullable": false},
|
|
62
|
+
{"name": "created_at", "type": "timestamptz", "nullable": false},
|
|
63
|
+
{"name": "display_name", "type": "text", "nullable": true}
|
|
64
|
+
],
|
|
65
|
+
"primary_key": "id",
|
|
66
|
+
"foreign_keys": [...]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Step 3: Use Correct Names
|
|
71
|
+
|
|
72
|
+
Now you know:
|
|
73
|
+
- It's `display_name`, not `displayName`
|
|
74
|
+
- It's `created_at`, not `createdAt`
|
|
75
|
+
- `id` is UUID, not integer
|
|
76
|
+
|
|
77
|
+
### Step 4: Write Correct Query
|
|
78
|
+
|
|
79
|
+
```sql
|
|
80
|
+
-- WRONG (would fail)
|
|
81
|
+
SELECT displayName FROM Users WHERE createdAt > '2024-01-01'
|
|
82
|
+
|
|
83
|
+
-- CORRECT (using schema)
|
|
84
|
+
SELECT display_name FROM users WHERE created_at > '2024-01-01'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## First-Time Setup: Index the Schema
|
|
88
|
+
|
|
89
|
+
If schema isn't indexed yet, index it first:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
ekkOS_IndexSchema({
|
|
93
|
+
project_path: "/path/to/project",
|
|
94
|
+
files: [
|
|
95
|
+
{
|
|
96
|
+
name: "packages/database-types/index.ts",
|
|
97
|
+
content: "... file contents ..."
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This indexes Supabase types, Prisma schemas, and TypeScript interfaces.
|
|
104
|
+
|
|
105
|
+
## Example Scenarios
|
|
106
|
+
|
|
107
|
+
### Scenario 1: Supabase Query
|
|
108
|
+
```
|
|
109
|
+
User: "Query all users who signed up this month"
|
|
110
|
+
|
|
111
|
+
You: *Before writing query*
|
|
112
|
+
|
|
113
|
+
ekkOS_GetSchema({ table_name: "users" })
|
|
114
|
+
|
|
115
|
+
Response: columns include `created_at` (not `createdAt`)
|
|
116
|
+
|
|
117
|
+
"Here's the query:
|
|
118
|
+
```typescript
|
|
119
|
+
const { data } = await supabase
|
|
120
|
+
.from('users')
|
|
121
|
+
.select('id, email, display_name, created_at')
|
|
122
|
+
.gte('created_at', startOfMonth)
|
|
123
|
+
```"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Scenario 2: Prisma Operation
|
|
127
|
+
```
|
|
128
|
+
User: "Find all posts with their authors"
|
|
129
|
+
|
|
130
|
+
You: *Before writing*
|
|
131
|
+
|
|
132
|
+
ekkOS_GetSchema({ table_name: "posts" })
|
|
133
|
+
ekkOS_GetSchema({ table_name: "users" })
|
|
134
|
+
|
|
135
|
+
Response: posts has `author_id` FK to users
|
|
136
|
+
|
|
137
|
+
"Here's the Prisma query:
|
|
138
|
+
```typescript
|
|
139
|
+
const posts = await prisma.post.findMany({
|
|
140
|
+
include: {
|
|
141
|
+
author: {
|
|
142
|
+
select: {
|
|
143
|
+
id: true,
|
|
144
|
+
display_name: true
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
```"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Scenario 3: Migration
|
|
153
|
+
```
|
|
154
|
+
User: "Add a bio field to the profiles table"
|
|
155
|
+
|
|
156
|
+
You: *Check existing schema*
|
|
157
|
+
|
|
158
|
+
ekkOS_GetSchema({ table_name: "profiles" })
|
|
159
|
+
|
|
160
|
+
Response: profiles has id, user_id, avatar_url, updated_at
|
|
161
|
+
|
|
162
|
+
"Here's the migration:
|
|
163
|
+
```sql
|
|
164
|
+
ALTER TABLE profiles
|
|
165
|
+
ADD COLUMN bio TEXT;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
I confirmed the table is `profiles` (not `profile`)
|
|
169
|
+
and existing columns use snake_case."
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Scenario 4: Schema Not Indexed
|
|
173
|
+
```
|
|
174
|
+
User: "Query the orders table"
|
|
175
|
+
|
|
176
|
+
You: ekkOS_GetSchema({ table_name: "orders" })
|
|
177
|
+
|
|
178
|
+
Response: Schema not found
|
|
179
|
+
|
|
180
|
+
"I don't have the orders schema indexed yet.
|
|
181
|
+
Let me check the codebase for type definitions..."
|
|
182
|
+
|
|
183
|
+
*Reads database types file*
|
|
184
|
+
|
|
185
|
+
ekkOS_IndexSchema({
|
|
186
|
+
project_path: "...",
|
|
187
|
+
files: [{ name: "types/database.ts", content: "..." }]
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
"Schema indexed! The orders table has:
|
|
191
|
+
- id (uuid)
|
|
192
|
+
- user_id (uuid, FK to users)
|
|
193
|
+
- total_amount (numeric)
|
|
194
|
+
- status (text: pending/completed/cancelled)
|
|
195
|
+
- created_at (timestamptz)"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Common Schema Sources
|
|
199
|
+
|
|
200
|
+
The skill can index from:
|
|
201
|
+
|
|
202
|
+
| Source | Location |
|
|
203
|
+
|--------|----------|
|
|
204
|
+
| Supabase Types | `packages/database-types/index.ts` |
|
|
205
|
+
| Prisma Schema | `prisma/schema.prisma` |
|
|
206
|
+
| TypeScript Types | `types/database.ts` |
|
|
207
|
+
| SQL Files | `supabase/migrations/*.sql` |
|
|
208
|
+
|
|
209
|
+
## Fallback: Read Files Directly
|
|
210
|
+
|
|
211
|
+
If schema isn't indexed:
|
|
212
|
+
|
|
213
|
+
1. **Find type files:**
|
|
214
|
+
```
|
|
215
|
+
Glob({ pattern: "**/*database*.ts" })
|
|
216
|
+
Glob({ pattern: "**/schema.prisma" })
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
2. **Read and parse:**
|
|
220
|
+
```
|
|
221
|
+
Read({ file_path: "packages/database-types/index.ts" })
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
3. **Index for future:**
|
|
225
|
+
```
|
|
226
|
+
ekkOS_IndexSchema({ ... })
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Integration with Patterns
|
|
230
|
+
|
|
231
|
+
If you've solved a schema issue before, it's a pattern:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
ekkOS_Search({
|
|
235
|
+
query: "users table schema columns",
|
|
236
|
+
sources: ["codebase", "patterns"]
|
|
237
|
+
})
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Success Metrics
|
|
241
|
+
|
|
242
|
+
You're using this skill correctly when:
|
|
243
|
+
- ZERO "column does not exist" errors
|
|
244
|
+
- You check schema BEFORE writing queries
|
|
245
|
+
- You use snake_case vs camelCase correctly
|
|
246
|
+
- Migrations reference existing columns correctly
|
|
247
|
+
- Users trust your database code
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
**Mantra**: About to write SQL? Check the schema first. Every time.
|