diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a4405..5f13d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ Releases of the BoCode template itself. Adopting projects upgrade by handing [UP When adding an entry, also refresh the collapsed What's-new block near the top of the three READMEs (`README.md`, `README.zh-CN.md`, `README.ja.md`): newest title in the summary line, latest three titles as bullets. +## 2026-11-06 — selected ub-mode practices (ADR-011) + +Selected practices from Robert C. Martin's [ub-mode](https://github.com/unclebob/ub-mode/blob/master/SKILL.md) supplement the existing phases where useful: valid state modeling, pure business calculations, behavior-focused tests, evidence-based defect repairs, shared domain terms, and complexity review. Automation samples remain an optional boscope reference, outside the general workflow and review checklist. Project rules and user requirements take precedence over this supplementary guidance. No phases, approval gates, required review items, mandatory tools, or fixed thresholds are added. Context-management, action logs, metrics-tool dependencies, and worktree cleanup are excluded; existing validation and data-ownership rules remain. + +- Added: `book/docs/decisions/ADR-011-distill-selected-ub-mode-practices.md` — the selection, adaptations, and scope boundaries; `skills/boscope/references/automation-tools.md` — the optional method and sample-storage guidance +- Changed: `skills/boscope/SKILL.md` (defect evidence and premise checks in Phase 1, state modeling, terminology and an optional reading pointer in Phase 2, calculation boundaries in Phase 3, behavior tests and repair verification in Phase 4); `skills/README.md` (entry points and reference installation); `book/guidelines/workflow.md` (matching principles); `book/guidelines/README.md` (check count and terminology pointer); `book/guidelines/writing-style.md` (use the existing domain glossary); `book/guidelines/architecture.md` (optional inline glossary guidance); `book/guidelines/coding-style.md` (optional complexity-check configuration) + +**Adopter action:** sync the entire `skills/boscope/` directory, `skills/README.md`, and `book/guidelines/{workflow,README,writing-style}.md` per UPGRADE.md, preserving project edits; sync any translated boscope variants and their reference pointers. Do not copy only `SKILL.md` and leave its reference behind. `architecture.md` and `coding-style.md` are project-owned after adoption: do not overwrite them. When useful, offer the glossary and optional complexity-check guidance for manual incorporation into those documents. No new sample directory or mandatory glossary file is required; retained samples follow existing test/fixture conventions. + ## 2026-11-06 — phase-2 stop rule aligned, L-tier ADR trigger decidable The task-tiers replay (ADR-008) caught two leftovers: boscope still required Phase-2 approval while workflow.md, AGENTS.md, and the newer skill variants stop only on real gaps; and the L row's "an ADR when impact warrants" carried no criterion. diff --git a/book/README.md b/book/README.md index d2d7427..e7182d2 100644 --- a/book/README.md +++ b/book/README.md @@ -59,6 +59,7 @@ description: Master index of the book — the map of every document. Regenerate - [ADR-008-grade-tasks-into-tiers-before-the-workflow.md](docs/decisions/ADR-008-grade-tasks-into-tiers-before-the-workflow.md) — Tasks are graded S/M/L before any work — S runs a light channel whose only gate is a one-sentence motive, M/L run Step 0 and all six phases; the tier is decided before Step 0 and recorded in the first commit's motive - [ADR-009-bowrite-voice-on-every-write.md](docs/decisions/ADR-009-bowrite-voice-on-every-write.md) — bowrite's voice rules now run on every write, not just from-scratch drafts; conditions and exceptions join the fidelity contract's never-move list; the writeback path names bowrite explicitly - [ADR-010-archive-by-status-flip-not-by-moving-files.md](docs/decisions/ADR-010-archive-by-status-flip-not-by-moving-files.md) — task and issue entries archive by flipping a frontmatter status and regenerating the index — files never move, the index regroups with open entries first +- [ADR-011-distill-selected-ub-mode-practices.md](docs/decisions/ADR-011-distill-selected-ub-mode-practices.md) — Selected ub-mode practices supplement project rules for modeling, calculations, testing, defects, terminology, and optional automation - [README.md](docs/decisions/README.md) — How to write an ADR here — sections, naming, numbering, and when a decision needs a record ### guidelines/ @@ -80,4 +81,4 @@ description: Master index of the book — the map of every document. Regenerate - [README.md](plans/README.md) — Plans directory usage — implementation plans land here after Phase 2 approval, with naming and the plan template - + diff --git a/book/docs/decisions/ADR-011-distill-selected-ub-mode-practices.md b/book/docs/decisions/ADR-011-distill-selected-ub-mode-practices.md new file mode 100644 index 0000000..17586bd --- /dev/null +++ b/book/docs/decisions/ADR-011-distill-selected-ub-mode-practices.md @@ -0,0 +1,36 @@ +--- +description: Selected ub-mode practices supplement project rules for modeling, calculations, testing, defects, terminology, and optional automation +--- + +# ADR-011: Distill selected ub-mode practices + +## Status + +Accepted — 2026-11-06. Ships with the template. + +## Context + +Robert C. Martin's [ub-mode](https://github.com/unclebob/ub-mode) provides engineering instructions for agents. Its [skill](https://github.com/unclebob/ub-mode/blob/master/SKILL.md) informs the modeling, calculation, testing, defect, terminology, and automation guidance selected here. We adapt those practices to BoCode's scope and document rules. + +BoCode already covers small changes, first-principles design, test-first iteration, regression, data ownership, and knowledge writeback. Importing the whole skill would repeat those rules and introduce conflicting process requirements. Short instructions can make modeling, calculation boundaries, test assertions, and defect investigation more concrete. Easily confused business concepts need shared definitions. Worked samples can help develop automation tools, but this specific task should not add checks to ordinary feature work. + +## Decision + +The ub-mode-derived practices below are supplementary and apply only where useful within the current task. The user's requirements and the project's workflow, task tiers, architecture, and coding conventions take precedence; skip or adapt any conflicting practice. These practices add no phase, approval gate, or required review item. Keep automation guidance in an optional reference, with one task-specific reading pointer in boscope. Keep the current phases, skills, and eleven-item review checklist. + +- **Defects:** Phase 1 establishes the cause from reproduction or checkable failure evidence. Where reproduction is unavailable, separate facts from hypotheses and specify verification. If two fixes sharing a premise fail the same verification, state and recheck that premise before another attempt. Phase 4 checks the original failure and regression; hiding an error alone is insufficient. +- **Modeling and calculations:** where practical, Phase 2 represents valid state combinations in types or data structures, and Phase 3 keeps business calculations as pure functions with explicit inputs and outputs, separate from external reads and writes. Existing scope rules still prohibit unrelated abstractions or refactors. +- **Tests:** Phase 4 checks observable results and required side effects through the caller's interface, without tying tests to private call sequences. +- **Complexity:** use the existing complexity review to consider complex conditions, deep nesting, and repeated branches when relevant. Reuse configured lint/static-analysis checks where available; adopting projects choose thresholds and warning or blocking policy. Scores identify candidates for review, not automatic refactoring. No measurement suite is required. +- **Automation tools (optional):** `skills/boscope/references/automation-tools.md` describes worked samples for batch or repetitive tasks. Use a sample when processing rules, expected results, or batch effects need confirmation; existing tools and established rules may already provide enough evidence. The agent can produce it from the requirements, clarifying unresolved business rules. It need not be a test or file. Retained regression cases follow the owning tests' conventions. Ordinary tasks do not load this reference or evaluate an automation checklist item. +- **Domain terms:** when concepts need clarification or terms are used inconsistently, maintain concise meanings, code names, and distinctions in the existing architecture document. Use existing definitions across docs, interfaces, and code; split the glossary only when it grows. This does not authorize unrelated renames. + +Context-management and action-log requirements are excluded by user choice. Boundary-only validation is not introduced; existing input, authorization, and business checks remain necessary. Existing data-ownership rules stay as they are. Companion metrics tools, fixed thresholds, worktree cleanup, and upstream commit/push instructions remain outside this change. Phase 5/6 still record findings without fixing them. + +## Consequences + +- Defect repairs have evidence to review; terminology has a shared definition when needed; tool-development tasks can consult the sample method without burdening the general workflow. +- No new skill, sample directory, mandatory glossary file, or tool dependency is introduced. Complexity review adds no mandatory Python runtime, custom analyzer, or fixed score threshold. New tooling remains within the designed scope. +- The glossary guidance lives in the skill as well as the architecture template: adopters own their architecture documents, so upgrades offer this addition for manual incorporation rather than overwriting project content. +- The existing eleven-item review checklist is unchanged. The skills README and root changelog explain that boscope's reference is copied with its entry point, and list the optional architecture-template addition. This template's own records remain ADRs, per [ADR-004](ADR-004-template-free-of-instance-records.md). +- Verification exposed an existing portability issue: on a Windows CRLF checkout, the index generator misreads descriptions and emits backslash paths. Rebuild with the unchanged generator on an LF copy under Linux; fixing the generator is separate work. diff --git a/book/guidelines/README.md b/book/guidelines/README.md index e44e87d..1755156 100644 --- a/book/guidelines/README.md +++ b/book/guidelines/README.md @@ -22,7 +22,7 @@ The project's development rules. Every contributor — including AI agents — f |--------|-----------| | Phases, gates, book sync | `workflow.md` | | Grading a task, which channel it runs | `task-tiers.md` | -| Module boundaries, data ownership, tech swaps | `architecture.md` | +| Module boundaries, data ownership, tech swaps, domain terms | `architecture.md` | | The current shape of modules and data flow | `../docs/architecture/` snapshots | | Interface contracts | `../docs/api/` | | Writing any book document | `writing-style.md` | diff --git a/book/guidelines/architecture.md b/book/guidelines/architecture.md index b698faa..3ed312f 100644 --- a/book/guidelines/architecture.md +++ b/book/guidelines/architecture.md @@ -12,6 +12,7 @@ description: Template for your project's long-term architecture rules — bounda 2. **Module map** — the top-level modules/processes, their responsibilities, and who talks to whom. One sentence per module is enough; details live in snapshots. 3. **Technology baseline** — languages, frameworks, storage, and the rule for swapping any of them (usually: via an adapter, never via a rewrite). 4. **Data ownership** — for each store or dataset, the single module allowed to write it. +5. **Domain terms (when needed)** — when concepts need clarification or terms are used inconsistently, keep a short glossary here: each term's meaning, code name, and distinction from similar concepts. Reuse existing definitions across docs, interfaces, and code; split the glossary into a linked document only when it grows. Terminology work stays within the task's scope. ## Worked example: boundary invariants diff --git a/book/guidelines/coding-style.md b/book/guidelines/coding-style.md index 2e05a15..e13dae1 100644 --- a/book/guidelines/coding-style.md +++ b/book/guidelines/coding-style.md @@ -11,6 +11,7 @@ description: Template for your project's coding baseline — the language-specif - **Language & toolchain** — versions, runtime, package manager; what counts as "the standard way to run this project" - **Naming** — files, types, functions, variables, constants; the project's one convention per kind - **Formatting & lint** — the tool, the command, and that CI fails when it's dirty +- **Complexity checks (optional)** — reuse existing lint/static analysis; define the command, scope, project-specific thresholds, and whether findings warn or block. Scores guide review; do not split code mechanically to lower them - **Error handling** — how errors are raised, wrapped, and surfaced; what never gets swallowed - **Testing conventions** — where tests live, how they're named, what must be covered before a change counts as done - **Dependencies** — the policy for adding one (and the default answer: don't, unless it removes more code than it adds) diff --git a/book/guidelines/workflow.md b/book/guidelines/workflow.md index 3c66a6c..30a5353 100644 --- a/book/guidelines/workflow.md +++ b/book/guidelines/workflow.md @@ -8,6 +8,8 @@ description: Six-phase gate workflow with the eight code↔book interaction rule Grade the task first — S, M, or L per `task-tiers.md`; the tier is decided before any work and lands in the first commit's motive. S runs the light channel and never enters this table. Every M/L feature moves through these phases in order. **No skipping.** +The ub-mode-derived practices below are supplementary and apply only where useful within the current task. The user's requirements and the project's workflow, task tiers, architecture, and coding conventions take precedence; skip or adapt any conflicting practice. These practices add no phase, approval gate, or required review item. + | Phase | Name | Output | Gate | |------|------|--------|------| | Step 0 | Structured requirements brief | Requirements brief | Every slot filled | @@ -20,10 +22,18 @@ Grade the task first — S, M, or L per `task-tiers.md`; the tier is decided bef Step 0 comes before any code (M and L). Fill the brief: background, scope (what it affects, what it explicitly does **not** affect, and the boundaries), and the requirement itself. An empty "does not affect" list is the number-one cause of out-of-scope changes in Phase 3 — the exclusions slot is required. Requirements arrive as suggestions; physics is the only law — correctness, data integrity, and the user's explicit hard constraints don't negotiate, while convention, past practice, and "how it's done" do. Question the inherited HOW; the user's WHAT holds (reasoning and sources in ADR-005, in the BoCode repository's `book/docs/decisions/`). The stated request is a proxy — the experience behind it is the requirement: capture what the user will see, do, and get. Focus is saying no; the exclusions slot gives the feature its shape (ADR-006). +For defect work, Phase 1 reproduces the failure or gathers checkable failure evidence and locates the cause before code changes. If reproduction is unavailable, distinguish facts from hypotheses and state how the fix will be verified. Suppressing an error alone does not establish a repair. If two fixes sharing a premise fail the same verification, state and recheck that premise before trying another fix (ADR-011). + Phase 2 produces the full design — data flow, file list, interfaces — and proceeds; it stops for the user only when a real gap appears (scope conflict, undetermined data shape, unclear external dependency), never just for confirmation. Designs and estimates derive bottom-up from primitives — what the data and code actually are — never by analogy to last time; delete what no requirement calls for before optimizing anything that remains. Design is how it works — the surfaces the user touches (defaults, empty states, error messages) are designed with the data flow, never decorated after it (ADR-006). +When domain concepts need clarification or terms are used inconsistently, maintain a short glossary in the existing architecture document, with meanings, code names, and distinctions; split it only when it grows. Use those terms consistently across docs, interfaces, and code (ADR-011). + +Where practical, Phase 2 uses types or data structures to exclude invalid state combinations. Phase 3 keeps business calculations as pure functions with explicit inputs and outputs, separate from database, file, and network operations (ADR-011). + Phase 4's hard part is the gate, not the sequence: all relevant tests green, no assertion weakened to get there, coverage of the normal path, boundary inputs (ranges, empty, extremes), error paths, and a regression check that existing behavior didn't break. Test-first (write a failing test → minimum implementation → refactor staying green) is the default loop — sequence the work however keeps the gate honest. Iterate fast inside the phase; polish at the gate — what crosses a gate is finished: defaults chosen, errors worded, edges handled (ADR-006). +Phase 4 tests observable results and required side effects through the caller's interface, avoiding dependence on private call sequences. For defects, it verifies that the original failure is resolved and existing behavior holds; unverified outcomes remain explicit (ADR-011). + Phases 5 and 6 share one discipline: **record, never fix.** A problem found during review or wrap-up goes into `notes/issue/` — fixing it is a separate, later task. Fixing in passing feels efficient and destroys the gate: the review no longer reviews what was built. ## code ↔ book — the two halves diff --git a/book/guidelines/writing-style.md b/book/guidelines/writing-style.md index 4de2983..718eba9 100644 --- a/book/guidelines/writing-style.md +++ b/book/guidelines/writing-style.md @@ -31,6 +31,7 @@ Work by pattern, not word-for-word substitution. Rotating synonyms to dodge repe - Un-nominalize: "performed an optimization" → what changed, how much faster. "perform / implement / complete + gerund" is the tell - Shorten translationese: fewer long attributive chains, fewer passive piles, less "through X, by way of Y, to achieve Z" - Don't call the same thing by three different names in adjacent sentences +- Use the project's domain glossary, when present, as the source for business terms; preserve the distinctions between similar concepts - Filler intensifiers ("important", "key", "critical", "core"): trim only when density is clearly too high, or replace with concrete information ## Intensity levels diff --git a/skills/README.md b/skills/README.md index 0d7c0b3..dd8f452 100644 --- a/skills/README.md +++ b/skills/README.md @@ -1,6 +1,6 @@ # Skills -Four self-contained skills implement the BoCode workflow for AI agents. Each is a single `SKILL.md` in the standard format (frontmatter with `name` and `description`, then the body) — no code, no dependencies. +Four skills implement the BoCode workflow for AI agents. Each has a `SKILL.md` entry point in the standard format (frontmatter with `name` and `description`, then the body) — no code, no dependencies. A skill can include optional references: boscope's [automation tools guide](boscope/references/automation-tools.md) is read only when relevant, not as a separate skill. | Skill | Does | Triggers | |-------|------|----------| @@ -13,7 +13,7 @@ Division of labor: **skills say when and how** (executable behavior for the agen ## Installation -Copy the four skill directories into your agent's skills folder: +Copy the four skill directories, including any `references/` subdirectories, into your agent's skills folder: - **ZCode**: `~/.zcode/skills/` (user-wide) or `/.zcode/skills/` (per project) - **Claude Code**: `~/.claude/skills/` or `/.claude/skills/` diff --git a/skills/boscope/SKILL.md b/skills/boscope/SKILL.md index 45c91bd..f67760d 100644 --- a/skills/boscope/SKILL.md +++ b/skills/boscope/SKILL.md @@ -15,6 +15,8 @@ Grade the task first (tier first, below). An M/L feature then splits into **brie **Core principle:** a request that says *what* but not *why / scope / boundaries* is not ready for code. Fill the gaps first; then surface the axes the user didn't know were missing. +The ub-mode-derived practices below are supplementary and apply only where useful within the current task. The user's requirements and the project's workflow, task tiers, architecture, and coding conventions take precedence; skip or adapt any conflicting practice. These practices add no phase, approval gate, or required review item. + ## Tier first — grade before anything (REQUIRED — before Step 0) Grade the task against the tier table in `book/guidelines/task-tiers.md` (the criteria live there, not here — this project's copy, with its always-L list). The tier is a fact about the change, not a preference; it lands in the first commit's motive. @@ -63,16 +65,24 @@ Render the brief below and fill every slot. For empty slots you have two duties: Understand the requirement → find the relevant code → trace the call chain → map the impact → flag risks. **No code changes.** +**For defects, establish the cause.** Reproduce the failure or collect checkable failure evidence, then locate its cause before editing. If reproduction is unavailable, separate confirmed evidence from hypotheses and state how the fix will be verified. A guard that merely hides the failure is not a fix. If two fixes sharing a premise fail the same verification, state that premise and recheck it against evidence before trying another fix. + **Output:** impact map + risk list. ### Phase 2: Design **Output:** data flow, sequence diagram (optional), file change list, new interfaces, permission design, notification design, experience surfaces (defaults, empty states, error messages), test points. +Where practical, represent valid state combinations in types or data structures so invalid combinations cannot be constructed. + **Derive, don't analogize.** Design and estimate bottom-up: decompose to primitives — what the data actually is, what the code actually does, measured costs — and reason up from there. An analogy ("the last similar feature took three days") is a data point, not an estimate. A gap between the bottom-up answer and the received number marks the real problem. **Delete before you optimize.** Question every part against its requirement: delete what nothing calls for, simplify what remains, and only then optimize or speed up. If nothing ever gets added back, you're deleting too little; optimizing a part that shouldn't exist is waste, faster. +When developing batch or repetitive-task tools, consult the optional [automation tools guide](references/automation-tools.md) as needed. + +**Use the domain's terms.** Reuse existing definitions across the design, interfaces, and code. When concepts need clarification or terms are used inconsistently, add or update a short glossary with each term's meaning, code name, and distinction from similar concepts. Keep it in the existing architecture document; split it only when it grows. Do not rename unrelated code to enforce terminology. + **Design is how it works.** The surfaces the user touches — defaults, empty states, error messages — are the design itself, not decoration on the data flow. A design that needs explaining before it works gets simplified, not documented. **Real gaps stop this phase; nothing else does.** With the outputs above complete, go straight to Phase 3 and deliver the design with the implementation — stop for the user only on a real gap (scope conflict, undetermined data shape, unclear external dependency), never just for confirmation. @@ -85,12 +95,18 @@ Understand the requirement → find the relevant code → trace the call chain Strictly per the design. **No changes outside scope, no refactors, no new abstractions.** Match the existing code's style. +Where practical, keep business calculations as pure functions with explicit inputs and outputs, separate from database, file, and network operations. + ### Phase 4: Testing (test-first) Write a failing test → write the minimal implementation that passes → refactor with tests green. This loop is the iteration engine — run it fast and let it fail: a red test is data, not a setback. Iterate freely inside the phase, never past the gate. What crosses the gate crosses it polished — defaults chosen, errors worded, edges handled. **Coverage (all required):** normal path · permission checks · boundaries (input ranges / empty / extremes) · error paths · regression (existing behavior intact). +Test through the caller's interface and assert observable results and required side effects; avoid coupling tests to private call sequences. + +For defects, verify the original failure is resolved and existing behavior holds; distinguish verified results from remaining uncertainty. + **Gate:** all relevant tests pass, and no assertion was weakened to make them pass. ### Phase 5: Code review diff --git a/skills/boscope/references/automation-tools.md b/skills/boscope/references/automation-tools.md new file mode 100644 index 0000000..7012ec1 --- /dev/null +++ b/skills/boscope/references/automation-tools.md @@ -0,0 +1,23 @@ +--- +description: Optional guidance for developing batch or repetitive-task tools — use a worked sample when processing rules or batch effects need confirmation +--- + +# Automation tools — optional guidance + +Use this reference when developing tools for batch or repetitive tasks, such as data conversion, report generation, or file processing. It adds no gate to ordinary feature development or the general review checklist. The user's requirements and existing project workflow and conventions take precedence over this reference. + +## When a sample helps + +Complete one small unit directly when processing rules, expected results, or batch effects need confirmation. Reuse suitable existing tools and established rules; do not manufacture a new sample when they already provide sufficient evidence. Include any new tooling in the task's design scope. + +The agent can produce the sample from known requirements. Clarify unresolved business rules rather than inventing them. A sample is a worked result, not necessarily an automated test or a separate file. + +For example, before generating sales reports, calculate one store's total from a few transactions and confirm how refunds affect it. That result gives the report generator something checkable to match. + +## Implement and verify + +Compare the tool's output with the checked result. Where batch effects matter, verify a small batch before wider execution. Follow the project's existing authorization and safety rules for execution. + +## Keep only useful samples + +Keep samples needed for regression with the owning tool's or module's tests: small cases inline, larger inputs and expected outputs as fixtures under existing conventions. Temporary working examples need not become maintained files. Do not create a project-wide sample directory for this method or retain a second implementation of the tool.