用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/amo-tech-ai/rocket-path-ai --skill saas-platforms命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | saas-platforms |
| description | SaaS architecture, multi-tenancy, and subscription management |
| domain | domain-applications |
| version | 1.0.0 |
| tags | ["saas","multi-tenancy","subscriptions","billing","onboarding"] |
| triggers | {"keywords":{"primary":["saas","multi-tenant","subscription","billing","tenant"],"secondary":["onboarding","feature flag","usage billing","plan","pricing tier"]},"context_boost":["platform","b2b","enterprise","organization"],"context_penalty":["mobile","game","desktop"],"priority":"high"} |
Building Software-as-a-Service applications with multi-tenancy, subscription billing, and user management.
// Strategy 1: Shared database with tenant_id column
interface TenantEntity {
tenantId: string;
// ... other fields
}
// Middleware to inject tenant context
function tenantMiddleware(req: Request, res: Response, next: NextFunction) {
const tenantId = req.headers['x-tenant-id'] || req.user?.tenantId;
if (!tenantId) {
return res.status(400).json({ error: 'Tenant ID required' });
}
req.tenantId = tenantId;
next();
}
// Prisma middleware for automatic tenant filtering
prisma.$use(async (params, next) => {
const tenantId = getCurrentTenantId();
if (params.model && hasTenantId(params.model)) {
// Add tenant filter to queries
if (params.action === 'findMany' || params.action === 'findFirst') {
params.args.where = {
...params.args.where,
tenantId,
};
}
// Add tenant ID to creates
if (params.action === 'create') {
params.args.data.tenantId = tenantId;
}
}
return next(params);
});
// Strategy 2: Schema per tenant (PostgreSQL)
async function createTenantSchema(tenantId: string) {
await prisma.$executeRaw`CREATE SCHEMA IF NOT EXISTS ${tenantId}`;
// Run migrations for new schema
await runMigrations(tenantId);
}
function getTenantConnection(tenantId: string) {
return new PrismaClient({
datasources: {
db: {
url: `${process.env.DATABASE_URL}?schema=${tenantId}`,
},
},
});
}
// Strategy 3: Database per tenant
async function createTenantDatabase(tenantId: string) {
const dbName = `tenant_${tenantId}`;
await adminDb.$executeRaw`CREATE DATABASE ${dbName}`;
return new PrismaClient({
datasources: {
db: {
url: `postgresql://user:pass@host:5432/${dbName}`,
},
},
});
}
// Row-level security with Prisma
const prisma = new PrismaClient().$extends({
query: {
$allModels: {
async findMany({ model, operation, args, query }) {
const tenantId = getCurrentTenantId();
args.where = { ...args.where, tenantId };
return query(args);
},
async create({ model, operation, args, query }) {
const tenantId = getCurrentTenantId();
args.data = { ...args.data, tenantId };
return query(args);
},
},
},
});
// PostgreSQL Row Level Security
/*
CREATE POLICY tenant_isolation ON projects
USING (tenant_id = current_setting('app.tenant_id')::uuid);
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
*/
// Set tenant context for RLS
async function withTenantContext<T>(
tenantId: string,
fn: () => Promise<T>
): Promise<T> {
await prisma.$executeRaw`SET app.tenant_id = ${tenantId}`;
try {
return await fn();
} finally {
await prisma.;
}
}
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// Create subscription
async function createSubscription(
customerId: string,
priceId: string,
trialDays?: number
) {
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{ price: priceId }],
trial_period_days: trialDays,
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: ['latest_invoice.payment_intent'],
});
return subscription;
}
// Update subscription
async function updateSubscription(subscriptionId: string, newPriceId: string) {
const subscription = await stripe.subscriptions.retrieve(subscriptionId);
return stripe.subscriptions.(subscriptionId, {
: [
{
: subscription..[].,
: newPriceId,
},
],
: ,
});
}
() {
(immediate) {
stripe..(subscriptionId);
}
stripe..(subscriptionId, {
: ,
});
}
() {
(event.) {
:
: {
subscription = event.. .;
(subscription);
;
}
: {
subscription = event.. .;
(subscription.);
;
}
: {
invoice = event.. .;
(invoice);
;
}
: {
invoice = event.. .;
(invoice);
;
}
}
}
() {
: <, > = {
: ,
: ,
: ,
};
prisma..({
: { : subscription. },
: {
: subscription.,
: subscription.,
: planMapping[subscription..[]..] || ,
: (subscription. * ),
},
});
}
// Track usage
async function recordUsage(
subscriptionItemId: string,
quantity: number,
timestamp?: number
) {
await stripe.subscriptionItems.createUsageRecord(subscriptionItemId, {
quantity,
timestamp: timestamp || Math.floor(Date.now() / 1000),
action: 'increment',
});
}
// Usage tracking service
class UsageTracker {
private buffer: Map<string, number> = new Map();
private flushInterval: NodeJS.Timeout;
constructor(private flushIntervalMs = 60000) {
this.flushInterval = setInterval(() => this.flush(), flushIntervalMs);
}
track(orgId: string, metric: string, amount = ) {
key = ;
..(key, (..(key) || ) + amount);
}
() {
entries = .(..());
..();
( [key, amount] entries) {
[orgId, metric] = key.();
prisma..({
: {
: orgId,
metric,
amount,
: (),
},
});
org = prisma..({
: { : orgId },
: { : },
});
(org?.) {
(org., amount);
}
}
}
}
interface Plan {
id: string;
name: string;
features: {
[key: string]: boolean | number;
};
limits: {
[key: string]: number;
};
}
const plans: Record<string, Plan> = {
free: {
id: 'free',
name: 'Free',
features: {
basicAnalytics: true,
advancedAnalytics: false,
apiAccess: false,
customBranding: false,
},
limits: {
projects: 3,
teamMembers: 1,
storage: 100, // MB
apiCalls: 1000,
},
},
pro: {
id: 'pro',
name: 'Pro',
features: {
basicAnalytics: true,
advancedAnalytics: true,
apiAccess: ,
: ,
},
: {
: ,
: ,
: ,
: ,
},
},
: {
: ,
: ,
: {
: ,
: ,
: ,
: ,
},
: {
: -,
: -,
: -,
: -,
},
},
};
(): {
plan = plans[org.];
plan?.[feature] ?? ;
}
(): {
plan = plans[org.];
limit = plan?.[resource] ?? ;
limit === - || current < limit;
}
() {
(: , : , : ) => {
org = (req.);
(!(org, feature)) {
res.().({
: ,
: ,
: (feature),
});
}
();
};
}
interface OnboardingStep {
id: string;
title: string;
completed: boolean;
skippable: boolean;
}
async function getOnboardingProgress(userId: string) {
const user = await prisma.user.findUnique({
where: { id: userId },
include: { organization: true },
});
const steps: OnboardingStep[] = [
{
id: 'profile',
title: 'Complete your profile',
completed: !!user.name && !!user.avatar,
skippable: true,
},
{
id: 'invite_team',
title: 'Invite team members',
completed: user.organization.memberCount > 1,
skippable: true,
},
{
id: 'create_project',
title: 'Create your first project',
completed: user.. > ,
: ,
},
{
: ,
: ,
: user.. > ,
: ,
},
];
completedCount = steps.( s.).;
{
steps,
: .((completedCount / steps.) * ),
: steps.( s. || s.),
};
}
OpenClaw Gateway setup, configuration, and best practices. Use when installing OpenClaw, configuring channels (WhatsApp/Telegram/Discord), setting up providers (OpenAI/Google/Anthropic), creating skills, managing the gateway daemon, or troubleshooting OpenClaw issues. Triggers on: openclaw, gateway, whatsapp channel, telegram bot, openclaw skill, openclaw config, openclaw install, openclaw cron, openclaw security.
Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations, help choosing the latest model for a use case, or explicit GPT-5.4 upgrade and prompt-upgrade guidance; prioritize OpenAI docs MCP tools, use bundled references only as helper context, and restrict any fallback browsing to official OpenAI domains.
Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. **Trigger when user asks to:** - Store or search vector embeddings in PostgreSQL - Set up semantic search, similarity search, or nearest neighbor search - Create HNSW or IVFFlat indexes for vectors - Implement RAG (Retrieval Augmented Generation) with PostgreSQL - Optimize pgvector performance, recall, or memory usage - Use binary quantization for large vector datasets **Keywords:** pgvector, embeddings, semantic search, vector similarity, HNSW, IVFFlat, halfvec, cosine distance, nearest neighbor, RAG, LLM, AI search Covers: halfvec storage, HNSW index configuration (m, ef_construction, ef_search), quantization strategies, filtered search, bulk loading, and performance tuning. **This project:** We use OpenAI text-embedding-3-small (1536) and store as vector(1536) in knowledge_chunks. halfvec is an optional future optimization; apply this skill's tuning (ef_search, iterative_scan
基于 SOC 职业分类