下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“projection-patterns”。 用户要求基础投影器模板
预期结果:
提供 Python Projection 基类,包含 name、handles() 和 apply() 的抽象方法。包含具有检查点管理和批处理的 Projector 运行器。展示数据库操作的 async/await 模式。
正在使用“projection-patterns”。 用户需要订单摘要投影
预期结果:
提供 OrderSummaryProjection 类,处理 OrderCreated、OrderItemAdded、OrderShipped 事件。每个处理程序更新特定列。演示参数化 SQL 查询和连接池。
正在使用“projection-patterns”。 用户想要重建损坏的投影
预期结果:
解释重建过程:删除检查点,可选择清除读模型表,从位置 0 重新运行投影。强调幂等性要求以安全重播。
安全审计
安全This skill contains documentation and Python code examples for CQRS projection patterns. Static analyzer flagged markdown code blocks as shell commands (false positive). URLs are documentation references, not network calls. No executable code, cryptographic operations, or system access detected. Safe for publication.
质量评分
你能构建什么
电商订单投影
构建读模型,将订单事件聚合为客户可见的摘要,并提供实时状态更新。
从事件构建搜索索引
创建 Elasticsearch 投影,使产品目录与领域事件保持同步以实现全文搜索。
分析仪表板数据
实现聚合投影,计算每日指标,如销售总额和用户活动。
试试这些提示
I need to build a read model for order events. Show me how to create a basic projector that handles OrderCreated and OrderUpdated events, stores checkpoints, and updates a SQL table.
Create a projection that syncs product domain events to Elasticsearch. Include handling for ProductCreated, ProductUpdated, and ProductDeleted events with proper error handling.
Show me how to build an aggregating projection that computes daily sales metrics from OrderCompleted events. Include UPSERT logic for efficient updates.
I need a projection that updates multiple tables atomically when processing CustomerOrderPlaced events. Show transaction handling and rollback patterns.
最佳实践
- 使投影具有幂等性 - 可以安全地多次重播事件而不会产生副作用
- 在每个事件后存储检查点以在失败后启用恢复
- 对多表更新使用数据库事务以保持一致性
避免
- 耦合投影 - 每个投影应该是独立和可隔离的
- 跳过错误处理 - 未处理的异常会停止投影并导致数据延迟
- 乱序处理事件 - 始终遵循 global_position 排序