**Category:** Learning
Sets up the Supabase learning system database schema with tables, views, and functions.
/plugin marketplace add nguyenthienthanh/aura-frog/plugin install aura-frog@aurafroglearn/Category: Learning Purpose: Set up the Supabase learning system database schema
From Claude Code terminal:
./scripts/supabase/setup.sh # Run setup
./scripts/supabase/setup.sh --check # Check if schema exists
./scripts/supabase/setup.sh --help # Show help
Or via command:
/learn:setup # Interactive setup
/learn:setup --check # Check if schema exists
When user runs /learn:setup, Claude MUST actually run the setup script or verify schema.
DO NOT just show instructions. DO check if schema exists and run setup if needed.
# ALWAYS source env first
source .envrc 2>/dev/null || source .claude/.envrc 2>/dev/null || true
Run bootstrap.sql in Supabase SQL Editor:
File: scripts/supabase/bootstrap.sql
CREATE OR REPLACE FUNCTION exec_sql(query text)
RETURNS json LANGUAGE plpgsql SECURITY DEFINER AS $$
BEGIN
EXECUTE query;
RETURN json_build_object('success', true);
EXCEPTION WHEN OTHERS THEN
RETURN json_build_object('success', false, 'error', SQLERRM);
END;
$$;
./scripts/supabase/setup.sh
This will:
Copy and paste scripts/supabase/schema.sql into Supabase SQL Editor.
When user runs /learn:setup, Claude should:
echo "Checking environment..."
echo "SUPABASE_URL: ${SUPABASE_URL:+✓ set}"
echo "SUPABASE_SECRET_KEY: ${SUPABASE_SECRET_KEY:+✓ set}"
If either is missing, tell user to:
.envrc.template to .envrcsource .envrc# Test if af_feedback table exists
response=$(curl -s -w "%{http_code}" -o /tmp/schema_check.json \
"${SUPABASE_URL}/rest/v1/af_feedback?limit=1" \
-H "apikey: ${SUPABASE_SECRET_KEY}" \
-H "Authorization: Bearer ${SUPABASE_SECRET_KEY}")
if [ "$response" = "200" ]; then
echo "✅ Schema already exists"
exit 0
fi
# Test if exec_sql function exists
response=$(curl -s -w "%{http_code}" -o /tmp/bootstrap_check.json \
-X POST "${SUPABASE_URL}/rest/v1/rpc/exec_sql" \
-H "apikey: ${SUPABASE_SECRET_KEY}" \
-H "Authorization: Bearer ${SUPABASE_SECRET_KEY}" \
-H "Content-Type: application/json" \
-d '{"query": "SELECT 1"}')
if [ "$response" != "200" ]; then
echo "❌ Bootstrap function not found"
echo ""
echo "Run this SQL in Supabase Dashboard → SQL Editor:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cat scripts/supabase/bootstrap.sql
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 1
fi
./scripts/supabase/setup.sh
Or if running manually:
node scripts/supabase/setup-schema.cjs
# Confirm tables were created
curl -s "${SUPABASE_URL}/rest/v1/af_feedback?limit=1" \
-H "apikey: ${SUPABASE_SECRET_KEY}" \
-H "Authorization: Bearer ${SUPABASE_SECRET_KEY}"
echo "✅ Learning system setup complete!"
echo "Run /learn:status to verify"
🐸 Aura Frog - Supabase Schema Setup
📡 Supabase URL: https://your-project.supabase.co
1. Checking exec_sql function...
✓ exec_sql function exists
2. Reading schema file...
✓ Read 15234 bytes
3. Parsing SQL statements...
✓ Found 42 statements
4. Executing statements...
[1/42] Executing... ✓
[2/42] Executing... ✓
...
[42/42] Executing... ✓
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Summary:
✓ Successful: 42
✅ Schema setup complete!
Next steps:
1. Run /learn:status to verify connection
2. Run /learn:analyze to check for patterns
| Table | Purpose |
|---|---|
af_feedback | User corrections, approvals, ratings |
af_workflow_metrics | Workflow execution data |
af_agent_performance | Agent success tracking |
af_learned_patterns | Identified patterns |
af_knowledge_base | Persistent learnings |
| View | Purpose |
|---|---|
v_agent_success_rates | Agent performance by task |
v_common_patterns | Pattern summary |
v_improvement_suggestions | Actionable suggestions |
v_workflow_trends | Weekly trends |
v_feedback_summary | Feedback statistics |
| Function | Purpose |
|---|---|
record_feedback() | Insert feedback record |
update_pattern_frequency() | Increment pattern count |
get_agent_recommendation() | Get best agent for task |
Run this in Supabase SQL Editor first:
CREATE OR REPLACE FUNCTION exec_sql(query text)
RETURNS json LANGUAGE plpgsql SECURITY DEFINER AS $$
BEGIN
EXECUTE query;
RETURN json_build_object('success', true);
EXCEPTION WHEN OTHERS THEN
RETURN json_build_object('success', false, 'error', SQLERRM);
END;
$$;
SUPABASE_SECRET_KEY is the Secret key (not Publishable)Safe to ignore - the schema uses CREATE TABLE IF NOT EXISTS.
/learn:status - Check learning system status/learn:analyze - Run pattern analysis/learn:apply - Apply improvementsVersion: 1.0.0