principle-boundary-discipline
Use when wiring input validation, error handling, adapters, CLI or config parsing, or API clients. Check data at the point it enters, rely on typed values past that point, and put domain logic in framework-free functions called by a thin shell.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- principle-boundary-discipline
- description
- Use when wiring input validation, error handling, adapters, CLI or config parsing, or API clients. Check data at the point it enters, rely on typed values past that point, and put domain logic in framework-free functions called by a thin shell.
- disable-model-invocation
- true
03 SKILL.md 正文
Boundary discipline
Do the defensive work (parsing, validation, error handling) where data crosses into the system. Past that point, hand typed values around and rely on them. Domain logic belongs in side-effect-free functions that a small layer of framework code invokes.
When it applies
Wiring validation, error handling, framework adapters, CLI parsing, config loading, or API clients, and deciding where logic lives relative to framework code.
This principle moves checks to the right place. It never justifies skipping validation at a real boundary.
What to do
- List the boundaries the change touches: command-line arguments, config files, environment variables, network requests, responses from external APIs, reads from storage, and output from tools or models an agent calls. Each is a trust boundary where content may be malformed or hostile.
- At each boundary, parse raw input into a domain type, reject what does not parse, and return a typed error. A webhook handler parses the JSON body into a
SignedEventafter verifying the signature. It does not pass a raw dictionary inward. - Inside, pass the typed value along and propagate errors. Do not re-check what the boundary already guaranteed. A null check five calls deep on a field the parser made mandatory is noise.
- Validate configuration when it is parsed, at startup.
- At the public surface, expose domain concepts. Do not re-export the HTTP response type, the ORM row, or the framework's request object. Generic mechanism stays inside, and rules specific to one caller or deployment sit at the outer layer.
- Write business logic as pure functions with no framework imports, so you can test it without starting the framework. Good candidates: parsers that turn bytes into typed state, prompt builders that turn structured state into a string, and scorers that turn state into a verdict.
- Ask two questions of each check and each function. Is this data crossing a boundary right now? If not, the validation is redundant. Could this be a pure function the shell calls? If so, extract it.
The failure it prevents
Scattered validation gives false confidence because nobody can say which layer is the real gate. Logic tangled with framework wiring cannot be unit tested, and leaked wire types tie the domain to one transport.
Done when
Every guard sits at a boundary, inner code trusts its types, and the logic runs without the framework.
Related: principle-type-system-discipline, principle-minimize-reader-load, principle-treat-input-as-untrusted.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.