schema-diff-analyzer
Schema Diff Analyzer Protocol
This skill takes two schema definitions (Source vs Target, or Environment A vs Environment B) and calculates the correct, safe delta between them. It doesn't blindly apply changes; it evaluates risk.
Core assumption: Applying standard ORM or CLI diff outputs directly to production often creates dangerous lock conditions.
1. Diff Extraction & Categorization
Analyze the two inputs. Group identified changes into three core risk categories:
🟢 Safe (Low Risk)
- Adding new tables.
- Adding new nullable columns.
- Adding non-unique indexes (with
CREATE INDEX CONCURRENTLY). - Adding new views (if they don't break existing dependencies).
🟡 Warning (Medium Risk)
- Modifying column types (e.g.,
VARCHAR(50)toVARCHAR(100)). - Adding missing constraints or foreign keys.
- Dropping unused tables.
🔴 Dangerous (High Risk / Blocking)
- Dropping columns or tables actively used.
- Renaming columns or tables (requires Expand-Contract).
- Modifying a column to make it
NOT NULLwithout default. - Adding a
DEFAULTto a huge table (depends on DB dialect).
2. Sync Plan Generation
Do not provide a single monolith transaction if dangerous changes exist. Organize changes logically.
Required Outputs (Must write BOTH to docs/database-report/):
- Human-Readable Markdown (
docs/database-report/schema-diff-report.md)
## ⚠️ Risk Assessment
- **Safe:** Added table `audit_logs`.
- **Dangerous:** Renamed `customer_id` to `client_id` in `orders` table.
## 🛠️ Sync Execution Plan
Rather than running `prisma db push` or raw alters directly, follow this safe order:
**PHASE 1: (Pre-deployment Safe Alters)**
```sql
CREATE TABLE audit_logs (...);
ALTER TABLE orders ADD COLUMN client_id UUID;
(Delegate to migration-strategist for the backfill of client_id vs customer_id)
PHASE 2: (Post-deployment Cleanup)
ALTER TABLE orders DROP COLUMN customer_id;
2. **Machine-Readable JSON (`docs/database-report/schema-diff-output.json`)**
```json
{
"skill": "schema-diff-analyzer",
"overall_risk_level": "High",
"changes": [
{"type": "Safe", "entity": "audit_logs", "action": "CREATE TABLE"},
{"type": "Dangerous", "entity": "orders", "action": "RENAME COLUMN", "details": "customer_id to client_id"}
],
"recommended_phases": ["Phase 1 (Safe Alters)", "Backfill", "Phase 2 (Cleanup)"]
}
3. Tool Handoff
If the diff contains a "🔴 Dangerous" change, explicitly state that the user should engage the migration-strategist skill for that specific field to prevent downtime.
Guardrails
- Data Truncation Warnings: Always explicitly flag operations where limits are reduced (e.g.,
255down to50). - Dialect Specific Locks: Recognize that PostgreSQL 11+ handles
ADD COLUMN ... DEFAULTinstantly, whereas older engines rewrite the table. - Dependency Graphs: Ensure dropping a table or column safely accounts for related views, sequences, or triggers.
More from fatih-developer/fth-skills
task-decomposer
Break down large, complex, or ambiguous tasks into independent subtasks with dependency maps, execution order, and success criteria. Plan first, then execute step by step. Triggers on 'how should I do this', 'where do I start', 'plan the project', 'break it down', 'implement' or whenever a task involves multiple phases.
24context-compressor
Compress long conversation histories, large code files, research results, and documents by 70% without losing critical information. Triggers when context window fills up, when summarizing previous steps in multi-step tasks, before loading large files into context, or on 'summarize', 'compress', 'reduce context', 'save tokens'.
18multi-brain-debate
Two-round debate protocol where perspectives challenge each other before consensus. Round 1 presents independent positions, Round 2 allows counter-arguments and rebuttals. Produces battle-tested decisions for high-stakes choices.
17multi-brain-score
Confidence scoring overlay for multi-brain decisions. Each perspective rates its own confidence (1-10) with justification. Consensus uses scores as weights, flags low-confidence areas, and surfaces uncertainty explicitly.
15checkpoint-guardian
Automatic risk assessment before every critical action in agentic workflows. Detects irreversible operations (file deletion, database writes, deployments, payments), classifies risk level, and requires confirmation before proceeding. Triggers on destructive keywords like deploy, delete, send, publish, update database, process payment.
14parallel-planner
Analyze multi-step tasks to identify which steps can run in parallel, build dependency graphs, detect conflicts (write-write, read-write, resource contention), and produce optimized execution plans. Triggers on 3+ independent steps, 'speed up', 'run simultaneously', 'parallelize', 'optimize' or any task where sequential execution wastes time.
14