一键导入
sba
Story-Based Architecture conventions for this codebase. Apply when implementing or refactoring use cases.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Story-Based Architecture conventions for this codebase. Apply when implementing or refactoring use cases.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | SBA |
| description | Story-Based Architecture conventions for this codebase. Apply when implementing or refactoring use cases. |
This codebase follows Story-Based Architecture. Every business operation is a self-contained narrative living in a single file. Apply these principles strictly.
Every use case follows the same pattern:
def use_case(args):
# 1. Load: gather all data needed upfront
...
# 2. Validate: check every precondition before any mutation
...
# 3. Execute: perform calculations and mutations
...
Load everything first, validate everything, then mutate. No interleaving unless there is a performance justification.
The behavior of a use case must be visible by reading only that file. Avoid:
Two use cases that look similar might serve different business purposes. Keep them separate. Similar code is not duplication when it can evolve independently.
Sandi Metz: "Duplication is far cheaper than the wrong abstraction."
DRY applies to knowledge, not to code. Hunt and Thomas: "Every piece of knowledge must have a single, unambiguous, authoritative representation."
When something is genuinely shared across use cases, share only the bare minimum and do not over generalize. Keep the boundaries of what is shared minimal in order to avoid dependencies and abstractions that will make the code harder to read.
Files are named after the business operation they perform: place_order.py. Not OrderHandler.py or OrderService.py. Open the file, see the story.
domain folder. Use a meaningful filename. It is ok to reuse the same filename if the knowledge falls in the same domain. For example, if you have two use cases that need to share the same business rules for calculating discounts, you can create a domain/discounts.py file and put the shared logic there.