principles
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrinciples
原则
Principle skills live at from this file.
../<name>/SKILL.mdIn your reply, name each principle that shaped a decision and the specific choice it changed. Cite only principles whose leaf SKILL.md you read this session.
Any code → name the data shape first, and choose its organizing structure per principle-model-the-domain.
Read the leaf skill in full for any principle you apply. Each entry names when it applies. Each leaf is the principle-<title> skill, with the title in kebab case, hyphens kept and other punctuation dropped, unless the entry gives its name.
Core
- Laziness Protocol. Refactoring, sizing a diff, or tempted to add abstractions, layers, or signal threading. Bias to deletion and the smallest change that solves the problem.
- Foundational Thinking. Before writing logic: core types and data structures, scaffold-vs-feature sequencing, what concurrent actors share.
- Redesign from First Principles. Integrating a new requirement into an existing design. Redesign as if it had been foundational from day one.
- Attack the Premise. Two or more fixes that share one premise have failed the same gate. Write the premise down and test it directly before you write another fix that assumes it.
- Subtract Before You Add. Sequencing an addition, refactor, or rewrite. Remove dead weight first, then build on the simpler base.
- Minimize Reader Load. Reviewing or shaping code that's hard to trace. Count layers and hidden state, collapse one-caller wrappers, shrink mutable scope.
- Outcome-Oriented Execution. Planned rewrites and migrations with explicit phase boundaries. Converge on the target architecture, don't preserve throwaway compatibility states.
- Experience First. Product, UX, or feature-scope tradeoffs. Choose user delight over implementation convenience.
- Exhaust the Design Space. A novel interaction or architectural decision with no precedent. Build 2-3 competing prototypes and compare before committing.
- Build the Lever. Any non-trivial work. Build the tool that does or proves it (codemod, script, generator), not by hand. The tool is the artifact a reviewer reruns.
Architecture
- Model the Domain. Writing stateful logic, or code that branches a lot or repeats a shape assumption across files. Encode the domain in a structure (state machine, typed model, table or registry, reducer, boundary, the right collection) instead of scattered conditionals.
- Boundary Discipline. Wiring validation, error handling, or framework adapters. Guards at system boundaries, trust internal types, keep business logic pure.
- Type System Discipline. Designing types or a signature in any typed language. Make illegal states unrepresentable, brand primitives, parse external data at boundaries.
- Make Operations Idempotent. Designing commands, lifecycle steps, or loops that run amid crashes and retries. Converge to the same end state.
- Migrate Callers Then Delete Legacy APIs. Introducing a new internal API while old callers exist. Migrate and delete in one wave.
- Separate Before Serializing Shared State. Concurrent actors might write the same file, branch, key, or object. Eliminate the sharing first.
Verification
- Prove It Works. After a task, before declaring done. Verify against the real artifact, not a proxy or "it compiles".
- Fix Root Causes. Debugging. Trace each symptom back to the first place the system went wrong and fix it there. A guard is a fix only when the state it handles is legitimate.
- Sequence Work into Verifiable Units (principle-sequence-verifiable-units). Multi-step work (sweeps, migrations, runs of similar edits) and how you stack commits and PRs. Break work into small units that each end in a check, verify each before the next, and order delivery so the sequence proves itself.
- Test Behavior, Not Implementation. Writing, changing, or keeping a test. Assert what the code's users can observe, so the test fails when that behavior breaks and keeps passing when only the internals change.
- Explain the Number. Apply before you measure, and before you trust, report, or act on a number you measured (a speedup, a regression, a throughput, a latency, or an eval result). Find what limits it, and rule out that it measured something other than the work you think.
Delegation
- Guard the Context Window. Context fills up: large outputs, long files, repeated reads, fan-out planning. Route bulk to subagents, keep summaries in the main thread.
- Never Block on the Human. Tempted to ask "should I do X?" on reversible work. Proceed, present the result, let the human course-correct.
Meta
- Encode Lessons in Structure. You catch yourself writing the same instruction a second time. Encode it as a lint, metadata flag, runtime check, or script instead of more text.
相对于本文件,Principle skill 位于 。
../<name>/SKILL.md在回复中,请列出每个影响决策的原则,以及该原则改变的具体选择。仅引用本次会话中已完整阅读其叶子 SKILL.md 的原则。
编写任何代码 → 先明确数据形态,并根据 principle-model-the-domain 选择其组织结构。
应用任何原则前,完整阅读对应的叶子 skill。每个条目都会说明其适用场景。每个叶子都是 principle-<title> skill;title 采用 kebab case,保留连字符并去掉其他标点,除非条目明确给出了名称。
核心
- Laziness Protocol. 用于重构、确定 diff 规模,或在容易忍不住添加抽象、层次或信号传递时。倾向于删除,并采用能解决问题的最小改动。
- Foundational Thinking. 在编写逻辑之前:先确定核心类型和数据结构,安排 scaffold 与 feature 的先后顺序,并明确并发执行者会共享什么。
- Redesign from First Principles. 将新需求整合进现有设计时,像它从第一天起就是基础一样重新设计。
- Attack the Premise. 当两个或更多修复共享同一前提时,说明它们都未通过同一道关卡。写下该前提,并在编写另一个依赖该前提的修复之前直接验证它。
- Subtract Before You Add. 安排新增、重构或重写的顺序时,先移除冗余负担,再基于更简单的基础进行构建。
- Minimize Reader Load. 审查或整理难以追踪的代码时。统计层次和隐藏状态,合并只有一个调用方的 wrapper,缩小可变作用域。
- Outcome-Oriented Execution. 用于具有明确阶段边界的计划性重写和迁移。目标是收敛到目标架构,不要保留一次性的兼容状态。
- Experience First. 用于产品、UX 或功能范围方面的权衡。优先选择用户愉悦度,而非实现便利性。
- Exhaust the Design Space. 用于没有先例的新颖交互或架构决策。构建 2-3 个竞争性原型并进行比较后再决定。
- Build the Lever. 用于任何非平凡的工作。构建能够执行或证明该工作的工具(codemod、script、generator),而不是手工完成。该工具就是审阅者可以重新运行的产物。
架构
- Model the Domain. 用于编写有状态逻辑,或分支很多、跨文件重复某种形态假设的代码。将领域编码到合适的结构中(state machine、typed model、table、registry、reducer、boundary 或恰当的 collection),而不是散落在各处的条件判断中。
- Boundary Discipline. 在接入验证、错误处理或 framework adapter 时。在系统边界设置 guard;信任内部类型,保持业务逻辑纯净。
- Type System Discipline. 在任意类型化语言中设计类型或函数签名时。让非法状态无法表示,对 primitive 使用 branded type,并在边界解析外部数据。
- Make Operations Idempotent. 设计可能遭遇崩溃和重试的 command、生命周期步骤或 loop 时。让其最终收敛到相同状态。
- Migrate Callers Then Delete Legacy APIs. 引入新的 internal API 但仍有旧调用方时。在同一波工作中完成迁移并删除旧 API。
- Separate Before Serializing Shared State. 并发执行者可能写入同一 file、branch、key 或 object 时。先消除共享。
验证
- Prove It Works. 完成任务后、宣告结束前。针对真实产物进行验证,而不是依赖代理指标或“它能编译”。
- Fix Root Causes. 调试时。将每个症状追溯到系统首次出错的位置,并在那里修复。只有当 guard 处理的是合法状态时,它才算修复。
- Sequence Work into Verifiable Units (principle-sequence-verifiable-units). 用于多步骤工作(批量修改、迁移、运行一系列相似编辑)以及安排 commits 和 PRs 时。将工作拆分为小型单元,每个单元都应以一项检查结束;在执行下一个单元前验证当前单元,并安排交付顺序,使整个序列能够自我证明。
- Test Behavior, Not Implementation. 编写、修改或保留测试时。断言代码使用者能够观察到的行为,使测试在行为损坏时失败,而在只有内部实现发生变化时继续通过。
- Explain the Number. 在测量前,以及信任、报告或根据测得的数字采取行动前应用(加速比、性能回退、吞吐量、延迟或 eval 结果)。找出限制因素,并排除测得的其实是别的工作而非你以为的工作。
委派
- Guard the Context Window. 当 context 被大量输出、长文件、重复读取或 fan-out 规划填满时。将批量任务交给 subagents,主线程只保留摘要。
- Never Block on the Human. 在可逆工作上产生疑问、想问“Should I do X?”时。直接推进并呈现结果,让人类随后纠正方向。
元原则
- Encode Lessons in Structure. 发现自己第二次编写同一条指令时。将其编码为 lint、metadata flag、runtime check 或 script,而不是增加更多文本。