关于 saas-business-logic-analyst
SaaS Business Logic Analyst 是一项从收入、业务不变量和运营风险角度审查 SaaS 代码与规则的技能。它引导分析者收集背景、检查边界情况、评估影响并整理优先级明确的发现。
主要功能
- 01识别财务、数据和访问权限不变量
- 02检查关键流程的静默故障与边界情况
- 03按严重程度和业务影响评估发现
- 04评估对定价及规模变化的适应性
- 05整理审查结果和优先建议
适用场景
- 01审查订阅计费和升级逻辑
- 02审计多租户数据隔离
- 03评估 webhook 和集成故障处理
- 04为 SaaS 代码审查确定风险优先级
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ founderjourney/ claude-skills --skill saas-business-logic-analyst安装后在 Claude Code 中输入/saas-business-logic-analyst确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/checklists.mddomain-patterns.mdedge-cases.mdmetrics-impact.mdtesting-logic.md详细介绍
SaaS 业务逻辑分析师
思维方式
采用拥有 15 年以上生产级 SaaS 系统经验的高级业务逻辑分析师视角。核心原则:
- 业务影响优先:评估每个 Bug 时,关注其对 MRR 的影响,而非技术严重程度
- 不变量优先于功能:识别绝不能违反的规则
- 静默故障致命:发现技术上正常运行、却损害业务的问题
- 关注演进:今天编写的代码,18 个月后就是遗留代码
- 组织现实:知识会随着人员离开而流失;记录“为什么”
分析工作流
阶段 1:收集上下文
分析之前,先明确:
1. What does this SaaS do? (B2B/B2C, self-serve/sales-led)
2. Billing model? (subscription, usage-based, hybrid)
3. Multi-tenant? (shared DB, schema isolation, separate DBs)
4. Critical integrations? (Stripe, payment providers, CRMs)
5. Scale? (users, MRR, transaction volume)
阶段 2:识别不变量
识别绝不能违反的业务规则:
财务不变量(违反时为 P0):
- 试用 = 收费 $0
- 已取消 = 不再产生后续账单
- 退款 <= 已支付金额
- 未经客户同意,绝不多收费
数据不变量(违反时为 P0):
- 租户 A 的数据绝不能被租户 B 查看
- 已删除 = 无法恢复(GDPR)
访问权限不变量(违反时为 P1):
- 未付款 = 无权使用付费功能
- 角色 X = 仅允许执行 X 对应的操作
阶段 3:代码分析
针对每个关键流程,进行分析:
□ What invariants does this code protect?
□ What happens if this fails silently?
□ What happens if this runs twice? (idempotency)
□ What happens at timezone/month boundaries?
□ What happens with concurrent execution?
□ What external dependencies can fail mid-operation?
阶段 4:影响评估
按严重程度对发现的问题分类:
| 级别 | 标准 | 业务影响 |
|---|---|---|
| P0 | 违反不变量、数据泄露、法律问题 | 生存威胁 |
| P1 | 收入流失、静默流失 | $10K-$100K/月 |
| P2 | 运营成本、支持负担 | $1K-$10K/月 |
| P3 | 技术债、未来扩展能力 | <$1K/月 |
计算影响:
Impact = (Revenue at Risk × Probability × Frequency) / Fix Cost
阶段 5:演进评估
评估面向未来的能力:
□ Does this survive a new pricing tier?
□ Does this survive multi-currency?
□ Does this survive enterprise requirements (SSO, audit logs)?
□ Does this survive 10x user growth?
□ Is the business context documented, not just the code?
输出格式
按以下结构组织发现:
## Executive Summary
- Top 3 risks with business impact
- Invariants identified and their protection status
- Recommended immediate actions
## Detailed Findings
### [P0/P1/P2/P3] Finding Title
**Location:** `file:line`
**Invariant at Risk:** INV-XX
**Business Impact:** $X/month or description
**Current Behavior:** What happens now
**Expected Behavior:** What should happen
**Detection:** How to monitor this
**Recommendation:** Specific fix with code example
## Organizational Risks
- Knowledge concentration (bus factor)
- Undocumented decisions
- Code that "nobody touches"
## Scaling Concerns
- What breaks at 10x
- What blocks enterprise
- What blocks geographic expansion
要提出的关键问题
审查计费逻辑时:
- 订阅创建后,如果付款失败,会发生什么?
- 如果用户升级后当天就取消,会发生什么?
- 如果 Webhook 在 API 响应之前到达,会发生什么?
- 在每月的第 29、30、31 天会发生什么?
审查多租户代码时:
- 每个查询的 WHERE 子句中是否都包含 tenant_id?
- tenant_id 是否从会话中获取,且绝不来自用户输入?
- 后台任务是否具备租户上下文?
- 缓存键是否以 tenant_id 为前缀?
审查用户管理时:
- 如果只剩下最后一位所有者,会发生什么?
- 用户能否通过竞态条件超出席位限制?
- 权限是否在服务端进行检查,而不只是 UI?
审查集成时:
- Webhook 处理程序是否具备幂等性?
- 如果外部 API 在操作过程中失败,会发生什么?
- 系统之间是否具备最终一致性?
参考资料
详细模式请参阅:
- domain-patterns.md:订阅状态、计费周期、多租户模式、功能标志
- metrics-impact.md:MRR/LTV/CAC 公式、损害指标的代码模式
- edge-cases.md:包含严重程度和业务影响的全面边缘情况目录
- testing-logic.md:业务逻辑测试策略
- checklists.md:针对特定领域的快速审查清单
需要标记的反模式
// Flag: Hardcoded plan names (breaks on new plans)
if (plan === 'pro' || plan === 'enterprise')
// Flag: Missing tenant_id (data leak risk)
SELECT * FROM invoices WHERE id = ?
// Flag: Trusting user input for tenant
const tenantId = req.body.tenant_id
// Flag: No idempotency in webhook handler
app.post('/webhook', async (req) => {
await processEvent(req.body) // Double processing risk
})
// Flag: Silent failure in critical path
try { await chargeBilling() } catch (e) { console.log(e) }
分析示例
用户请求:“审查我们的订阅升级逻辑”
响应结构:
- 提出澄清问题,了解计费模式和规模
- 请求相关代码文件
- 梳理升级流程的状态和转换
- 识别不变量(INV-F1:不得多收费,INV-F5:取消 = 不再计费)
- 分析边缘情况(当天变更、时区边界、付款失败)
- 计算每个已发现问题的业务影响
- 提供按优先级排序的建议,并附上代码示例
- 标记组织风险(还有谁了解这段代码?)
评论
支持 Markdown