sliced-bread-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSliced Bread Review
Sliced Bread审查
Review the target change set against the Sliced Bread architecture. The full
rationale lives at
https://cheeselord.dev/sliced-bread-architecture/reference/sliced-bread/;
this skill is the operational checklist.
对照Sliced Bread架构审查目标变更集。完整的原理说明请查看https://cheeselord.dev/sliced-bread-architecture/reference/sliced-bread/;此技能是可落地的检查清单。
Scope
审查范围
Determine the review target from the invocation, in priority order:
- An explicit path, diff, branch, or PR named by the user.
- The current branch's diff against the default branch.
- Uncommitted changes ().
git diff HEAD
Review only the changed files plus any file a changed import points at.
按优先级从调用信息中确定审查目标:
- 用户指定的明确路径、diff、分支或PR。
- 当前分支与默认分支的差异。
- 未提交的变更()。
git diff HEAD
仅审查变更文件以及变更导入指向的任何文件。
The Five Checks
五项检查
Run every check against every changed file. Cite and quote the
offending import or definition for each finding.
file:line对每个变更文件执行所有检查。每个问题需标注并引用违规的导入或定义内容。
file:line1. Import direction
1. 导入方向
Arrows may only point in a permitted direction. Only the composition root
(, ) may import concrete adapters, and nothing imports
. A slice may import a sibling slice's public seam directly.
The arrows describe permitted direction, not required directories — a repo with
no layer is not in violation.
<!-- doctrine:arrows:start -->
app/bootstrapmainentrypoints/entrypoints/text
entrypoints/ -> app/ -> domains/* -> domains/common/
app/bootstrap -> adapters/ (composition root only)
adapters/ -> domains/* (implement domain ports)
Never:
app/use_cases/* -> adapters/*
domains/* -> adapters/ | app/ | entrypoints/
adapters/* -> app/ | entrypoints/
common/ -> sibling domains
anything -> entrypoints/Any inversion of these arrows is a blocker; a use case importing a concrete
adapter is medium.
箭头仅可指向允许的方向。只有组合根(、)可导入具体适配器(adapter),且任何内容都不得导入。切片可直接导入同级切片的公共接口。箭头描述的是允许的方向,而非必需的目录——没有层的仓库不违反规则。
<!-- doctrine:arrows:start -->
app/bootstrapmainentrypoints/entrypoints/text
entrypoints/ -> app/ -> domains/* -> domains/common/
app/bootstrap -> adapters/ (composition root only)
adapters/ -> domains/* (implement domain ports)
Never:
app/use_cases/* -> adapters/*
domains/* -> adapters/ | app/ | entrypoints/
adapters/* -> app/ | entrypoints/
common/ -> sibling domains
anything -> entrypoints/任何箭头方向的反转均为阻塞级(blocker);用例导入具体适配器属于**中等(medium)**问题。
2. Crust integrity
2. 外壳完整性
External consumers use a slice's public seam in the language's native form —
exported identifiers in Go, the package surface in Python, an index
module in TypeScript, a public class surface elsewhere — never its internals.
is fine;
is a violation —
high with multiple consumers, low with one.
__init__from domains.pricing import calculate_discountfrom domains.pricing.discount_calculator import ...外部消费者需以语言原生形式使用切片的公共接口——比如Go中的导出标识符、Python中的包对外暴露内容、TypeScript中的索引模块、其他语言中的公共类接口——绝不能使用其内部实现。是合规的;则违反规则——若存在多个消费者则为高风险(high),仅单个消费者则为低风险(low)。
__init__from domains.pricing import calculate_discountfrom domains.pricing.discount_calculator import ...3. Model purity
3. 模型纯度
Domain files import only stdlib, , and sibling slice public APIs.
A domain file importing an HTTP client, ORM, or queue is a violation; the fix
is a port (protocol) defined in the domain and implemented by an adapter.
Medium, escalating to blocker only when the infrastructure call
executes at import time.
common/领域文件仅可导入标准库、以及同级切片的公共API。领域文件导入HTTP客户端、ORM或队列属于违规;修复方案是在领域中定义端口(协议),并由适配器实现。属于中等(medium)问题,仅当基础设施调用在导入时执行时才升级为阻塞级(blocker)。
common/4. Growth justification
4. 增长合理性
Every new directory or abstraction needs 2+ concrete uses. An abstract base
with one implementation, an event bus interface when no event exists yet, or a
registry with one plugin is premature abstraction — medium. "Numeric
thresholds" in the guards below means the advisory growth signals (~200 lines,
3+ concepts, 3+ clustered files), not this check. Suppress these false
positives:
<!-- doctrine:growth-guards:start -->
- New single-file concepts that stayed single files are correct; do not flag them.
- A dispatcher introduced to break a cross-slice cycle is not premature abstraction, even with one event and one subscriber.
- Numeric thresholds are advisory signals, not gradeable violations; grade implementation share, public-surface size, and lifetime mixing.
- In a language whose only privacy mechanism is file placement, a subdirectory that exists to mark its contents internal is the visibility mechanism, not growth structure; do not grade it against the 2+-concrete-uses check, even with a single file inside.
每个新目录或抽象层需要2个及以上的具体用途。仅有一个实现的抽象基类、尚未存在事件时的事件总线接口、仅有一个插件的注册表均属于过早抽象——**中等(medium)**问题。以下情况为误报,无需标记:
<!-- doctrine:growth-guards:start -->
- 保持为单个文件的新概念是合规的,无需标记。
- 为打破跨切片循环而引入的调度器不属于过早抽象,即使只有一个事件和一个订阅者。
- 数值阈值仅为参考信号,并非可评级的违规项;需评估实现共享程度、公共接口大小以及生命周期混合情况。
- 在仅通过文件位置实现隐私机制的语言中,用于标记内容为内部实现的子目录是可见性机制,而非增长结构;即使内部只有单个文件,也无需按“2个及以上具体用途”的规则进行评级。
5. Event usage
5. 事件使用
Events exist for reverse dependencies: B reacts to A without A knowing B.
Cycles between slices must resolve via events typed in , not mutual
imports (high).
Events used as general-purpose messaging where a direct import is the natural
dependency are a medium finding.
common/事件用于处理反向依赖:B响应A,但A无需知晓B的存在。切片间的循环必须通过中定义的事件来解决,而非相互导入(高风险(high))。在自然依赖应为直接导入的场景中,将事件用作通用消息传递属于**中等(medium)**问题。
common/Severity
严重等级
The severities cited in the checks above derive from this table.
<!-- doctrine:severity:start -->
| Severity | Meaning |
|---|---|
| blocker | Inverted dependency arrow; infrastructure executing at import time in a domain file |
| high | Cross-slice internal import; circular slice dependency; crust bypass with multiple consumers |
| medium | Model-purity drift (infrastructure imported, not executed at import time); premature abstraction; events-as-messaging; adapter imported outside the composition root |
| low | Single-consumer crust bypass; naming drift |
上述检查中提及的严重等级源自下表。
<!-- doctrine:severity:start -->
| 严重等级 | 含义 |
|---|---|
| blocker | 依赖箭头方向反转;领域文件中在导入时执行基础设施代码 |
| high | 跨切片内部导入;切片间循环依赖;存在多个消费者时绕过外壳接口 |
| medium | 模型纯度偏差(导入基础设施但未在导入时执行);过早抽象;事件用作通用消息传递;在组合根之外导入适配器 |
| low | 单个消费者绕过外壳接口;命名偏差 |
Output
输出
Report findings grouped by severity, most severe first. Each finding:
. An empty
report is a valid outcome; never manufacture findings. Do not fix anything —
this skill reviews only.
severity — check — file:line — quoted evidence — one-line fix按严重等级从高到低分组报告问题。每个问题需包含:。空报告是有效结果;切勿编造问题。请勿修复任何内容——此技能仅用于审查。
严重等级 — 检查项 — 文件:行号 — 引用违规证据 — 一行修复建议