bc-refinement
Use this skill when the user asks to refine a particular Bounded Context (BC) skill. The sub-agent will lock scope to a single BC, assess whether it is cohesive enough to remain one BC, ask questions to understand the actual business behaviour, identify gaps in the existing skill files, and then update all files to align with the business requirements.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 7
- Forks
- 0
01 前言 Front Matter
- name
- bc-refinement
- context
- fork
- description
- Use this skill when the user asks to refine a particular Bounded Context (BC) skill. The sub-agent will lock scope to a single BC, assess whether it is cohesive enough to remain one BC, ask questions to understand the actual business behaviour, identify gaps in the existing skill files, and then update all files to align with the business requirements.
02 资源文件 7
- 资产文件assets/bdd-scenarios-template.md981 B
- 资产文件assets/properties-template.md6.2 KB
- 资产文件assets/property-discovery-template.md4.0 KB
- 资产文件assets/status-template.md599 B
- 参考文档decisions.md2.0 KB
- 参考文档references/phase-5-execution.md9.9 KB
- 参考文档references/phase-6-validation.md3.5 KB
03 SKILL.md 正文
BC Skill Refinement Process
Overview
This document defines the repeatable process used to bring a Bounded Context (BC) skill into alignment with its actual business behaviour.
Input: An existing skill directory at .github/skills/<bc-name>/
Output: Fully updated SKILL.md, domain-model.md, bdd-scenarios.md,
decisions.md, status.md, one or more *-acl.md files, and any new ACL files
needed. When the human has explicitly opted into Goal 3 business-logic
verification for this BC scope, output also includes properties.md.
Golden rule: one BC per session. If conversation drifts toward another BC, warn the developer, note it in the Deferred Items log, and suggest redirecting. The developer has final authority — but the risk of cross-BC contamination must be clearly stated before proceeding.
Phase 0 — Read Everything First + Scope Lock
Before generating any output:
- Read all files in
.github/skills/<bc-name>/ - Read all other BC skill files to understand what adjacent BCs already own
- Read
CLAUDE.mdfor project-wide conventions
Then declare a Scope Lock to the user:
Scope lock: This session covers the [bc-name] BC only.
In scope:
- Everything owned and decided by this BC
Out of scope (owned by other BCs):
- [List every adjacent BC and what it owns, one line each]
Any concern that belongs to another BC will be noted in a Deferred Items log
and addressed in a separate session. It will NOT be designed or implemented here.
Do not generate any other output until Phase 0 is complete.
At session start, update this BC's status.md from DISCOVERED, REFINED, or
SPEC_REVIEWED to REFINING. If the file does not exist, create it from
assets/status-template.md and record why lifecycle tracking was initialized
late. Immediately run npm run project:sync (the generator reads the lifecycle from
status.md, which remains authoritative).
Phase 1 — Business Alignment Interview
Ask the user to describe what the BC is actually supposed to do in plain business language:
"Please describe the business behaviour of the
<bc-name>BC — what triggers it, what it does, and what outcomes it produces. Don't worry about technical details; describe it as a business user would."
Rules for this phase:
- Ask one focused question at a time; do not bundle.
- Do not assume anything — if something is unclear, ask explicitly.
- Do not generate code or updated files during this phase.
- Document all open/deferred questions (those the user could not answer yet).
Phase 1.5 — Cohesion Check
After the business alignment interview, before doing any gap analysis, assess whether the described BC is cohesive enough to remain a single BC.
Decomposition Signals
Flag a potential split if two or more of these are true:
| Signal | Example |
|---|---|
| Two distinct business concerns that could stand alone | "manages catalog AND approves activations" |
| Aggregates with no direct relationship | different lifecycles, different owners, never referenced together |
| Different roles trigger different parts independently | tenants interact with one part; LiveOps interact with another |
| Unrelated external integrations | two external APIs that share no domain concepts |
| The BC name uses "and" or is vague | "Catalog and activations BC" |
| Different reasons to change | one part changes when products change; the other when approval rules change |
If no signals fire
State clearly:
Cohesion check passed — [bc-name] describes a single cohesive concern. Continuing to gap analysis.
If signals fire
Pause refinement. Present a decomposition proposal:
Cohesion concern: the described BC appears to cover [X] and [Y], which are distinct concerns.
Proposed split:
BC A — [Name]: owns [concern A]. Triggered by [trigger]. Produces [outcome].
BC B — [Name]: owns [concern B]. Triggered by [trigger]. Produces [outcome].
Rationale: [one sentence per signal that fired]
Options:
1. Split as proposed — proceed with BC A only this session; BC B gets its own session.
2. Keep as one BC — explain why these concerns must stay together.
3. Adjust the split — describe a different boundary.
Do not proceed until the user explicitly chooses an option. If they choose option 1, update the Scope Lock to reflect the narrower BC before continuing.
Phase 2 — Gap Analysis
Compare the business description (Phase 1) against the existing skill files. Produce a structured gap list:
| Gap Category | Description |
|---|---|
| Missing concepts | Aggregates, entities, or lifecycle states absent from the current model |
| Wrong behaviour | Existing rules that contradict the business description |
| Wrong cadence/schedule | Cron jobs or polling intervals that differ from spec |
| Missing events | Domain events that should be emitted but aren't listed |
| Missing integrations | External systems that interact with this BC but have no ACL file |
| VO Discipline violations | String-wrapper VO classes that should be type aliases |
| Cross-BC contamination | Concepts, methods, or ports that belong to another BC |
| YAGNI contamination | Methods or ports added for a BC that does not yet exist |
Present the gap list to the user for confirmation before proceeding.
When identifying cross-BC contamination, name the BC it belongs to and add it to the Deferred Items log (see Active Redirection below).
Phase 3 — Structured Clarification
For each non-trivial gap, ask a targeted clarifying question. Group questions by topic. Use multiple-choice where the answer space is bounded.
Capture answers as a numbered list in the session plan. Mark deferred questions as [OPEN].
Minimum questions to resolve before proceeding:
- Granularity of any approval/activation lifecycle (e.g., per-product vs per-denomination)
- Status transitions — what statuses exist, what transitions are allowed, which are terminal
- Concurrency rules — can duplicate pending records exist?
- Who can trigger state transitions (tenant vs admin vs system job)?
- What domain events does this BC emit? (Limit to the event name and payload. What consuming BCs do with those events is out of scope — that belongs in the consuming BC's refinement session.)
- Any external API contracts — does a real API spec exist or is it TBD?
Active Redirection (applies throughout the entire session)
Whenever the user raises a concern that belongs to another BC — whether during interview, clarification, or execution — apply this protocol:
- Acknowledge the concern in one sentence.
- Name the BC it belongs to.
- Log it in the Deferred Items section (see format below).
- Redirect back to the current BC.
That sounds like it belongs to the [X] BC — I've noted it in the Deferred Items log.
Let's stay focused on [current BC] for now.
Deferred Items Log
Maintain a running list. Present it at the end of the session.
## Deferred Items (for other sessions)
| BC | Item | Why deferred |
|----|------|--------------|
| Ordering BC | Cart submission webhook handler | Belongs to Ordering BC's ACL, not here |
If the user wants to implement a deferred item in the current session, issue a clear warning before proceeding:
⚠️ Warning: implementing [item] here introduces cross-BC coupling.
[item] belongs to the [X] BC. Adding it to [current BC] means [current BC]
now has a reason to change when [X] changes — violating single-responsibility.
Recommended: defer to a separate [X] BC session.
Proceeding anyway? [yes / no]
Phase 4 — Plan & Approval
Write a plan summarising:
- New domain concepts to add (aggregates, entities, enums, type aliases)
- Business rules to add or correct
- Domain events to add
- Schema changes
- Files to update vs. files to create
- Contamination to remove (with destination BC noted)
Present the plan using exit_plan_mode. Do not modify any files until the user approves.
Phase 5 — Execution (Update Skill Files)
Before doing any work in this phase, read references/phase-5-execution.md in full and follow it exactly. It contains the complete body of this phase; do not proceed from memory or skip it.
Phase 6 — Validation
Before doing any work in this phase, read references/phase-6-validation.md in full and follow it exactly. It contains the complete body of this phase; do not proceed from memory or skip it.
Phase 7 — Session Close
End every session with a structured summary:
## Session Summary — [bc-name] BC Refinement
### What changed
- [file]: [one-line description of change]
### Open questions [OPEN]
- [question]: deferred because [reason]
### Deferred Items (for other sessions)
| BC | Item | Why deferred |
|----|------|--------------|
| ...
### Recommended next sessions
1. [BC name] — [one sentence on why it should be refined next]
This ensures nothing gets lost between sessions and the next refinement has a clear starting point.
Standing Rules (Applied in Every Refinement)
BC Isolation
A BC must have a single reason to change. If two concerns within a BC would evolve independently — triggered by different events, owned by different teams, or changing for different business reasons — they belong in separate BCs.
- When another BC's logic is about to be added to the current BC, warn the developer and explain the coupling risk before proceeding. Cross-BC contamination typically starts with "just one method."
- A port or method that only makes sense when an adjacent (unbuilt) BC exists is a YAGNI violation — flag it, log it in Deferred Items, and recommend removing it. The developer decides.
VO Discipline
A Value Object earns a dedicated class only when it carries at least one of:
- Validation invariants
- Non-trivial equality semantics
- Behaviour (methods)
Plain string/number wrappers are type aliases colocated with the aggregate file. Structural DDD elements (Aggregate, Repository, Domain Event, Application Service, ACL) remain uniform across BCs regardless of subdomain depth.
Schema-per-Tenant
- Global / shared tables →
publicschema - Per-tenant tables →
<tenant_schema>set via CLS context - Repositories targeting tenant tables must call
Model.schema(tenantContextService.getTenantSchema())on every query. - Cross-schema FKs from tenant tables to
publictables are logical only (no Postgres FK constraint). Integrity maintained by: (a) public tables are append-only / soft-delete only, (b) cascade rules enforced in application code.
Soft Delete
Never hard-delete domain records. Use isActive = false (products), status terminal states (EXPIRED, REVOKED), or equivalent per BC.
Idempotency
Every sync job or external webhook handler must be safe to call twice. Use a checksum, external correlation ID, or UNIQUE constraint to guard against duplicate processing.
Decimal Money
Always use DECIMAL(12,4) for monetary amounts in Postgres. Never use FLOAT or DOUBLE. In TypeScript use decimal.js or equivalent. Never compare Money values with ==.
Domain Events
All state transitions that adjacent BCs need to know about must emit a domain event. The event payload must contain enough context for consumers to act without querying back.
Document the event name and payload in this BC's skill. How consuming BCs handle the event is documented in the consuming BC's skill — not here.
ProductType Extensibility
Always use the ProductType enum. Never hardcode 'GIFT_CARD' as a string literal.
Ports (Outbound Dependencies)
Every outbound dependency (external API, messaging, storage outside the BC) must be accessed via a port interface defined in the domain layer (domain/ports/). The ACL adapter in the infrastructure layer implements the port. Application services depend on the port interface, never on the adapter directly.
ApplicationService → calls → SomePort (domain/ports/)
↑ implements
SomeExternalClient (infrastructure/acl/)
This rule applies uniformly to all outbound integrations — there are no exceptions for "simple" sync jobs or polling clients.
No Raw External DTOs in Domain
No domain aggregate or application service may hold a raw API response object. Translation always happens in the ACL adapter.
Reference Output
The Catalog BC skill (.github/skills/catalog/) is the canonical reference for a fully-refined, cleanly-scoped BC skill. It was produced by applying this process, including removing cross-BC contamination
Key files to reference:
SKILL.md— purpose, full module tree, business rules, VO Discipline section, ubiquitous languagedomain-model.md— type aliases block, true VO classes, Sequelize schemas, design decisionsbdd-scenarios.md— features ordered from infrastructure concern → core feature → supporting concern; no scenarios for adjacent BCs*-acl.md— the BC's ACL companion file (proxy details, token lifecycle, error handling, env vars)
04 同仓库更多 Skills
cart
暂无简介
ordering
暂无简介
catalog
暂无简介
hgate-guide
Use this skill when a user needs help deciding where to start or which hGATE skill to use next. It diagnoses the current lifecycle stage, checks available artifacts, recommends exactly one next skill, and explains that skill's input, output, fork requirement, and completion signal. Trigger phrases include "how do I use hGATE", "what should I do next", "which skill should I use", "where do I start", and "guide me through the workflow". It never invokes another skill or advances lifecycle state automatically.
domain-exploration
Use this skill when a user needs to understand a business problem or requirement, discover the relevant domain concepts, or determine whether the work belongs to one bounded context or several. Trigger phrases include "explore this domain", "identify the bounded contexts", "is this one BC or multiple BCs", "help me understand this requirement", "break this problem into domains", and "where does this feature belong". This skill is interactive and confirmation-gated. It does not produce source code or detailed BC specifications.
cross-bc-validation
Use this skill to validate one completed business journey that crosses two or more implemented bounded contexts. It performs a read-only comparison of published contracts, events, ports, adapters, runtime wiring, and tests; identifies incompatible or missing journey hops; and routes each finding to its owning BC. Trigger phrases include "validate this cross-BC feature", "verify the end-to-end bounded context flow", "check integration between these BCs", and "does this business journey work across contexts". It does not redesign boundaries or implement fixes.