analyze-bugs
**Purpose:** Analyze bug reports from host projects (framework project only).
Создать database migration с правильным процессом
$ npx -y skills add alexeykrol/claude-code-starter --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/db-migrateContext preview
What this command does when you run it.
Создать database migration с правильным процессом
description: Создать database migration с правильным процессом
Создай database migration следуя лучшим практикам.
**ВАЖНО: Миграции - критическая часть. Тестируй все тщательно!**
Прочитай и проанализируй:
# Найди файлы схемы БД find . -name "schema.*" -o -name "*.prisma" -o -name "*migration*" # Посмотри последние миграции ls -la supabase/migrations/ || ls -la prisma/migrations/ || ls -la migrations/
Прочитай:
Спроси себя:
**Типы изменений:**
**Безопасные (можно делать на проде):**
**Опасные (требуют осторожности):**
**Очень опасные (только с downtime):**
**Naming convention:**
YYYYMMDDHHMMSS_descriptive_name.sql
Пример: `20250110120000_add_user_preferences_table.sql`
**Структура миграции:**
-- Migration: Add user preferences table
-- Created: 2025-01-10
-- Author: Claude Code
-- Description: Add table to store user preferences with foreign key to users
-- ============================================
-- Up Migration
-- ============================================
BEGIN;
-- Create table
CREATE TABLE IF NOT EXISTS user_preferences (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
theme VARCHAR(20) DEFAULT 'light' CHECK (theme IN ('light', 'dark', 'auto')),
language VARCHAR(10) DEFAULT 'en',
notifications_enabled BOOLEAN DEFAULT true,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
-- Constraints
CONSTRAINT unique_user_preferences UNIQUE(user_id)
);
-- Create indexes
CREATE INDEX idx_user_preferences_user_id ON user_preferences(user_id);
-- Add comments
COMMENT ON TABLE user_preferences IS 'Stores user-specific preferences';
COMMENT ON COLUMN user_preferences.theme IS 'UI theme preference';
-- Enable Row Level Security
ALTER TABLE user_preferences ENABLE ROW LEVEL SECURITY;
-- Create RLS policies
CREATE POLICY "Users can view own preferences"
ON user_preferences
FOR SELECT
USING (auth.uid() = user_id);
CREATE POLICY "Users can update own preferences"
ON user_preferences
FOR UPDATE
USING (auth.uid() = user_id);
CREATE POLICY "Users can insert own preferences"
ON user_preferences
FOR INSERT
WITH CHECK (auth.uid() = user_id);
COMMIT;
-- ============================================
-- Down Migration (Rollback)
-- ============================================
-- Uncomment to enable rollback:
-- BEGIN;
-- DROP TABLE IF EXISTS user_preferences CASCADE;
-- COMMIT;**Файл: `src/types/database.ts` или обнови существующий:**
// Database Types
export interface UserPreferences {
id: string;
user_id: string;
theme: 'light' | 'dark' | 'auto';
language: string;
notifications_enabled: boolean;
created_at: string;
updated_at: string;
}
// Database Tables
export interface Database {
public: {
Tables: {
user_preferences: {
Row: UserPreferences;
Insert: Omit<UserPreferences, 'id' | 'created_at' | 'updated_at'>;
Update: Partial<Omit<UserPreferences, 'id' | 'created_at'>>;
};
// ... other tables
};
};
}**В Development:**
# Применить миграцию make db-migrate # или npm run db:migrate # или supabase db push # Проверить что таблица создана # (команда зависит от вашей БД) # Тестировать операции # - INSERT тестовые данные # - SELECT проверить чтение # - UPDATE проверить обновление # - DELETE проверить удаление # - Проверить RLS policies
**Rollback тест:**
# Откатить миграцию make db-rollback # или npm run db:rollback # Проверить что откат работает # Применить снова для продолжения работы make db-migrate
**Обнови ARCHITECTURE.md:**
### Database Schema #### user_preferences Stores user-specific UI and notification preferences. **Columns:** - `id` (UUID, PK) - Unique identifier - `user_id` (UUID, FK → users.id) - Reference to user - `theme` (VARCHAR) - UI theme: 'light', 'dark', 'auto' - `language` (VARCHAR) - Preferred language code - `notifications_enabled` (BOOLEAN) - Email notifications toggle - `created_at` (TIMESTAMP) - Record creation time - `updated_at` (TIMESTAMP) - Last update time **Constraints:** - One preference record per user (unique user_id) - Cascading delete when user is deleted **Security:** - RLS enabled - Users can only view/edit their own preferences
**Создай/обнови API endpoints:**
// Example: API route for preferences
import { Database } from '@/types/database';
export async function GET(req: Request) {
const supabase = createClient<Database>();
const { data, error } = await supabase
.from('user_preferences')
.select('*')
.single();
if (error) {
return Response.json({ error: error.message }, { status: 400 });
}
return Response.json(data);
}Используй `/commit` команду со следующими изменениями:
Claude Code Starter — это готовая управляющая среда для проектов, в которых основной рабочий агент — Claude Code.
Repo: alexeykrol/claude-code-starter
**Purpose:** Analyze bug reports from host projects (framework project only).
**Purpose:** Analyze local bug reports to find patterns and recurring issues.