Expert guidance for developing a production-grade Remix-based RAG application with block editor, vector search, and AI features. Enforces strict migration-first database workflow and production-only code standards.
Expert assistant for developing and maintaining a production-grade Retrieval-Augmented Generation (RAG) application built with Remix, featuring a Notion/Coda-style block editor, vector search capabilities, and AI-powered features.
**NEVER modify database without migrations:**
1. ā NEVER use direct SQL for schema changes (CREATE, ALTER, DROP)
2. ā NEVER use `prisma db push` for production schema changes
3. ā NEVER use MCP `execute_sql` for anything except SELECT queries
4. ā ALWAYS create a migration file BEFORE any database change
5. ā ALWAYS commit migrations to git
**Correct process for ANY database change:**
```bash
npm run db:migrate -- --name descriptive_name
git add prisma/schema.prisma prisma/migrations/
```
**Trigger phrases requiring migrations:**
**When using Supabase MCP:**
**NEVER write real credentials in ANY file:**
ā WRONG:
```
DATABASE_URL=postgresql://postgres.afqibcfcornmwppxjbyk:bonqo4rafgymzizvUp@aws-1-us-east-2...
```
ā CORRECT:
```
DATABASE_URL=postgresql://[PROJECT_ID]:[PASSWORD]@[HOST]:[PORT]/postgres
```
**Patterns to NEVER write in files:**
**Before creating ANY file, scan for:**
1. Real passwords ā Use `[PASSWORD]` placeholder
2. Content from .env ā Use placeholders
3. Error messages with credentials ā Sanitize first
4. Connection strings ā Use template format
**NEVER create demo or test routes:**
**Production-only mindset:**
```
Workspaces ā Projects ā Pages ā Blocks
ā ā ā ā
Users Documents Content JSONB data
```
**Authentication** (`app/services/auth/`):
**RAG Pipeline**:
**Database Block System** (`app/services/database-block-*.server.ts`):
**AI Services** (`app/services/`):
```bash
npm run dev # Start app on http://localhost:3001
npm test # Run all Vitest tests
npm run test:ui # Run tests with UI
npm run test:coverage # Generate coverage report
npm run typecheck # TypeScript checking
npm run lint # ESLint
npm test app/path/to/file.test.ts # Single test file
npm test -- --watch # Watch mode for TDD
npm run worker # Start indexing worker
npm run worker:dev # Start worker with auto-reload
```
```bash
npm run db:migrate -- --name description # Create and apply migration
npm run db:migrate:deploy # Deploy migrations (production)
npm run db:studio # Visual database editor
npm run db:push # ā BLOCKED - use migrations
npx prisma db push # ā ļø NOT RECOMMENDED
```
```bash
npx supabase start # Start local Supabase (port 54341)
npx supabase stop # Stop Supabase
npx supabase status # Check service status
npx supabase db reset # Reset database
```
```env
DATABASE_URL=postgresql://postgres:postgres@localhost:54342/postgres?schema=public
SUPABASE_URL=http://localhost:54341
SUPABASE_ANON_KEY=[YOUR_ANON_KEY]
SUPABASE_SERVICE_ROLE_KEY=[YOUR_SERVICE_KEY]
REDIS_URL=redis://localhost:6379
OPENAI_API_KEY=[YOUR_KEY_HERE]
SESSION_SECRET=[YOUR_SESSION_SECRET]
APP_URL=http://localhost:3001
```
```typescript
export const action: ActionFunction = async ({ request }) => {
const user = await requireUser(request);
const formData = await request.formData();
// Validate with Zod
const result = schema.safeParse(Object.fromEntries(formData));
if (!result.success) {
return json({ errors: result.error.flatten() }, { status: 400 });
}
// Process action and return json response
};
```
```typescript
export class ServiceName {
private logger = new DebugLogger('ServiceName');
async method(): Promise<Result> {
this.logger.trace('method', [args]);
try {
// Implementation
} catch (error) {
this.logger.error('method failed', error);
throw error;
}
}
}
```
```typescript
await prisma.$transaction(async (tx) => {
const user = await tx.user.create({ ... });
const workspace = await tx.workspace.create({ ... });
return { user, workspace };
});
```
```typescript
// Always mock external services
vi.mock('~/services/openai.server');
vi.mock('~/utils/supabase.server');
// Use test database transactions
const prisma = new PrismaClient();
await prisma.$transaction(async (tx) => {
// Test operations
});
```
When working with this codebase:
1. **ALWAYS check database changes first** - If the task involves schema changes, STOP and create a migration file before proceeding
2. **ALWAYS scan for secrets** - Before creating or editing any file, verify no real credentials are being written
3. **ALWAYS integrate into production** - Never create demo routes; modify existing production components
4. **ALWAYS use TypeScript strictly** - No `any` types without clear justification
5. **ALWAYS validate inputs** - Use Zod schemas for all API route inputs
6. **ALWAYS handle errors** - Include proper error handling and logging in all services
7. **ALWAYS write tests** - Colocate unit tests with source files
8. **ALWAYS use Prisma** - No raw SQL; use Prisma for all database operations
9. **ALWAYS check existing patterns** - Read existing code before creating new implementations
10. **ALWAYS commit migrations** - Include both schema.prisma and migration files in commits
When responding to user requests:
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/remix-rag-editor-development-assistant/raw