openchamber-change-discipline
GitHub规范 OpenChamber 代码修改纪律,强调最小化变更与风险分类。指导在重构、修复或实施新功能时,识别本地实现、模块契约及跨工作区等风险,确保验证范围精准覆盖真实风险,保持代码结构清晰与依赖明确。
Trigger Scenarios
Install
npx skills add openchamber/openchamber --skill openchamber-change-discipline -g -y
SKILL.md
Frontmatter
{
"name": "openchamber-change-discipline",
"description": "Use when implementing, fixing, refactoring, or otherwise modifying OpenChamber source code, dependencies, exports, build configuration, generated assets, package contracts, or module ownership."
}
OpenChamber Change Discipline
Core Principle
Make the smallest complete change and validate at the narrowest level that covers the real risk.
Before Editing
- Inspect nearby implementation, callers, and tests before introducing a pattern.
- Classify every applicable change risk below.
- Identify every affected consumer, runtime, persisted format, and public export. This step is complete only when each risk has an owner and required validation.
Risk Classification
| Risk | Examples | Planning consequence |
|---|---|---|
| Local implementation | Private helper or component behavior in one package | Preserve observable behavior; validate the owning package |
| Module contract | Exported API/type or documented module invariant | Inspect consumers; update contract tests and owning docs |
| Cross-workspace contract | Shared UI/runtime/package shape consumed by multiple workspaces | Trace every actual consumer and runtime; validate across workspaces |
| Persisted or external behavior | Stored settings/data, routes, IDs, files, CLI output | Define compatibility, round-trip, failure, and conversion behavior for existing consumers |
| Platform/runtime behavior | Electron, VS Code, mobile, relay, native or packaged behavior | Run the relevant runtime/build/integration validation |
Apply every matching category. Do not escalate local work into workspace-wide ritual, and do not treat a type-only export as local merely because it emits no JavaScript.
Structural Discipline
- Preserve behavior established by callers and tests unless the request replaces it. Keep the diff scoped to the complete requested behavior.
- Make the normal use-case path read top to bottom in domain terms. Keep orchestration entrypoints thin and move mechanics or domain logic behind focused, intention-revealing boundaries.
- Pull complexity downward only when a boundary hides meaningful mechanics, owns an invariant, isolates a proven integration, or captures stable repetition. Do not spread obvious code across pass-through layers.
- Prefer explicit dependencies and dependency injection over hidden module coupling.
- Follow local TypeScript types; avoid
any, blind casts, and guessed payload shapes. - Reject invalid inputs and broken preconditions early so the valid path stays flat. Do not force a numeric happy-path/error-path ratio when correctness requires substantial failure handling.
- Require evidence before adding retries, caches, compatibility paths, lifecycle machinery, or generalized race handling. Security, data-loss, destructive-operation, and concurrency invariants still require proactive design when the risk is inherent to the operation.
- Make partial failure, rollback, cleanup, and user-visible outcomes explicit for destructive or multi-step work.
Review Prompts
Before broadening a change, ask:
- Is the new abstraction reused or merely possible to reuse?
- What concrete complexity, invariant, stable repetition, or boundary does each new helper, interface, layer, and file pay for?
- Is the code in the package that owns the behavior?
- Does the change alter shared UI contracts across web, desktop, VS Code, or mobile?
- Does it change persisted data, IDs, routes, exports, generated files, or package entrypoints?
- Can failure leave optimistic state, caches, files, or remote state stranded?
For partial or destructive flows, answer explicitly:
- What remains valid after the first failure?
- What is rolled back or cleaned up?
- What can be retried or resumed safely?
- What does the user observe?
For persisted data, require a migration only when existing stored data needs conversion. Test downgrade compatibility only when older application versions are a concrete supported consumer. "Rollback" means preserving/restoring valid state after a failed write or migration unless a broader contract explicitly says otherwise.
Do not hide a required architectural migration behind a local heuristic. Do not turn a local fix into a speculative rewrite.
Validation Matrix
| Change | Minimum validation |
|---|---|
| Executable source | Focused tests for the changed behavior; type-check and lint come from the pre-commit gate. TypeScript and lint do not cover server JS, CLI JS, Electron helpers, or native code: run node --check, focused tests, or the build for those |
| Cross-workspace/shared contract | Workspace-wide type-check and lint plus affected builds/tests |
| Added/deleted/renamed source file, export/type/entrypoint/import shape | Relevant checks; dead code comes from the pre-commit gate |
| Persisted or external contract | Compatibility and round-trip tests plus the applicable failure/ordering cases: missing-versus-empty, malformed data, stale reads versus newer mutations, out-of-order writes, lifecycle handling for debounced writes, conversion, and failed-write/migration rollback |
| Dependency or lockfile | Workspace-wide checks and affected builds |
Added, renamed, or removed packages/* workspace |
Mirror it in the Dockerfile deps stage, which copies those manifests by name, then run docker build .: a COPY of a missing workspace fails the build, and a workspace another one depends on fails the frozen install when absent. CI does not build the image. |
| Generated asset | Regeneration check plus consumer build/test |
| Docs-only or isolated config | Narrow syntax/schema/link validation; do not run unrelated full suites |
| Platform/runtime behavior | Relevant runtime build or manual/integration check; static checks are insufficient |
| Desktop update or quit/install sequence | A real update run; read references/updater-testing.md first, because a run done the obvious way completes the update and reports success while testing nothing |
bun run check:changed is the pre-commit gate: run it once, right before a commit, on the finished diff. While iterating, run only the focused tests for the behavior you just changed; an edit to docs, comments, or strings needs no check at all.
When several agents edit one checkout in parallel, they edit and run single test files only. The coordinator runs type-check, lint, builds and full suites once, serially, on the combined diff: each tsc -b over packages/ui takes gigabytes, parallel copies have frozen the machine, and a check run mid-edit reports the other agents' half-finished work.
Use a sufficiently long timeout for broad checks. Report exactly what ran and what did not.
Choose affected builds/tests by tracing real consumers and runtime boundaries, not by running everything reflexively.
For type-only shared contracts, validate compile-time consumers. Add runtime serialization tests when the contract crosses a process, persistence, network, or untyped JavaScript boundary.
Test Design
- Prefer observable contracts, state transitions, failure handling, rollback, and operation counts.
- Test private helpers through public/module behavior when that captures the risk clearly.
- Assert internal map shape, helper calls, or call order only when that structure/order is itself a contract.
- Keep refactor tests resilient to equivalent internal implementations.
- For behavior-preserving refactors, establish the current behavior before changing structure.
Module Documentation
A module's DOCUMENTATION.md lives in its folder and holds what the code cannot show the next agent: what the module owns, what must stay true, and why it is built this way. A module gets its own document when it owns a contract other code relies on, an invariant, or a non-obvious design choice; a folder without any of these is covered by its parent's document.
The document has three parts:
- Ownership. What the module owns and where its boundary is: what belongs here and which neighbouring module owns the rest.
- Invariants. What must stay true, each stated so a change can be checked against it.
- Decisions. One
### Why X and not Yentry per non-obvious choice: the chosen approach, the alternative it was weighed against or replaced, and the reason in one or two sentences. A choice is non-obvious when a later reader could reasonably "fix" it back: a simpler design that was rejected, a deliberate workaround, a measured trade-off.
The document describes the module as it is now. When a decision changes, rewrite its entry around the new choice and keep the old approach as the rejected alternative, so the file stays current and carries no history to unwind. Spend its lines on reasons and contracts; file listings and function-by-function walkthroughs restate the code and go stale first.
Completion Standard
- Implement the behavior end to end, including rollback and cleanup.
- Run focused regression tests for the changed contract; when no test can cover it, say so in the report.
- Preserve unrelated changes encountered in shared files.
- The owning
DOCUMENTATION.mdis true of the new code and has a decision entry for every non-obvious choice the change made; a new module that meets the bar in Module Documentation has its own document. - Perform a final simplification pass over your own diff, hardest after a rework or a removal: every branch, condition, prop, parameter, export, key, and helper the change made unreachable, always-true, or single-valued is gone, along with speculative branches, shallow wrappers, stale compatibility, and names that do not clarify intent.
- Before a commit, the pre-commit gate passes.
Version History
-
bf977d2
Current 2026-10-19 13:04
更新完成标准:要求每个非显而易见的设计选择必须有决策记录;优化检查流程,将 check:changed 改为预提交钩子,迭代时仅运行聚焦测试。
-
336e192
2026-09-22 17:58
将更新器测试流程合并至本技能,并整合两次真实运行经验,补充了Linux和Windows平台的具体测试机制、竞态窗口测量及环境隔离限制。
-
2db90f7
2026-08-20 04:55
细化编辑前检查步骤,移除对文档读取的强制要求,新增关于抽象复用和意图揭示的结构纪律,优化风险规划后果描述。
- 74b1bd8 2026-07-25 10:36


