database-manager
CookMode V2のデータベース構造やデータ移行、検索を管理し、テーブルの作成・変更、セキュリティポリシーの更新、問題解決などをサポートするSkill。
📜 元の英語説明(参考)
Manages Supabase database schema, migrations, and queries for CookMode V2. Use this when the user needs to create/modify tables, write migrations, update RLS policies, or troubleshoot database issues.
🇯🇵 日本人クリエイター向け解説
CookMode V2のデータベース構造やデータ移行、検索を管理し、テーブルの作成・変更、セキュリティポリシーの更新、問題解決などをサポートするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o database-manager.zip https://jpskill.com/download/16998.zip && unzip -o database-manager.zip && rm database-manager.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/16998.zip -OutFile "$d\database-manager.zip"; Expand-Archive "$d\database-manager.zip" -DestinationPath $d -Force; ri "$d\database-manager.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
database-manager.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
database-managerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] database-manager
Database Manager Skill
あなたの役割
あなたは CookMode V2 のための Supabase PostgreSQL データベース操作を専門としています。スキーマの管理、マイグレーションの記述、Row Level Security (RLS) の設定、データベースの問題のトラブルシューティングを支援します。
この Skill を使用するタイミング
ユーザーが以下を希望する場合に、この skill を呼び出してください。
- データベーステーブルの作成または変更
- SQL マイグレーションの記述
- RLS ポリシーの追加/更新
- データベースエラーのデバッグ
- クエリの最適化
- 新しいデータベース機能の追加
現在のデータベーススキーマ
テーブルの概要
-
ingredient_checks
- 材料の完了状況を追跡します
- クライアント間でリアルタイムに同期されます
-
step_checks
- 指示ステップの完了状況を追跡します
- クライアント間でリアルタイムに同期されます
-
recipe_status
- ワークフローの状態: gathered, complete, plated, packed
- レシピごとに1つの状態
-
recipe_order_counts
- 各レシピの注文数 (1-50)
- 材料の調整に使用されます
-
recipe_chef_names
- カラーバッジ付きのシェフの割り当て
nameおよびcolorフィールドが含まれます
スキーマファイル
- Primary:
/supabase-schema.sql - Migrations:
/supabase-migration-*.sql
テーブルスキーマ
ingredient_checks
CREATE TABLE ingredient_checks (
recipe_slug TEXT NOT NULL,
ingredient_index INTEGER NOT NULL,
component_name TEXT NOT NULL,
ingredient_text TEXT,
is_checked BOOLEAN DEFAULT FALSE,
updated_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (recipe_slug, ingredient_index, component_name)
);
step_checks
CREATE TABLE step_checks (
recipe_slug TEXT NOT NULL,
step_index INTEGER NOT NULL,
step_text TEXT,
is_checked BOOLEAN DEFAULT FALSE,
updated_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (recipe_slug, step_index)
);
recipe_status
CREATE TABLE recipe_status (
recipe_slug TEXT PRIMARY KEY,
status TEXT CHECK (status IN ('gathered', 'complete', 'plated', 'packed')),
updated_at TIMESTAMP DEFAULT NOW()
);
recipe_order_counts
CREATE TABLE recipe_order_counts (
recipe_slug TEXT PRIMARY KEY,
order_count INTEGER DEFAULT 1 CHECK (order_count >= 1 AND order_count <= 50),
updated_at TIMESTAMP DEFAULT NOW()
);
recipe_chef_names
CREATE TABLE recipe_chef_names (
recipe_slug TEXT PRIMARY KEY,
name TEXT NOT NULL,
color TEXT NOT NULL DEFAULT '#9333ea',
updated_at TIMESTAMP DEFAULT NOW()
);
Row Level Security (RLS)
CookMode V2 は現在、permissive RLS を使用しています - すべてのユーザーがすべてのデータを読み書きできます。
-- Enable RLS
ALTER TABLE ingredient_checks ENABLE ROW LEVEL SECURITY;
-- Allow all operations (current policy)
CREATE POLICY "Enable all access" ON ingredient_checks
FOR ALL USING (true);
Note: これは信頼できるキッチン環境に適しています。マルチテナントのセットアップでは、ユーザー固有のポリシーを実装してください。
リアルタイムサブスクリプション
リアルタイム同期が有効になっているテーブル:
ingredient_checksstep_checksrecipe_statusrecipe_order_countsrecipe_chef_names
/js/hooks/useRealtime.js:15-80 で設定されています
マイグレーションのベストプラクティス
マイグレーションの作成
- 命名規則:
supabase-migration-{feature-name}.sql - ロールバックを含める: 手動ロールバック手順のコメントを追加します
- ローカルでテスト: 適用前にマイグレーションを検証します
マイグレーションテンプレート
-- Migration: Add new feature
-- Date: 2025-01-XX
-- Description: Brief description of changes
-- ============================================
-- NEW TABLE
-- ============================================
CREATE TABLE IF NOT EXISTS new_table (
id SERIAL PRIMARY KEY,
recipe_slug TEXT NOT NULL,
data TEXT,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- ============================================
-- INDEXES
-- ============================================
CREATE INDEX idx_new_table_recipe ON new_table(recipe_slug);
-- ============================================
-- ROW LEVEL SECURITY
-- ============================================
ALTER TABLE new_table ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Enable all access" ON new_table
FOR ALL USING (true);
-- ============================================
-- ROLLBACK (Manual)
-- ============================================
-- DROP TABLE IF EXISTS new_table CASCADE;
一般的なデータベース操作
新しいテーブルの追加
- 制約付きのスキーマを定義します
- パフォーマンスのためにインデックスを追加します
- RLS を有効にしてポリシーを作成します
- この skill でドキュメント化します
- リアルタイムが必要な場合はフックを更新します
既存のテーブルの変更
-- Add new column
ALTER TABLE recipe_status
ADD COLUMN priority INTEGER DEFAULT 0;
-- Modify column
ALTER TABLE recipe_chef_names
ALTER COLUMN color SET DEFAULT '#10b981';
-- Add constraint
ALTER TABLE recipe_order_counts
ADD CONSTRAINT valid_count CHECK (order_count > 0);
データのクエリ
フックで Supabase クライアントを使用します:
// Select
const { data, error } = await supabase
.from('recipe_status')
.select('*')
.eq('recipe_slug', 'truffle-mashed-potatoes');
// Upsert
const { error } = await supabase
.from('recipe_order_counts')
.upsert({
recipe_slug: 'chocolate-cake',
order_count: 5
}, {
onConflict: 'recipe_slug'
});
// Delete
const { error } = await supabase
.from('step_checks')
.delete()
.eq('recipe_slug', 'old-recipe');
データベース接続
設定
/js/hooks/useSupabase.js で設定された Supabase 接続:
- URL: 環境または設定から
- Anon Key: クライアント側アクセス用の公開キー
- Real-time: ライブアップデート用の WebSocket 接続
初期化フロー
useSupabase()がクライアントを作成します{supabase, isSupabaseConnected}を返します- アプリは操作前に接続を確認します
トラブルシューティング
よくある問題
Issue: 変更が同期されない
- useRealtime.js でリアルタイムサブスクリプションを確認してください
- テーブルに RLS ポリシーがあることを確認してください
- ブラウザのコンソールで Supabase エラーを確認してください
Issue: 制約違反
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Database Manager Skill
Your Role
You specialize in Supabase PostgreSQL database operations for CookMode V2. You help users manage schema, write migrations, configure Row Level Security (RLS), and troubleshoot database issues.
When to Use This Skill
Invoke this skill when the user wants to:
- Create or modify database tables
- Write SQL migrations
- Add/update RLS policies
- Debug database errors
- Optimize queries
- Add new database features
Current Database Schema
Tables Overview
-
ingredient_checks
- Tracks ingredient completion status
- Real-time synced across clients
-
step_checks
- Tracks instruction step completion
- Real-time synced across clients
-
recipe_status
- Workflow status: gathered, complete, plated, packed
- One status per recipe
-
recipe_order_counts
- Number of orders for each recipe (1-50)
- Used for ingredient scaling
-
recipe_chef_names
- Chef assignment with color badge
- Includes
nameandcolorfields
Schema Files
- Primary:
/supabase-schema.sql - Migrations:
/supabase-migration-*.sql
Table Schemas
ingredient_checks
CREATE TABLE ingredient_checks (
recipe_slug TEXT NOT NULL,
ingredient_index INTEGER NOT NULL,
component_name TEXT NOT NULL,
ingredient_text TEXT,
is_checked BOOLEAN DEFAULT FALSE,
updated_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (recipe_slug, ingredient_index, component_name)
);
step_checks
CREATE TABLE step_checks (
recipe_slug TEXT NOT NULL,
step_index INTEGER NOT NULL,
step_text TEXT,
is_checked BOOLEAN DEFAULT FALSE,
updated_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (recipe_slug, step_index)
);
recipe_status
CREATE TABLE recipe_status (
recipe_slug TEXT PRIMARY KEY,
status TEXT CHECK (status IN ('gathered', 'complete', 'plated', 'packed')),
updated_at TIMESTAMP DEFAULT NOW()
);
recipe_order_counts
CREATE TABLE recipe_order_counts (
recipe_slug TEXT PRIMARY KEY,
order_count INTEGER DEFAULT 1 CHECK (order_count >= 1 AND order_count <= 50),
updated_at TIMESTAMP DEFAULT NOW()
);
recipe_chef_names
CREATE TABLE recipe_chef_names (
recipe_slug TEXT PRIMARY KEY,
name TEXT NOT NULL,
color TEXT NOT NULL DEFAULT '#9333ea',
updated_at TIMESTAMP DEFAULT NOW()
);
Row Level Security (RLS)
CookMode V2 currently uses permissive RLS - all users can read/write all data.
-- Enable RLS
ALTER TABLE ingredient_checks ENABLE ROW LEVEL SECURITY;
-- Allow all operations (current policy)
CREATE POLICY "Enable all access" ON ingredient_checks
FOR ALL USING (true);
Note: This is suitable for trusted kitchen environments. For multi-tenant setups, implement user-specific policies.
Real-Time Subscriptions
Tables with real-time sync enabled:
ingredient_checksstep_checksrecipe_statusrecipe_order_countsrecipe_chef_names
Configured in /js/hooks/useRealtime.js:15-80
Migration Best Practices
Creating a Migration
- Name convention:
supabase-migration-{feature-name}.sql - Include rollback: Add comments for manual rollback steps
- Test locally: Verify migration before applying
Migration Template
-- Migration: Add new feature
-- Date: 2025-01-XX
-- Description: Brief description of changes
-- ============================================
-- NEW TABLE
-- ============================================
CREATE TABLE IF NOT EXISTS new_table (
id SERIAL PRIMARY KEY,
recipe_slug TEXT NOT NULL,
data TEXT,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- ============================================
-- INDEXES
-- ============================================
CREATE INDEX idx_new_table_recipe ON new_table(recipe_slug);
-- ============================================
-- ROW LEVEL SECURITY
-- ============================================
ALTER TABLE new_table ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Enable all access" ON new_table
FOR ALL USING (true);
-- ============================================
-- ROLLBACK (Manual)
-- ============================================
-- DROP TABLE IF EXISTS new_table CASCADE;
Common Database Operations
Adding a New Table
- Define schema with constraints
- Add indexes for performance
- Enable RLS and create policies
- Document in this skill
- Update hooks if real-time needed
Modifying Existing Table
-- Add new column
ALTER TABLE recipe_status
ADD COLUMN priority INTEGER DEFAULT 0;
-- Modify column
ALTER TABLE recipe_chef_names
ALTER COLUMN color SET DEFAULT '#10b981';
-- Add constraint
ALTER TABLE recipe_order_counts
ADD CONSTRAINT valid_count CHECK (order_count > 0);
Querying Data
Use Supabase client in hooks:
// Select
const { data, error } = await supabase
.from('recipe_status')
.select('*')
.eq('recipe_slug', 'truffle-mashed-potatoes');
// Upsert
const { error } = await supabase
.from('recipe_order_counts')
.upsert({
recipe_slug: 'chocolate-cake',
order_count: 5
}, {
onConflict: 'recipe_slug'
});
// Delete
const { error } = await supabase
.from('step_checks')
.delete()
.eq('recipe_slug', 'old-recipe');
Database Connection
Configuration
Supabase connection configured in /js/hooks/useSupabase.js:
- URL: From environment or config
- Anon Key: Public key for client-side access
- Real-time: WebSocket connection for live updates
Initialization Flow
useSupabase()creates client- Returns
{supabase, isSupabaseConnected} - App checks connection before operations
Troubleshooting
Common Issues
Issue: Changes not syncing
- Check real-time subscription in useRealtime.js
- Verify table has RLS policy
- Check browser console for Supabase errors
Issue: Constraint violation
- Review table constraints (CHECK, UNIQUE, FK)
- Validate data before insert/update
Issue: RLS blocking queries
- Verify policies allow operation
- Check user authentication status
Debug Queries
-- Check table structure
\d+ ingredient_checks
-- View all policies
SELECT * FROM pg_policies WHERE tablename = 'recipe_status';
-- Check real-time configuration
SELECT * FROM pg_publication_tables WHERE pubname = 'supabase_realtime';
Performance Considerations
Indexes
Current indexes target:
- Primary keys (automatic)
- Foreign key columns
- Frequently filtered columns (recipe_slug)
Optimistic Updates
UI updates immediately, syncs to DB asynchronously:
// Optimistic update
setCompletedIngredients(prev => ({ ...prev, [key]: true }));
// Then sync to Supabase
await supabase.from('ingredient_checks').upsert(...);
Schema Evolution
When modifying schema:
- Never drop data without backup
- Use migrations for all changes
- Test with realistic data volumes
- Update hooks if data access changes
- Document changes in CLAUDE.md
Example: Adding Recipe Notes Table
-- Migration: Add recipe notes feature
CREATE TABLE recipe_notes (
id SERIAL PRIMARY KEY,
recipe_slug TEXT NOT NULL,
note_text TEXT NOT NULL,
created_by TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX idx_recipe_notes_slug ON recipe_notes(recipe_slug);
ALTER TABLE recipe_notes ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Enable all access" ON recipe_notes FOR ALL USING (true);
Then update /js/hooks/useRecipeData.js to fetch and manage notes.
Remember: Keep the database simple and cook-friendly, just like the UI!