@juho0719/cckit 0.1.1

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.
Files changed (111) hide show
  1. package/assets/agents/architect.md +211 -0
  2. package/assets/agents/build-error-resolver.md +114 -0
  3. package/assets/agents/ccwin-code-reviewer.md +224 -0
  4. package/assets/agents/database-reviewer.md +91 -0
  5. package/assets/agents/doc-updater.md +107 -0
  6. package/assets/agents/e2e-runner.md +107 -0
  7. package/assets/agents/planner.md +212 -0
  8. package/assets/agents/python-reviewer.md +98 -0
  9. package/assets/agents/refactor-cleaner.md +85 -0
  10. package/assets/agents/security-reviewer.md +108 -0
  11. package/assets/agents/superpower-code-reviewer.md +48 -0
  12. package/assets/agents/tdd-guide.md +80 -0
  13. package/assets/commands/build-fix.md +62 -0
  14. package/assets/commands/checkpoint.md +74 -0
  15. package/assets/commands/code-review.md +40 -0
  16. package/assets/commands/e2e.md +362 -0
  17. package/assets/commands/eval.md +120 -0
  18. package/assets/commands/orchestrate.md +172 -0
  19. package/assets/commands/plan.md +113 -0
  20. package/assets/commands/python-review.md +297 -0
  21. package/assets/commands/refactor-clean.md +80 -0
  22. package/assets/commands/sessions.md +305 -0
  23. package/assets/commands/tdd.md +326 -0
  24. package/assets/commands/test-coverage.md +69 -0
  25. package/assets/commands/update-codemaps.md +72 -0
  26. package/assets/commands/update-docs.md +84 -0
  27. package/assets/commands/verify.md +59 -0
  28. package/assets/hooks/post-edit-format.js +49 -0
  29. package/assets/hooks/post-edit-typecheck.js +96 -0
  30. package/assets/mcps/mcp-servers.json +92 -0
  31. package/assets/rules/common/agents.md +49 -0
  32. package/assets/rules/common/coding-style.md +48 -0
  33. package/assets/rules/common/git-workflow.md +45 -0
  34. package/assets/rules/common/hooks.md +30 -0
  35. package/assets/rules/common/patterns.md +31 -0
  36. package/assets/rules/common/performance.md +55 -0
  37. package/assets/rules/common/security.md +29 -0
  38. package/assets/rules/common/testing.md +29 -0
  39. package/assets/rules/python/coding-style.md +42 -0
  40. package/assets/rules/python/hooks.md +19 -0
  41. package/assets/rules/python/patterns.md +39 -0
  42. package/assets/rules/python/security.md +30 -0
  43. package/assets/rules/python/testing.md +38 -0
  44. package/assets/rules/typescript/coding-style.md +18 -0
  45. package/assets/rules/typescript/hooks.md +19 -0
  46. package/assets/rules/typescript/patterns.md +39 -0
  47. package/assets/rules/typescript/security.md +30 -0
  48. package/assets/rules/typescript/testing.md +38 -0
  49. package/assets/skills/api-design/SKILL.md +522 -0
  50. package/assets/skills/backend-patterns/SKILL.md +597 -0
  51. package/assets/skills/brainstorming/SKILL.md +96 -0
  52. package/assets/skills/coding-standards/SKILL.md +529 -0
  53. package/assets/skills/database-migrations/SKILL.md +334 -0
  54. package/assets/skills/deployment-patterns/SKILL.md +426 -0
  55. package/assets/skills/dispatching-parallel-agents/SKILL.md +180 -0
  56. package/assets/skills/docker-patterns/SKILL.md +363 -0
  57. package/assets/skills/e2e-testing/SKILL.md +325 -0
  58. package/assets/skills/eval-harness/SKILL.md +235 -0
  59. package/assets/skills/executing-plans/SKILL.md +84 -0
  60. package/assets/skills/finishing-a-development-branch/SKILL.md +200 -0
  61. package/assets/skills/frontend-patterns/SKILL.md +641 -0
  62. package/assets/skills/iterative-retrieval/SKILL.md +210 -0
  63. package/assets/skills/postgres-patterns/SKILL.md +145 -0
  64. package/assets/skills/python-patterns/SKILL.md +749 -0
  65. package/assets/skills/python-testing/SKILL.md +815 -0
  66. package/assets/skills/receiving-code-review/SKILL.md +213 -0
  67. package/assets/skills/requesting-code-review/SKILL.md +105 -0
  68. package/assets/skills/requesting-code-review/code-reviewer-template.md +146 -0
  69. package/assets/skills/subagent-driven-development/SKILL.md +242 -0
  70. package/assets/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  71. package/assets/skills/subagent-driven-development/implementer-prompt.md +78 -0
  72. package/assets/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  73. package/assets/skills/systematic-debugging/CREATION-LOG.md +114 -0
  74. package/assets/skills/systematic-debugging/SKILL.md +296 -0
  75. package/assets/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  76. package/assets/skills/systematic-debugging/condition-based-waiting.md +115 -0
  77. package/assets/skills/systematic-debugging/defense-in-depth.md +122 -0
  78. package/assets/skills/systematic-debugging/root-cause-tracing.md +169 -0
  79. package/assets/skills/systematic-debugging/scripts/find-polluter.sh +63 -0
  80. package/assets/skills/systematic-debugging/test-academic.md +14 -0
  81. package/assets/skills/systematic-debugging/test-pressure-1.md +58 -0
  82. package/assets/skills/systematic-debugging/test-pressure-2.md +68 -0
  83. package/assets/skills/systematic-debugging/test-pressure-3.md +69 -0
  84. package/assets/skills/tdd-workflow/SKILL.md +409 -0
  85. package/assets/skills/test-driven-development/SKILL.md +371 -0
  86. package/assets/skills/test-driven-development/testing-anti-patterns.md +299 -0
  87. package/assets/skills/using-git-worktrees/SKILL.md +218 -0
  88. package/assets/skills/verification-before-completion/SKILL.md +139 -0
  89. package/assets/skills/verification-loop/SKILL.md +125 -0
  90. package/assets/skills/writing-plans/SKILL.md +116 -0
  91. package/dist/agents-AEKT67A6.js +9 -0
  92. package/dist/chunk-3GUKEMND.js +28 -0
  93. package/dist/chunk-3UNN3IBE.js +54 -0
  94. package/dist/chunk-3Y26YU4R.js +27 -0
  95. package/dist/chunk-5XOKKPAA.js +21 -0
  96. package/dist/chunk-6B46AIFM.js +136 -0
  97. package/dist/chunk-EYY2IZ7N.js +27 -0
  98. package/dist/chunk-K25UZZVG.js +17 -0
  99. package/dist/chunk-KEENFBLL.js +24 -0
  100. package/dist/chunk-RMUKD7CW.js +44 -0
  101. package/dist/chunk-W63UKEIT.js +50 -0
  102. package/dist/cli-VZRGF733.js +238 -0
  103. package/dist/commands-P5LILVZ5.js +9 -0
  104. package/dist/hooks-IIG2XK4I.js +9 -0
  105. package/dist/index.js +131 -0
  106. package/dist/mcps-67Q7TBGW.js +6 -0
  107. package/dist/paths-FT6KBIRD.js +10 -0
  108. package/dist/registry-EGXWYWWK.js +17 -0
  109. package/dist/rules-2CPBVNNJ.js +7 -0
  110. package/dist/skills-ULMW3UCM.js +8 -0
  111. package/package.json +36 -0
@@ -0,0 +1,334 @@
1
+ ---
2
+ name: database-migrations
3
+ description: Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Django, TypeORM, golang-migrate).
4
+ ---
5
+
6
+ # Database Migration Patterns
7
+
8
+ Safe, reversible database schema changes for production systems.
9
+
10
+ ## When to Activate
11
+
12
+ - Creating or altering database tables
13
+ - Adding/removing columns or indexes
14
+ - Running data migrations (backfill, transform)
15
+ - Planning zero-downtime schema changes
16
+ - Setting up migration tooling for a new project
17
+
18
+ ## Core Principles
19
+
20
+ 1. **Every change is a migration** — never alter production databases manually
21
+ 2. **Migrations are forward-only in production** — rollbacks use new forward migrations
22
+ 3. **Schema and data migrations are separate** — never mix DDL and DML in one migration
23
+ 4. **Test migrations against production-sized data** — a migration that works on 100 rows may lock on 10M
24
+ 5. **Migrations are immutable once deployed** — never edit a migration that has run in production
25
+
26
+ ## Migration Safety Checklist
27
+
28
+ Before applying any migration:
29
+
30
+ - [ ] Migration has both UP and DOWN (or is explicitly marked irreversible)
31
+ - [ ] No full table locks on large tables (use concurrent operations)
32
+ - [ ] New columns have defaults or are nullable (never add NOT NULL without default)
33
+ - [ ] Indexes created concurrently (not inline with CREATE TABLE for existing tables)
34
+ - [ ] Data backfill is a separate migration from schema change
35
+ - [ ] Tested against a copy of production data
36
+ - [ ] Rollback plan documented
37
+
38
+ ## PostgreSQL Patterns
39
+
40
+ ### Adding a Column Safely
41
+
42
+ ```sql
43
+ -- GOOD: Nullable column, no lock
44
+ ALTER TABLE users ADD COLUMN avatar_url TEXT;
45
+
46
+ -- GOOD: Column with default (Postgres 11+ is instant, no rewrite)
47
+ ALTER TABLE users ADD COLUMN is_active BOOLEAN NOT NULL DEFAULT true;
48
+
49
+ -- BAD: NOT NULL without default on existing table (requires full rewrite)
50
+ ALTER TABLE users ADD COLUMN role TEXT NOT NULL;
51
+ -- This locks the table and rewrites every row
52
+ ```
53
+
54
+ ### Adding an Index Without Downtime
55
+
56
+ ```sql
57
+ -- BAD: Blocks writes on large tables
58
+ CREATE INDEX idx_users_email ON users (email);
59
+
60
+ -- GOOD: Non-blocking, allows concurrent writes
61
+ CREATE INDEX CONCURRENTLY idx_users_email ON users (email);
62
+
63
+ -- Note: CONCURRENTLY cannot run inside a transaction block
64
+ -- Most migration tools need special handling for this
65
+ ```
66
+
67
+ ### Renaming a Column (Zero-Downtime)
68
+
69
+ Never rename directly in production. Use the expand-contract pattern:
70
+
71
+ ```sql
72
+ -- Step 1: Add new column (migration 001)
73
+ ALTER TABLE users ADD COLUMN display_name TEXT;
74
+
75
+ -- Step 2: Backfill data (migration 002, data migration)
76
+ UPDATE users SET display_name = username WHERE display_name IS NULL;
77
+
78
+ -- Step 3: Update application code to read/write both columns
79
+ -- Deploy application changes
80
+
81
+ -- Step 4: Stop writing to old column, drop it (migration 003)
82
+ ALTER TABLE users DROP COLUMN username;
83
+ ```
84
+
85
+ ### Removing a Column Safely
86
+
87
+ ```sql
88
+ -- Step 1: Remove all application references to the column
89
+ -- Step 2: Deploy application without the column reference
90
+ -- Step 3: Drop column in next migration
91
+ ALTER TABLE orders DROP COLUMN legacy_status;
92
+
93
+ -- For Django: use SeparateDatabaseAndState to remove from model
94
+ -- without generating DROP COLUMN (then drop in next migration)
95
+ ```
96
+
97
+ ### Large Data Migrations
98
+
99
+ ```sql
100
+ -- BAD: Updates all rows in one transaction (locks table)
101
+ UPDATE users SET normalized_email = LOWER(email);
102
+
103
+ -- GOOD: Batch update with progress
104
+ DO $$
105
+ DECLARE
106
+ batch_size INT := 10000;
107
+ rows_updated INT;
108
+ BEGIN
109
+ LOOP
110
+ UPDATE users
111
+ SET normalized_email = LOWER(email)
112
+ WHERE id IN (
113
+ SELECT id FROM users
114
+ WHERE normalized_email IS NULL
115
+ LIMIT batch_size
116
+ FOR UPDATE SKIP LOCKED
117
+ );
118
+ GET DIAGNOSTICS rows_updated = ROW_COUNT;
119
+ RAISE NOTICE 'Updated % rows', rows_updated;
120
+ EXIT WHEN rows_updated = 0;
121
+ COMMIT;
122
+ END LOOP;
123
+ END $$;
124
+ ```
125
+
126
+ ## Prisma (TypeScript/Node.js)
127
+
128
+ ### Workflow
129
+
130
+ ```bash
131
+ # Create migration from schema changes
132
+ npx prisma migrate dev --name add_user_avatar
133
+
134
+ # Apply pending migrations in production
135
+ npx prisma migrate deploy
136
+
137
+ # Reset database (dev only)
138
+ npx prisma migrate reset
139
+
140
+ # Generate client after schema changes
141
+ npx prisma generate
142
+ ```
143
+
144
+ ### Schema Example
145
+
146
+ ```prisma
147
+ model User {
148
+ id String @id @default(cuid())
149
+ email String @unique
150
+ name String?
151
+ avatarUrl String? @map("avatar_url")
152
+ createdAt DateTime @default(now()) @map("created_at")
153
+ updatedAt DateTime @updatedAt @map("updated_at")
154
+ orders Order[]
155
+
156
+ @@map("users")
157
+ @@index([email])
158
+ }
159
+ ```
160
+
161
+ ### Custom SQL Migration
162
+
163
+ For operations Prisma cannot express (concurrent indexes, data backfills):
164
+
165
+ ```bash
166
+ # Create empty migration, then edit the SQL manually
167
+ npx prisma migrate dev --create-only --name add_email_index
168
+ ```
169
+
170
+ ```sql
171
+ -- migrations/20240115_add_email_index/migration.sql
172
+ -- Prisma cannot generate CONCURRENTLY, so we write it manually
173
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_email ON users (email);
174
+ ```
175
+
176
+ ## Drizzle (TypeScript/Node.js)
177
+
178
+ ### Workflow
179
+
180
+ ```bash
181
+ # Generate migration from schema changes
182
+ npx drizzle-kit generate
183
+
184
+ # Apply migrations
185
+ npx drizzle-kit migrate
186
+
187
+ # Push schema directly (dev only, no migration file)
188
+ npx drizzle-kit push
189
+ ```
190
+
191
+ ### Schema Example
192
+
193
+ ```typescript
194
+ import { pgTable, text, timestamp, uuid, boolean } from "drizzle-orm/pg-core";
195
+
196
+ export const users = pgTable("users", {
197
+ id: uuid("id").primaryKey().defaultRandom(),
198
+ email: text("email").notNull().unique(),
199
+ name: text("name"),
200
+ isActive: boolean("is_active").notNull().default(true),
201
+ createdAt: timestamp("created_at").notNull().defaultNow(),
202
+ updatedAt: timestamp("updated_at").notNull().defaultNow(),
203
+ });
204
+ ```
205
+
206
+ ## Django (Python)
207
+
208
+ ### Workflow
209
+
210
+ ```bash
211
+ # Generate migration from model changes
212
+ python manage.py makemigrations
213
+
214
+ # Apply migrations
215
+ python manage.py migrate
216
+
217
+ # Show migration status
218
+ python manage.py showmigrations
219
+
220
+ # Generate empty migration for custom SQL
221
+ python manage.py makemigrations --empty app_name -n description
222
+ ```
223
+
224
+ ### Data Migration
225
+
226
+ ```python
227
+ from django.db import migrations
228
+
229
+ def backfill_display_names(apps, schema_editor):
230
+ User = apps.get_model("accounts", "User")
231
+ batch_size = 5000
232
+ users = User.objects.filter(display_name="")
233
+ while users.exists():
234
+ batch = list(users[:batch_size])
235
+ for user in batch:
236
+ user.display_name = user.username
237
+ User.objects.bulk_update(batch, ["display_name"], batch_size=batch_size)
238
+
239
+ def reverse_backfill(apps, schema_editor):
240
+ pass # Data migration, no reverse needed
241
+
242
+ class Migration(migrations.Migration):
243
+ dependencies = [("accounts", "0015_add_display_name")]
244
+
245
+ operations = [
246
+ migrations.RunPython(backfill_display_names, reverse_backfill),
247
+ ]
248
+ ```
249
+
250
+ ### SeparateDatabaseAndState
251
+
252
+ Remove a column from the Django model without dropping it from the database immediately:
253
+
254
+ ```python
255
+ class Migration(migrations.Migration):
256
+ operations = [
257
+ migrations.SeparateDatabaseAndState(
258
+ state_operations=[
259
+ migrations.RemoveField(model_name="user", name="legacy_field"),
260
+ ],
261
+ database_operations=[], # Don't touch the DB yet
262
+ ),
263
+ ]
264
+ ```
265
+
266
+ ## golang-migrate (Go)
267
+
268
+ ### Workflow
269
+
270
+ ```bash
271
+ # Create migration pair
272
+ migrate create -ext sql -dir migrations -seq add_user_avatar
273
+
274
+ # Apply all pending migrations
275
+ migrate -path migrations -database "$DATABASE_URL" up
276
+
277
+ # Rollback last migration
278
+ migrate -path migrations -database "$DATABASE_URL" down 1
279
+
280
+ # Force version (fix dirty state)
281
+ migrate -path migrations -database "$DATABASE_URL" force VERSION
282
+ ```
283
+
284
+ ### Migration Files
285
+
286
+ ```sql
287
+ -- migrations/000003_add_user_avatar.up.sql
288
+ ALTER TABLE users ADD COLUMN avatar_url TEXT;
289
+ CREATE INDEX CONCURRENTLY idx_users_avatar ON users (avatar_url) WHERE avatar_url IS NOT NULL;
290
+
291
+ -- migrations/000003_add_user_avatar.down.sql
292
+ DROP INDEX IF EXISTS idx_users_avatar;
293
+ ALTER TABLE users DROP COLUMN IF EXISTS avatar_url;
294
+ ```
295
+
296
+ ## Zero-Downtime Migration Strategy
297
+
298
+ For critical production changes, follow the expand-contract pattern:
299
+
300
+ ```
301
+ Phase 1: EXPAND
302
+ - Add new column/table (nullable or with default)
303
+ - Deploy: app writes to BOTH old and new
304
+ - Backfill existing data
305
+
306
+ Phase 2: MIGRATE
307
+ - Deploy: app reads from NEW, writes to BOTH
308
+ - Verify data consistency
309
+
310
+ Phase 3: CONTRACT
311
+ - Deploy: app only uses NEW
312
+ - Drop old column/table in separate migration
313
+ ```
314
+
315
+ ### Timeline Example
316
+
317
+ ```
318
+ Day 1: Migration adds new_status column (nullable)
319
+ Day 1: Deploy app v2 — writes to both status and new_status
320
+ Day 2: Run backfill migration for existing rows
321
+ Day 3: Deploy app v3 — reads from new_status only
322
+ Day 7: Migration drops old status column
323
+ ```
324
+
325
+ ## Anti-Patterns
326
+
327
+ | Anti-Pattern | Why It Fails | Better Approach |
328
+ |-------------|-------------|-----------------|
329
+ | Manual SQL in production | No audit trail, unrepeatable | Always use migration files |
330
+ | Editing deployed migrations | Causes drift between environments | Create new migration instead |
331
+ | NOT NULL without default | Locks table, rewrites all rows | Add nullable, backfill, then add constraint |
332
+ | Inline index on large table | Blocks writes during build | CREATE INDEX CONCURRENTLY |
333
+ | Schema + data in one migration | Hard to rollback, long transactions | Separate migrations |
334
+ | Dropping column before removing code | Application errors on missing column | Remove code first, drop column next deploy |