supabase-postgres-best-practices
Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
api-tester
API 自动化测试 - OpenAPI 解析、测试用例生成、集成测试
Full skill instructions
当用户要求测试 API、生成测试用例、接口测试、集成测试时激活此技能。
按优先级查找 API 定义:
openapi.yaml、swagger.json)/api/、/routes/、/controllers/)OpenAPI 解析方法:
# 使用 swagger-cli 验证
npx @apidevtools/swagger-cli validate openapi.yaml
# 使用 redocly 提取端点信息
npx @redocly/cli lint openapi.yaml
# 从 OpenAPI 提取所有路径
grep -E '^\s+/' openapi.yaml | awk '{print $2}'
为每个 endpoint 生成三类测试:
根据项目技术栈选择测试框架并生成代码。
策略:
| 策略 | 适用场景 | 工具/方法 |
|---|---|---|
| 固定数据 | 简单接口、确定性测试 | JSON fixture 文件 |
| Faker 随机生成 | 大量测试数据、压力测试 | @faker-js/faker、Faker(Python) |
| 工厂模式 | 复杂对象关系 | factory_boy、fishery |
| 从 Schema 生成 | 基于 OpenAPI 自动生成 | json-schema-faker |
import pytest
# 正常场景
def test_get_users_success(client):
response = client.get("/api/users")
assert response.status_code == 200
assert isinstance(response.json(), list)
# 边界值测试
def test_create_user_empty_name(client):
response = client.post("/api/users", json={"name": ""})
assert response.status_code == 422
# 认证测试
def test_get_users_unauthorized(client):
response = client.get("/api/users", headers={})
assert response.status_code == 401
# 参数化批量测试
@pytest.mark.parametrize("name,expected_status", [
("Alice", 200),
("", 422),
("a" * 500, 422),
(None, 422),
])
def test_create_user_validation(client, name, expected_status):
response = client.post("/api/users", json={"name": name})
assert response.status_code == expected_status
import request from 'supertest';
import app from '../src/app';
describe('GET /api/users', () => {
it('应返回用户列表', async () => {
const res = await request(app).get('/api/users');
expect(res.status).toBe(200);
expect(Array.isArray(res.body)).toBe(true);
});
it('未认证应返回 401', async () => {
const res = await request(app).get('/api/users');
expect(res.status).toBe(401);
});
});
describe('POST /api/users', () => {
it('空名称应返回 422', async () => {
const res = await request(app)
.post('/api/users')
.send({ name: '' });
expect(res.status).toBe(422);
});
it('有效数据应返回 201', async () => {
const res = await request(app)
.post('/api/users')
.send({ name: 'Alice', email: '[email protected]' });
expect(res.status).toBe(201);
expect(res.body).toHaveProperty('id');
});
});
#!/bin/bash
BASE_URL="http://localhost:3000/api"
# 正常请求
echo "=== GET /users ==="
curl -s -w "\nHTTP Status: %{http_code}\n" \
-H "Authorization: Bearer *** \
"$BASE_URL/users"
# POST 创建资源
echo "=== POST /users ==="
curl -s -w "\nHTTP Status: %{http_code}\n" \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer *** \
-d '{"name":"Alice","email":"[email protected]"}' \
"$BASE_URL/users"
# 错误场景 - 空 body
echo "=== POST /users (empty) ==="
curl -s -w "\nHTTP Status: %{http_code}\n" \
-X POST \
-H "Content-Type: application/json" \
-d '{}' \
"$BASE_URL/users"
beforeEach 或 fixture 管理测试数据的初始化和清理Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
Step-by-step configuration guides for Prisma ORM across PostgreSQL, MySQL, SQLite, MongoDB, SQL Server, CockroachDB, and Prisma Postgres.
Complete Prisma Client API reference for model queries, CRUD operations, filtering, relations, and transactions.
Complete reference for Prisma CLI commands, options, and workflows across setup, migrations, and database operations.
prisma postgres
prisma driver adapter implementation
prisma upgrade v7
prisma postgres setup
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.
>-
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.
Opus.ai: Revolutionize Your Web Experience
Build a no-code AI app in minutes.
An IDE for code migration from legacy to modern frameworks through coding agents.
Automate CGI animation in live-action scenes
Branded artistic QR-code concepts
Launch a website in seconds with AI.
Streamline Your Coding Experience with AI Code Helper
Convert any screenshot or design to clean code.