Database First

REQUIRED before implementing any game feature, scoring logic, state transition, or decision-making. ALL business logic lives in PostgreSQL - frontend is presentation only. Load this to understand where code belongs: database function vs component. Covers RPC patterns, SECURITY DEFINER, and anti-patterns.

8 stars 3 forksDatabases Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add Freddy-CHEN-ux/00_claude_skills

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add Freddy-CHEN-ux/00_claude_skills --skill database-first
Manual install
git clone --depth 1 https://github.com/Freddy-CHEN-ux/00_claude_skills.git /tmp/00_claude_skills
mkdir -p ~/.claude/skills
cp -r /tmp/00_claude_skills/skills/database-first ~/.claude/skills/database-first

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Database-First Architecture

The Iron Law of this project: **ALL business logic lives in PostgreSQL.**

> **Announce:** "I'm using database-first to ensure this logic goes in the right place."

## The Rule

```
FRONTEND (src/)         → Presentation + User Input ONLY
DATABASE (supabase/db/) → Game Logic + State + Decisions
EDGE FUNCTIONS          → LLM/Embedding Integration ONLY
```

## Where Does This Code Go?

| Feature | Database | Frontend |
|---------|----------|----------|
| Calculate confidence score | `game_logic.calculate_confidence()` | NEVER |
| Determine next question | `game_logic.get_next_turn()` | NEVER |
| Filter candidates | `game_logic.filter_*_candidates()` | NEVER |
| Check win condition | `game_logic.check_guess_decision()` | NEVER |
| Validate game state | DB constraints + RLS | NEVER |
| Render question UI | NEVER | Vue component |
| Display map markers | NEVER | MapLibre layer |
| Fetch game state | RPC returns it | Store calls RPC |
| Handle user input | NEVER | Vue event handler |

## Anti-Pattern: Logic in Frontend

```typescript
// WRONG: Scoring logic in Vue component
const confidence = computed(() => {
  const probabilities = candidates.value.map(c => c.score)
  const maxProb = Math.max(...probabilities)
  const margin = maxProb - (probabilities[1] || 0)
  // THIS IS GAME LOGIC - SHOULD BE IN DATABASE
  return { maxProb, margin }
})
```

**Why it's wrong:**
- Different clients would calculate differently
- Can't use for learning/training data
Read the full skill on GitHub

Details

Skill name
database-first
Path
skills/database-first/SKILL.md
Repo updated
10 January 2026

FAQ

What does the Database First skill do?

REQUIRED before implementing any game feature, scoring logic, state transition, or decision-making. ALL business logic lives in PostgreSQL - frontend is presentation only. Load this to understand where code belongs: database function vs component. Covers RPC patterns, SECURITY DEFINER, and anti-patterns.

How do I install the Database First skill?

Claude Code plugin: /plugin marketplace add Freddy-CHEN-ux/00_claude_skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Database First popular?

It lives in Freddy-CHEN-ux/00_claude_skills, which has 8 GitHub stars and 3 forks.

Related skills

Browse the most popular Claude skills, all databases skills, or write your own with the skills generator.