Codex compatibility note:
- Invoke repository skills with
$skill-name in Codex; this mirrored copy rewrites legacy Claude /skill-name references.
- Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
- User-question prompts mean to ask the user directly in Codex.
- Ignore Claude-specific mode-switch instructions when they appear.
- Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
- Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required
spawn_agent subagent(s) for that task.
- Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
- For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
- If a required step/tool cannot run in this environment, stop and ask the user before adapting.
Codex Project-Reference Loading (No Hooks)
Codex uses static project-reference loading instead of runtime-injected project docs.
When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
Always read:
docs/project-config.json (project-specific paths, commands, modules, and workflow/test settings)
docs/project-reference/docs-index-reference.md (routes to the full docs/project-reference/* catalog)
docs/project-reference/lessons.md (always-on guardrails and anti-patterns)
Missing/stale context route: If docs/project-config.json, the docs index, lessons.md, CLAUDE.md, AGENTS.md, or any task-required reference doc is missing or stale, auto-run $project-init or the narrow setup route ($project-config, $docs-init, $scan-all, $scan --target=<key>, $claude-md-init) before ordinary project-specific work. If Codex mirrors or AGENTS.md are missing/stale, ask the user to run $sync-codex; do not auto-run it.
Situation-based docs:
- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra):
project-structure-reference.md
- Backend/CQRS/API/domain/entity changes:
backend-patterns-reference.md, domain-entities-reference.md
- Frontend/UI/styling/design-system:
frontend-patterns-reference.md, scss-styling-guide.md, design-system/README.md
- Spec authoring,
docs/specs/ pathing, or TC format: feature-spec-reference.md, spec-system-reference.md, spec-principles.md
- Behavior/public-contract changes or spec-test-code sync:
workflow-spec-test-code-cycle-reference.md plus the spec docs above
- Derived spec indexes/ERDs/reimplementation guides:
spec-system-reference.md and source Feature Specs under docs/specs/
- Integration test implementation/review:
integration-test-reference.md
- E2E test implementation/review:
e2e-test-reference.md
- Code review/audit work:
code-review-rules.md plus domain docs above based on changed files
Do not read all docs blindly. Start from docs-index-reference.md, then open only relevant files for the task.
[BLOCKING] Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
[BLOCKING] Before each step or sub-skill call, update task tracking: set in_progress when step starts, set completed when step ends.
[BLOCKING] Every completed/skipped step MUST include brief evidence or explicit skip reason.
[BLOCKING] If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
Quick Summary
Goal: Transform raw ideas into a Definition-of-Ready PBI using BA best practices, hypothesis validation, and domain research — problem-validated, tech-agnostic, with testable acceptance criteria, estimates, and a Dependencies table — so a team can build it without re-asking what or why.
Summary:
- Purpose: turn a raw idea into a groomable, Definition-of-Ready PBI a team can build without re-asking what or why.
- Main steps — run in order, track EACH (AI keeps forgetting sub-phases): Phase 0 locate active plan → 1 idea intake + module detect → 2 domain research → 3 problem-hypothesis validation (GATE) → 4 BABOK elicitation → 5 BDD acceptance criteria → 5.1 AI-SDD M1-M5/M7 gate (BLOCKING) → 5.5 testability assessment → 6 prioritization + draft estimate → 7 validation interview (GATE, 3-5 Qs) → 7.5 RE-DERIVE estimate vs locked scope → 8 PBI artifact generation.
- Two gates are NON-OPTIONAL: validate the problem hypothesis (Phase 3) before building, and run the 3-5 question validation interview (Phase 7) before writing the PBI — the user decides assumptions, scope, and dependencies, never the AI.
- Acceptance criteria are BDD GIVEN/WHEN/THEN (min 3: happy/edge/error) and MUST satisfy the AI-SDD M1-M5 and M7 gate (Phase 5.1): tech-agnostic Business Intent, logical FR-/BR- IDs first, observable single-interpretation ACs, rebuild-from-scratch validity, and every AC demoable as a business outcome (M7).
- Estimate twice: Phase 6 drafts story points/man-days against draft scope, then Phase 7.5 RE-DERIVES them against the locked post-interview scope (per SYNC:estimation-framework) — shipping stale Phase 6 numbers is the cardinal failure.
- The PBI frontmatter MUST carry
story_points, complexity, man_days_traditional, man_days_ai, and every PBI MUST include a complete Dependencies table (must-before/can-parallel/blocked-by/independent).
Workflow:
| Phase |
Name |
Key Activity |
Output |
| 0 |
Locate Active Plan |
Load plan.md if in workflow |
Plan context |
| 1 |
Idea Intake |
Load artifact, detect module |
Context loaded |
| 2 |
Domain Research |
WebSearch market/competitors |
Research summary |
| 3 |
Problem Hypothesis (GATE) |
Validate problem exists |
Confirmed hypothesis |
| 4 |
Elicitation |
Apply BABOK techniques |
Requirements extracted |
| 5 |
Acceptance Criteria |
Write BDD scenarios |
GIVEN/WHEN/THEN |
| 5.1 |
AI-SDD Gate (M1-M5/M7) |
Tech-agnostic, FR/BR IDs first, demoable |
Mandate-compliant ACs |
| 5.5 |
Testability |
Test approach + per-AC outlines |
Test seed for $spec |
| 6 |
Prioritization |
RICE/MoSCoW + DRAFT Story Points |
Priority + draft est. |
| 7 |
Validation (GATE) |
Interview user (MANDATORY, 3-5Q) |
Assumptions confirmed |
| 7.5 |
Re-estimate |
RE-DERIVE vs LOCKED scope |
Final estimate |
| 8 |
PBI Generation |
Create artifact |
PBI file saved |
Key Rules:
- NEVER skip hypothesis validation for new features
- Validation interview NOT optional — always ask 3-5 questions
- Use project domain-specific vocabulary when available
- MUST ATTENTION include
story_points, complexity, man_days_traditional, man_days_ai in PBI frontmatter
- Every PBI MUST ATTENTION include Dependencies table — types:
must-before | can-parallel | blocked-by | independent
docs/specs/ — read existing TCs for related features; recommend test spec generation for new PBIs
docs/project-reference/domain-entities-reference.md — read when task involves business entities/models
Frontend/UI Context (if applicable)
- Component patterns:
docs/project-reference/frontend-patterns-reference.md
- Styling/BEM guide:
docs/project-reference/scss-styling-guide.md
- Design system tokens:
docs/project-reference/design-system/README.md
Greenfield Mode
Auto-detected: No discovered source directories and no manifest files found. Planning artifacts (docs/, plans/, .claude/) don't count.
When greenfield detected:
- Skip existing backlog refinement (no backlog exists)
- Enable DDD domain modeling: bounded contexts, aggregates, entities, value objects
- Capture constraints: team skills, expected scale, hosting preferences, budget — as input signals only
- Use WebSearch for market research + competitor analysis
- Output domain model artifact alongside PBI artifact
- Increase ask the user directly frequency — validate domain boundaries, entity relationships, business rules
- [CRITICAL] NEVER ask about tech stack during refinement. Tech stack decided after business analysis. Capture team skills + scale expectations as signals only.
Be skeptical. Every claim needs traced proof, confidence >80%.
Phase 0: Locate Active Plan (if in workflow)
If running in workflow (big-feature, greenfield-init, etc.):
- Glob
plans/*/plan.md sorted by modification time, or check the current task list for plan context
- Read
plan.md — project scope, goals, architecture decisions, domain model
- Read existing research —
{plan-dir}/research/*.md for business evaluation, domain analysis
- Read
docs/project-reference/domain-entities-reference.md (if exists) — existing domain entities
- Use plan context — don't re-ask questions answered in prior steps
Phase 1: Idea Intake & Context Loading
- Read idea artifact from path or find by ID in
team-artifacts/ideas/
- Extract: problem statement, value proposition, target users, scope
- Check
module field; if absent, detect via keywords or prompt user
Phase 2: Domain Research
Trigger: New domain, unclear competitors, --research flag.
Skip: Internal tooling, well-understood domain, time-constrained.
Use WebSearch with domain terms. Summarize in max 3 bullets (market context, competitors, best practices).
Phase 3: Problem Hypothesis Validation
Validate hypothesis with user by asking the user directly. 42% of startups fail from no market need — validate before building.
Skip: --skip-hypothesis, validated hypothesis exists, bug fix/tech debt.
Problem Hypothesis Template
**We believe** [target users/persona]
**Experience** [specific problem]
**Because** [root cause]
**We'll know this is true when** [validation metric/evidence]
Value Hypothesis Template
**We believe** [feature/solution]
**Will deliver** [value/benefit]
**To** [target users]
**We'll know we're right when** [success metric]
Validation Process
- Draft hypothesis from idea content
- Use ask the user directly to validate:
- "Is this the core problem we're solving?"
- "Who exactly experiences this? How often?"
- "What evidence do we have this problem exists?"
- Validated → proceed to elicitation
- Invalidated → return idea for clarification
Phase 4: Requirements Elicitation (BABOK Core 5)
Think: What information gaps exist? Which technique fills them with least effort + highest confidence?
| Technique |
When to Choose |
What to Extract |
| Interviews |
Deep insights needed, stakeholder perspectives vary |
Stakeholder needs, pain points, constraints |
| Workshops |
Group consensus needed, multiple stakeholders |
Prioritized requirements, consensus decisions |
| Document Analysis |
Existing systems/processes, regulatory requirements |
As-is state, compliance requirements, gaps |
| Observation |
Users can't articulate needs, workflow unclear |
Actual vs stated workflow, hidden requirements |
| Prototyping |
Visual validation needed, UI/UX requirements vague |
Validated UI requirements, interaction patterns |
Technique notes:
- Interviews: Open-ended questions (why, how, what-if) → active listening → follow-up on unexpected → document verbatim quotes
- Workshops: Define agenda + 90 min timebox → neutral facilitator → round-robin/silent voting → document decisions AND dissent
- Observation: Shadow users → note workarounds/pain points → don't interrupt → ask clarifying questions afterward
Phase 5: Acceptance Criteria (BDD Format)
Write GIVEN/WHEN/THEN scenarios. Minimum 3: happy path, edge case, error case.
Scenario: {Descriptive title}
Given {precondition/context}
And {additional context}
When {action/trigger}
And {additional action}
Then {expected outcome}
And {additional verification}
| Practice |
Rule |
| Single trigger |
"When" clause has ONE action |
| 3 scenarios minimum |
Happy path, edge case, error case |
| No implementation details |
Behavior, not how |
| Testable outcomes |
"Then" must be verifiable |
| Stakeholder language |
No technical jargon |
Example Scenarios
Scenario: User creates invoice with valid data
Given user has permission to create invoices
And user is on the invoice creation page
When user submits invoice form with all required fields
Then invoice is created with status "Draft"
And invoice appears in user's invoice list
Scenario: Invoice creation fails with missing required field
Given user is on the invoice creation page
When user submits form without title
Then validation error "Title is required" is displayed
And invoice is not created
Scenario: Approver reviews a submitted invoice
Given approver has invoices awaiting approval
And an invoice has been submitted for approval
When approver opens the invoice review page
Then the invoice is visible with "Pending Review" status
Project Test Case Format
- Format:
TC-{FEATURE}-{NNN} (e.g., TC-GM-001)
- Evidence:
[Source: namespace/service/id] abstract-anchor format (never file:line)
- See
business-analyst skill for detailed patterns
Phase 5.1: AI-SDD Mandate Gate (M1-M5 and M7) — BLOCKING
See .claude/skills/shared/sdd-artifact-contract.md → "AI-SDD Mandates (M1-M7)" for BLOCKING criteria. The generated PBI MUST satisfy M1-M5 and M7 or be reworked before Phase 8 writes it:
- Separate intent from implementation (M1/M2): Keep a tech-agnostic Business Intent narrative (Description, Business Value, Acceptance Criteria) free of framework/product/language/design-pattern names and source identifiers. Put any optional implementation hints in a clearly separated Implementation Notes block, and put source references only in evidence carriers (
[Source: namespace/service/id], **Evidence**). Prose stays tech-agnostic per docs/project-reference/spec-principles.md §3.
- Logical Requirement ID first (M3): Assign each requirement a logical ID (
FR-/BR-) as the PRIMARY citation spine; keep [Source: namespace/service/id] abstract-anchor evidence (never physical code coordinates or repository-root paths — those live only in the provenance sidecar) as a SECONDARY carrier in a separate evidence column/section — KEEP it, never remove it.
- Testable, observable acceptance criteria (M4): Every acceptance criterion has ONE valid interpretation, observable completion states, named failure modes, and NO implementation details. Reject vague phrasing ("handle appropriately", "fast", "user-friendly").
- Rebuild-from-scratch validation (M5): Before emitting, confirm a competent team with zero codebase knowledge could re-implement identical business behavior on ANY stack from the PBI alone. If a reader would have to guess a rule, limit, role, or failure mode, add it as a clarification — never guess.
- Business-visibility (M7): Apply the demo test to each acceptance criterion's BODY: "what would a stakeholder SEE change?" — no answer → FAIL as TECHNICAL-ONLY and drop it from the PBI. Every
GIVEN = a state a user could arrange; every WHEN = an action a user could take; every THEN = an outcome a user could see. FAIL a WHEN that is an invocation (a handler runs, a consumer receives, a job fires, data syncs) or a THEN asserting schema/type/nullability/call-count. Judge the BODY, never the AC's title or ID. Never derive the AC count from an architecture inventory (handlers, consumers, jobs) — that count moves when the system is re-architected though no business behavior changed, falsifying M5.
M1 governs vocabulary; M7 governs subject matter. A technical AC in impeccably tech-free prose satisfies M1 while violating M7 — "the system correctly synchronizes the record" names no framework and is still a technical case in a business costume. That gap is the most common way business specs rot. Ask what a user could SEE, not which words were used.
Phase 5.5: Testability Assessment
Use ask the user directly with 2-3 questions:
"Which testing approach fits this PBI?"
- TDD-first: Write test specs before implementation (Recommended for complex features)
- Implement-first: Build feature, then create test specs
- Parallel: Spec and implement simultaneously
"What test levels are needed?"
- Integration tests only (Recommended for backend CQRS)
- Integration + E2E
- Unit + Integration + E2E
For EACH acceptance criterion, generate corresponding test case outline:
| AC |
Test Outline |
Priority |
| AC-1 |
TC: Create invoice with valid data → verify persisted |
P0 |
| AC-2 |
TC: Create invoice without title → verify validation error |
P1 |
Seed for $spec [mode=tests] if user chooses TDD-first. Document in PBI under ## Testability Assessment.
Phase 6: Prioritization & Estimation
Apply RICE score or MoSCoW for priority. Estimate using Story Points (Modified Fibonacci 1-21).
Quick RICE Score
Score = (Reach x Impact x Confidence) / Effort
Reach: Users affected per quarter (100, 500, 1000+)
Impact: 0.25 (minimal) | 0.5 (low) | 1 (medium) | 2 (high) | 3 (massive)
Confidence: 0.5 (low) | 0.8 (medium) | 1.0 (high)
Effort: Story points (1, 2, 3, 5, 8, 13, 21)
MoSCoW Categories
| Category |
Meaning |
Action |
| Must Have |
Critical, non-negotiable |
Include in MVP |
| Should Have |
Important but not vital |
Plan for release |
| Could Have |
Nice to have, low effort |
If time permits |
| Won't Have |
Out of scope this cycle |
Document for future |
Phase 7: Validation Interview (MANDATORY)
Generate 3-5 questions covering assumptions, scope, dependencies, edge cases. Use ask the user directly. Document in PBI. NOT optional.
| Category |
Example Question |
| Assumptions |
"We assume X is true. Correct?" |
| Scope |
"Should Y be included or explicitly excluded?" |
| Dependencies |
"This requires Z. Is that available?" |
| Edge Cases |
"What happens when data is empty/null?" |
| Business Impact |
"Will this affect existing reports/workflows?" |
| Entities |
"Create new entity or extend existing X?" |
| Prod Readiness |
"Does this feature need linting, error handling, loading, or Docker setup?" |
| Authorization |
"Who can perform this action? What roles/permissions are needed?" |
| Seed Data |
"Does this feature need reference/lookup data to function?" |
| Data Migration |
"Does this change entity schema? Is data transformation needed?" |
- Generate 3-5 questions from assumptions, scope, dependencies
- Use ask the user directly to interview
- Document in PBI under
## Validation Summary
- Update PBI based on answers
Validation Output Format
## Validation Summary
**Validated:** {date}
### Confirmed Decisions
- {decision}: {user choice}
### Assumptions Confirmed
- {assumption}: Confirmed/Modified
### Open Items
- [ ] {follow-up items}
Cross-Cutting & Production Readiness
Capture in PBI template sections: Production Readiness Concerns, Authorization & Access Control, Seed Data, Data Migration.
Phase 7.5: Re-evaluate Estimation (MANDATORY — runs after Validation Interview)
Why this phase exists: Phase 6 estimation runs against a draft scope. Phase 7 (Validation Interview) and Cross-Cutting capture often resolve unknowns, add constraints, or trim/expand scope. The numbers in story_points, complexity, man_days_traditional, man_days_ai MUST be re-derived against the locked scope BEFORE Phase 8 writes them into the PBI frontmatter. Estimating once at draft and forgetting is the #1 source of estimation drift in PBIs.
Inputs (locked by end of Phase 7)
- Confirmed assumptions, scope inclusions/exclusions
- Authorization, seed data, migration, prod-readiness decisions
- Newly discovered dependencies or edge cases
- Any rescoping the user requested during validation
Re-derive (per SYNC:estimation-framework)
- Walk the locked scope acceptance criteria + cross-cutting concerns; assign hours per slice.
bottom_up_hours = Σ slice_hours (use the SP table mapping in Phase 6, not eyeballing).
likely_days = ceil(bottom_up_hours / 6) × productivity factor for the team/AI mode.
- Recompute
risk_margin_pct based on remaining unknowns AFTER Phase 7 (margin should usually shrink because validation removed unknowns; rises only if new risks surfaced).
- Recompute
min-max range from the new likely_days ± margin.
- Re-pick the closest Fibonacci
story_points and complexity bucket from the re-derived likely_days.
Compare against Phase 6 draft estimate
Compute delta_pct = (new_likely_days - draft_likely_days) / draft_likely_days × 100.
| Delta |
Action |
|delta| ≤ 20% |
Keep draft estimate. Note reestimate_delta_pct: <signed> + reestimate_reason: "within tolerance, no change" in PBI frontmatter for transparency. |
|delta| > 20% |
UPDATE story_points, complexity, man_days_traditional, man_days_ai. Add reestimate_delta_pct: <signed> + 1-line reestimate_reason explaining what changed (e.g., "auth scope confirmed wider", "seed data dropped per validation"). |
|delta| > 50% |
UPDATE values AND flag SHOULD-RESCOPE. Surface to user by asking the user directly BEFORE Phase 8 writes the PBI: "Re-estimate is +/-X% vs original. Options: (a) accept new estimate as-is, (b) split into 2 PBIs, (c) trim scope back to original estimate, (d) defer." Record the user's decision in ## Validation Summary. |
Output
- Updated estimation values (carry into Phase 8 frontmatter)
- New frontmatter fields:
reestimate_delta_pct, reestimate_reason (always populate even when within tolerance — creates a paper trail for retrospective comparison against actual implementation time)
- If rescoped: updated acceptance criteria/scope sections reflecting the user's choice
Run this re-estimation phase against the locked scope — never skip it. A PBI that ships with stale Phase 6 estimates is the source of unreliable velocity data. The whole point is to make the post-validation numbers — not the pre-validation guesses — the ones the team commits to.
Phase 8: PBI Artifact Generation
Path: team-artifacts/pbis/{YYMMDD}-pbi-{slug}.md | ID Pattern: PBI-{YYMMDD}-{NNN}
Artifact Path (canonical convention) — Command $refine → base path team-artifacts/pbis/, role token ba, type pbi. General filename pattern: {YYMMDD}-{role}-{type}-{slug}.md → e.g. 260119-ba-pbi-invoice-approval.md. Slug = lowercased basename, non-alphanumeric → -, trimmed, max 50 chars.
PBI Template
---
id: PBI-{YYMMDD}-{NNN}
title: '{Brief descriptive title}'
module: '{ModuleName — detect from project-config.json modules[]}'
priority: Must Have | Should Have | Could Have | Won't Have
rank: { numeric 1-999, ascending — populated/updated by $prioritize during cross-PBI ranking; omit until prioritized }
story_points: 1 | 2 | 3 | 5 | 8 | 13 | 21
complexity: Low | Medium | High | Very High
man_days_traditional: '{ Xd (Yd code + Zd test) — from SP table }'
man_days_ai: '{ Xd (Yd code + Zd test) — from SP table with AI }'
status: draft | refined | ready | in_progress | done
rice_score: { calculated }
created: '{YYYY-MM-DD}'
source_idea: '{idea artifact path or ID}'
---
# {PBI Title}
> **Business Intent (tech-agnostic — M1/M2):** Description, Business Value, Business Rules, and Acceptance Criteria below describe observable business behavior only — no framework/product/language/design-pattern names, no source identifiers. Keep implementation hints in `## Implementation Notes` and source references in evidence carriers.
## Requirement IDs (M3 — logical-IDs-first)
| Logical ID | Statement (tech-agnostic) | Evidence (secondary, re-anchorable) |
| ------------ | ------------------------- | ----------------------------------------- |
| FR-{MOD}-XXX | {functional requirement} | `[Source: path:line]` or `TBD (pre-impl)` |
| BR-{MOD}-XXX | {business rule} | `[Source: path:line]` or `TBD (pre-impl)` |
## Description
**As a** {user role}
**I want** {capability}
**So that** {business value}
## Business Value
- {Quantified benefit 1}
- {Quantified benefit 2}
## Problem Hypothesis
**We believe** {target users}
**Experience** {specific problem}
**Because** {root cause}
**We'll know this is true when** {validation metric}
## Business Rules
- BR-{MOD}-XXX: {Rule description}
## Acceptance Criteria
### AC-1: {Title}
Scenario: {Happy path}
Given {context}
When {action}
Then {outcome}
### AC-2: {Title}
Scenario: {Edge case}
Given {edge state}
When {action}
Then {handling}
### AC-3: {Title}
Scenario: {Error case}
Given {context}
When {invalid action}
Then error "{message}"
## Testability Assessment
| AC | Test Outline | Priority |
| ---- | ------------------ | -------- |
| AC-1 | {test description} | P0 |
| AC-2 | {test description} | P1 |
## Out of Scope
- {Explicitly excluded item 1}
- {Explicitly excluded item 2}
## Dependencies
| Dependency | Type | Description |
| --------------------- | ------------ | ------------------------------ |
| {PBI/service/feature} | must-before | {Why this must be done first} |
| {PBI/service/feature} | can-parallel | {Why this can run in parallel} |
| {PBI/service/feature} | blocked-by | {What blocks this PBI} |
| - | independent | {No dependencies — first item} |
## Production Readiness Concerns
| Concern | Required | Notes |
| ---------------------- | --------------- | ----------------------------------------------------------------------- |
| Code linting/analyzers | Yes/No/Existing | {tool preference or "scaffold default"} |
| Error handling setup | Yes/No/Existing | {pattern: toast/inline/error-page} |
| Loading indicators | Yes/No/Existing | {pattern: spinner/skeleton/progress} |
| Docker integration | Yes/No/Existing | {scope: infra-only/full/none} |
| CI/CD quality gates | Yes/No/Existing | {mutation-score gate (line-coverage diagnostic only), lint enforcement} |
| Security scanning | Yes/No/Existing | {dependency audit, SAST} |
## Authorization & Access Control
| Role | Can Create | Can Read | Can Update | Can Delete | Notes |
| ------ | ---------- | -------- | ---------- | ---------- | ------------- |
| {Role} | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | {scope notes} |
**New permissions needed:** {Yes/No — list if yes}
**Multi-tenant isolation:** {Yes/No}
## Seed Data Requirements
| Data Type | Description | Owner | Required |
| ------------------ | ------------------------------------ | ------------ | -------- |
| Reference data | {lookups, statuses, types} | Application | Yes/No |
| Configuration data | {default settings} | Application | Yes/No |
| Test seed data | {entities for integration tests} | Test project | Yes/No |
| Performance data | {large-volume data for load testing} | Test tooling | Yes/No |
> If no seed data needed: `N/A — no seed data required for this feature.`
## Data Migration
| Change | Type | Backward Compatible | Reversible |
| --------------------------- | -------------------------------------- | ------------------- | ---------- |
| {schema change description} | Add field / Remove field / Type change | Yes/No | Yes/No |
> If no schema changes: `N/A — no schema changes required.`
## Domain Context
**Entities:** {Entity1}, {Entity2}
**Related Features:** {feature doc paths}
## Implementation Notes
> Optional, clearly separated from Business Intent. Implementation hints / source identifiers may appear here and in evidence carriers only — never in the tech-agnostic sections above. If none: `N/A — no implementation hints; rebuild from Business Intent + Requirement IDs.`
## UI Layout
**Design Spec:** {link to the `$design-spec` artifact — or inline UI specs ref — that owns this PBI's screen/component design. REQUIRED for any PBI with UI work. Produce it AFTER inventorying existing UI + connected flows (per `SYNC:existing-ui-research`) so it faithfully matches the current UI system. If backend-only: `N/A — Backend-only change. No UI affected.`}
### Wireframe
{ASCII wireframe using box-drawing characters}
**Layout:** {description with approximate proportions/dimensions}
### Components
- **{ComponentName}** — {behavior description} _(tier: common | domain-shared | page/app)_
> Classify per **Component Hierarchy** in UI wireframe protocol — search existing libs before proposing new components.
### States
| State | Behavior |
| ------- | -------------------------- |
| Default | {what user sees initially} |
| Loading | {spinner/skeleton} |
| Empty | {empty state message} |
| Error | {error handling} |
> If backend-only: `## UI Layout` → `N/A — Backend-only change. No UI affected.`
## Validation Summary
**Validated:** {date}
### Confirmed Decisions
- {decision}: {user choice}
### Assumptions Confirmed
- {assumption}: Confirmed/Modified
### Open Items
- [ ] {follow-up items}
Anti-Patterns to Avoid
| Anti-Pattern |
Better Approach |
| Refining vague ideas |
Return to $idea for clarification |
| Skipping hypothesis validation |
Always run Phase 3 for new features |
| Solution-first thinking |
Start with problem, not solution |
| Generic acceptance criteria |
Use GIVEN/WHEN/THEN with specifics |
| Ignoring domain context |
Load project docs if applicable |
| Too large PBI (XL+) |
Break into smaller items |
| Missing "Out of Scope" |
Explicitly list exclusions |
| Assuming instead of asking |
Run validation interview |
Key Rules
- Every PBI MUST ATTENTION include Dependencies table — types:
must-before, can-parallel, blocked-by, independent. Enables $prioritize and $plan to respect ordering.
- No vague dependency descriptions — Each dependency must specify concrete PBI, service, or feature and WHY relationship exists.
BA Team Refinement Context (canonical)
Applies to Writes/Edits under team-artifacts/pbis/, .../stories/, team-artifacts/ideas/. Mirrored for Codex via SYNC:ba-team-decision-model / SYNC:refinement-dor-checklist in AGENTS.md (do not hand-edit the mirror).
Decision Model: 2/3 majority vote (UX BA + Designer BA + Dev BA PIC). Dev BA PIC has technical veto.
Disagree-and-Commit: Once decided, everyone commits. No re-litigating.
Grooming Override: BA team decision changes only if >75% remaining team votes to override.
Role Scopes:
- UX BA: UI/UX flows, wireframes, interaction AC, user research
- Designer BA: Design feasibility, product thinking, visual design, equal vote
- Dev BA PIC: Technical feasibility review, AI pre-review, DoR gate, grooming presentation
DoR Gate (ALL must pass before grooming):
Refinement Cadence: Always one sprint ahead. Weekly meeting (60 min + ~3h async).
Skills: Use $pbi-challenge for collaborative review, $dor-gate before grooming.
Definition of Ready (INVEST)
| Criterion |
Check |
| Independent |
No blocking dependencies |
| Negotiable |
Details can be refined |
| Valuable |
Clear user/business value |
| Estimable |
Team can estimate (XS-XL) |
| Small |
Single sprint |
| Testable |
3+ GIVEN/WHEN/THEN scenarios |
| Problem Validated |
Hypothesis confirmed |
| Domain Context |
BR/entity context loaded |
| Stakeholder Aligned |
Validation interview done |
| Prod Readiness |
Concerns documented |
Project Integration
For domain PBIs: detect module from docs/specs/ directory names, extract business rules from docs/specs/{module}/, load entity context from feature doc. Target 8-12K tokens for feature context.
Related
- Role Skill:
business-analyst (detailed patterns)
- Input:
$idea output
- Next Step:
$story, $spec [mode=tests] (Recommended for TDD), $design-spec
- Prioritization:
$prioritize
Next Steps
MANDATORY IMPORTANT MUST ATTENTION after completing this skill, use ask the user directly to present these options. NEVER skip because task seems "simple" or "obvious":
- "$why-review (Recommended)" — Validate design rationale, alternatives, risk assessment before
$story or implementation
- "$domain-analysis" — If PBI creates/modifies domain entities, model bounded contexts before writing stories
- "$story" — Break PBI into implementable user stories
- "$pbi-mockup" — Generate HTML mockup from PBI
- "$spec [mode=tests]" — If using TDD approach
- "Skip, continue manually" — user decides
[IMPORTANT] Use task tracking to break ALL work into small tasks BEFORE starting. Simple tasks: ask user whether to skip.
External Memory: Complex/lengthy work → write findings to plans/reports/ — prevents context loss.
Evidence Gate: MANDATORY IMPORTANT MUST ATTENTION — every claim requires file:line proof or traced evidence, confidence >80% to act.
AI Mistake Prevention — Failure modes to avoid on every task:
Re-read files after context changes. Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
Verify generated content against source evidence. AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
Check downstream references before deleting or renaming. Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
Trace the full impact chain after edits. Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
Verify ALL affected outputs, not just the first. One green check is not all green checks; validate every output surface the change can affect.
Assume existing values are intentional — ask WHY before changing OR flagging one as a defect. Before changing or reporting a constant, limit, flag, cutoff, wording, or pattern, read nearby context and history, the CALLER's ordering, and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard.
Surface ambiguity before acting — don't pick silently. Multiple valid interpretations require an explicit question or stated assumption with risk.
Assert the outcome your system owns, not the intermediate state your infrastructure owns. When verifying async work, assert the final business state — never the delivery/retry bookkeeping held in shared infrastructure that any co-running process can write. Such a check passes when run alone and flakes the moment anything else shares that infrastructure.
Keep shared guidance role-relevant. Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
UI System Context — For ANY task touching .ts, .html, .scss, or .css files:
MUST ATTENTION READ before implementing:
docs/project-reference/frontend-patterns-reference.md — component base classes, stores, forms
docs/project-reference/scss-styling-guide.md — BEM methodology, SCSS variables, mixins, responsive
docs/project-reference/design-system/README.md — design tokens, component inventory, icons
Reference docs/project-config.json for project-specific paths.
1---2name: refine3description: [Project Management] Use when converting ideas to PBIs, validating problem hypotheses, adding acceptance criteria, or refining requirements.4---5
6> Codex compatibility note:
7>
8> - Invoke repository skills with `$skill-name` in Codex; this mirrored copy rewrites legacy Claude `/skill-name` references.
9> - Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
10> - User-question prompts mean to ask the user directly in Codex.
11> - Ignore Claude-specific mode-switch instructions when they appear.
12> - Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
13> - Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required `spawn_agent` subagent(s) for that task.
14> - Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
15> - For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
16> - If a required step/tool cannot run in this environment, stop and ask the user before adapting.
17
18<!-- CODEX:PROJECT-REFERENCE-LOADING:START -->
19
20## Codex Project-Reference Loading (No Hooks)
21
22Codex uses static project-reference loading instead of runtime-injected project docs.
23When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
24
25**Always read:**
26
27- `docs/project-config.json` (project-specific paths, commands, modules, and workflow/test settings)
28- `docs/project-reference/docs-index-reference.md` (routes to the full `docs/project-reference/*` catalog)
29- `docs/project-reference/lessons.md` (always-on guardrails and anti-patterns)
30
31**Missing/stale context route:** If `docs/project-config.json`, the docs index, `lessons.md`, `CLAUDE.md`, `AGENTS.md`, or any task-required reference doc is missing or stale, auto-run `$project-init` or the narrow setup route (`$project-config`, `$docs-init`, `$scan-all`, `$scan --target=<key>`, `$claude-md-init`) before ordinary project-specific work. If Codex mirrors or `AGENTS.md` are missing/stale, ask the user to run `$sync-codex`; do not auto-run it.
32
33**Situation-based docs:**
34
35- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra): `project-structure-reference.md`
36- Backend/CQRS/API/domain/entity changes: `backend-patterns-reference.md`, `domain-entities-reference.md`
37- Frontend/UI/styling/design-system: `frontend-patterns-reference.md`, `scss-styling-guide.md`, `design-system/README.md`
38- Spec authoring, `docs/specs/` pathing, or TC format: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`
39- Behavior/public-contract changes or spec-test-code sync: `workflow-spec-test-code-cycle-reference.md` plus the spec docs above
40- Derived spec indexes/ERDs/reimplementation guides: `spec-system-reference.md` and source Feature Specs under `docs/specs/`
41- Integration test implementation/review: `integration-test-reference.md`
42- E2E test implementation/review: `e2e-test-reference.md`
43- Code review/audit work: `code-review-rules.md` plus domain docs above based on changed files
44
45Do not read all docs blindly. Start from `docs-index-reference.md`, then open only relevant files for the task.
46
47<!-- CODEX:PROJECT-REFERENCE-LOADING:END -->
48
49<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:START -->
50
51> **[BLOCKING]** Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
52> **[BLOCKING]** Before each step or sub-skill call, update task tracking: set `in_progress` when step starts, set `completed` when step ends.
53> **[BLOCKING]** Every completed/skipped step MUST include brief evidence or explicit skip reason.
54> **[BLOCKING]** If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
55
56<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->
57
58## Quick Summary
59
60**Goal:** Transform raw ideas into a Definition-of-Ready PBI using BA best practices, hypothesis validation, and domain research — problem-validated, tech-agnostic, with testable acceptance criteria, estimates, and a Dependencies table — so a team can build it without re-asking what or why.
61
62**Summary:**
63
64- **Purpose:** turn a raw idea into a groomable, Definition-of-Ready PBI a team can build without re-asking what or why.
65- **Main steps — run in order, track EACH (AI keeps forgetting sub-phases):** Phase 0 locate active plan → 1 idea intake + module detect → 2 domain research → 3 problem-hypothesis validation (GATE) → 4 BABOK elicitation → 5 BDD acceptance criteria → 5.1 AI-SDD M1-M5/M7 gate (BLOCKING) → 5.5 testability assessment → 6 prioritization + draft estimate → 7 validation interview (GATE, 3-5 Qs) → 7.5 RE-DERIVE estimate vs locked scope → 8 PBI artifact generation.
66- Two gates are NON-OPTIONAL: validate the problem hypothesis (Phase 3) before building, and run the 3-5 question validation interview (Phase 7) before writing the PBI — the user decides assumptions, scope, and dependencies, never the AI.
67- Acceptance criteria are BDD GIVEN/WHEN/THEN (min 3: happy/edge/error) and MUST satisfy the AI-SDD M1-M5 and M7 gate (Phase 5.1): tech-agnostic Business Intent, logical FR-/BR- IDs first, observable single-interpretation ACs, rebuild-from-scratch validity, and every AC demoable as a business outcome (M7).
68- Estimate twice: Phase 6 drafts story points/man-days against draft scope, then Phase 7.5 RE-DERIVES them against the locked post-interview scope (per SYNC:estimation-framework) — shipping stale Phase 6 numbers is the cardinal failure.
69- The PBI frontmatter MUST carry `story_points`, `complexity`, `man_days_traditional`, `man_days_ai`, and every PBI MUST include a complete Dependencies table (`must-before`/`can-parallel`/`blocked-by`/`independent`).
70
71**Workflow:**
72
73| Phase | Name | Key Activity | Output |
74| ----- | ------------------------- | ---------------------------------------- | ---------------------- |
75| 0 | Locate Active Plan | Load `plan.md` if in workflow | Plan context |
76| 1 | Idea Intake | Load artifact, detect module | Context loaded |
77| 2 | Domain Research | WebSearch market/competitors | Research summary |
78| 3 | Problem Hypothesis (GATE) | Validate problem exists | Confirmed hypothesis |
79| 4 | Elicitation | Apply BABOK techniques | Requirements extracted |
80| 5 | Acceptance Criteria | Write BDD scenarios | GIVEN/WHEN/THEN |
81| 5.1 | AI-SDD Gate (M1-M5/M7) | Tech-agnostic, FR/BR IDs first, demoable | Mandate-compliant ACs |
82| 5.5 | Testability | Test approach + per-AC outlines | Test seed for `$spec` |
83| 6 | Prioritization | RICE/MoSCoW + DRAFT Story Points | Priority + draft est. |
84| 7 | Validation (GATE) | Interview user (MANDATORY, 3-5Q) | Assumptions confirmed |
85| 7.5 | Re-estimate | RE-DERIVE vs LOCKED scope | Final estimate |
86| 8 | PBI Generation | Create artifact | PBI file saved |
87
88**Key Rules:**
89
90- NEVER skip hypothesis validation for new features
91- Validation interview NOT optional — always ask 3-5 questions
92- Use project domain-specific vocabulary when available
93- MUST ATTENTION include `story_points`, `complexity`, `man_days_traditional`, `man_days_ai` in PBI frontmatter
94- Every PBI MUST ATTENTION include Dependencies table — types: `must-before` | `can-parallel` | `blocked-by` | `independent`
95- `docs/specs/` — read existing TCs for related features; recommend test spec generation for new PBIs
96- `docs/project-reference/domain-entities-reference.md` — read when task involves business entities/models
97
98---
99
100## Frontend/UI Context (if applicable)
101
102- Component patterns: `docs/project-reference/frontend-patterns-reference.md`
103- Styling/BEM guide: `docs/project-reference/scss-styling-guide.md`
104- Design system tokens: `docs/project-reference/design-system/README.md`
105
106---
107
108## Greenfield Mode
109
110> **Auto-detected:** No discovered source directories and no manifest files found. Planning artifacts (docs/, plans/, .claude/) don't count.
111
112**When greenfield detected:**
113
1141. Skip existing backlog refinement (no backlog exists)
1152. Enable DDD domain modeling: bounded contexts, aggregates, entities, value objects
1163. Capture constraints: team skills, expected scale, hosting preferences, budget — as input signals only
1174. Use WebSearch for market research + competitor analysis
1185. Output domain model artifact alongside PBI artifact
1196. Increase ask the user directly frequency — validate domain boundaries, entity relationships, business rules
1207. **[CRITICAL] NEVER ask about tech stack during refinement.** Tech stack decided after business analysis. Capture team skills + scale expectations as signals only.
121
122**Be skeptical. Every claim needs traced proof, confidence >80%.**
123
124---
125
126## Phase 0: Locate Active Plan (if in workflow)
127
128If running in workflow (big-feature, greenfield-init, etc.):
129
1301. Glob `plans/*/plan.md` sorted by modification time, or check the current task list for plan context
1312. Read `plan.md` — project scope, goals, architecture decisions, domain model
1323. Read existing research — `{plan-dir}/research/*.md` for business evaluation, domain analysis
1334. Read `docs/project-reference/domain-entities-reference.md` (if exists) — existing domain entities
1345. Use plan context — don't re-ask questions answered in prior steps
135
136## Phase 1: Idea Intake & Context Loading
137
1381. Read idea artifact from path or find by ID in `team-artifacts/ideas/`
1392. Extract: problem statement, value proposition, target users, scope
1403. Check `module` field; if absent, detect via keywords or prompt user
141
142---
143
144## Phase 2: Domain Research
145
146**Trigger:** New domain, unclear competitors, `--research` flag.
147**Skip:** Internal tooling, well-understood domain, time-constrained.
148
149Use WebSearch with domain terms. Summarize in max 3 bullets (market context, competitors, best practices).
150
151---
152
153## Phase 3: Problem Hypothesis Validation
154
155Validate hypothesis with user by asking the user directly. 42% of startups fail from no market need — validate before building.
156
157**Skip:** `--skip-hypothesis`, validated hypothesis exists, bug fix/tech debt.
158
159### Problem Hypothesis Template
160
161```markdown
162**We believe** [target users/persona]
163**Experience** [specific problem]
164**Because** [root cause]
165**We'll know this is true when** [validation metric/evidence]
166```
167
168### Value Hypothesis Template
169
170```markdown
171**We believe** [feature/solution]
172**Will deliver** [value/benefit]
173**To** [target users]
174**We'll know we're right when** [success metric]
175```
176
177### Validation Process
178
1791. Draft hypothesis from idea content
1802. Use ask the user directly to validate:
181 - "Is this the core problem we're solving?"
182 - "Who exactly experiences this? How often?"
183 - "What evidence do we have this problem exists?"
1843. Validated → proceed to elicitation
1854. Invalidated → return idea for clarification
186
187---
188
189## Phase 4: Requirements Elicitation (BABOK Core 5)
190
191**Think:** What information gaps exist? Which technique fills them with least effort + highest confidence?
192
193| Technique | When to Choose | What to Extract |
194| --------------------- | --------------------------------------------------- | ----------------------------------------------- |
195| **Interviews** | Deep insights needed, stakeholder perspectives vary | Stakeholder needs, pain points, constraints |
196| **Workshops** | Group consensus needed, multiple stakeholders | Prioritized requirements, consensus decisions |
197| **Document Analysis** | Existing systems/processes, regulatory requirements | As-is state, compliance requirements, gaps |
198| **Observation** | Users can't articulate needs, workflow unclear | Actual vs stated workflow, hidden requirements |
199| **Prototyping** | Visual validation needed, UI/UX requirements vague | Validated UI requirements, interaction patterns |
200
201**Technique notes:**
202
203- Interviews: Open-ended questions (why, how, what-if) → active listening → follow-up on unexpected → document verbatim quotes
204- Workshops: Define agenda + 90 min timebox → neutral facilitator → round-robin/silent voting → document decisions AND dissent
205- Observation: Shadow users → note workarounds/pain points → don't interrupt → ask clarifying questions afterward
206
207---
208
209## Phase 5: Acceptance Criteria (BDD Format)
210
211Write GIVEN/WHEN/THEN scenarios. Minimum 3: happy path, edge case, error case.
212
213```gherkin
214Scenario: {Descriptive title}
215 Given {precondition/context}
216 And {additional context}
217 When {action/trigger}
218 And {additional action}
219 Then {expected outcome}
220 And {additional verification}
221```
222
223| Practice | Rule |
224| ------------------------- | --------------------------------- |
225| Single trigger | "When" clause has ONE action |
226| 3 scenarios minimum | Happy path, edge case, error case |
227| No implementation details | Behavior, not how |
228| Testable outcomes | "Then" must be verifiable |
229| Stakeholder language | No technical jargon |
230
231### Example Scenarios
232
233```gherkin
234Scenario: User creates invoice with valid data
235 Given user has permission to create invoices
236 And user is on the invoice creation page
237 When user submits invoice form with all required fields
238 Then invoice is created with status "Draft"
239 And invoice appears in user's invoice list
240
241Scenario: Invoice creation fails with missing required field
242 Given user is on the invoice creation page
243 When user submits form without title
244 Then validation error "Title is required" is displayed
245 And invoice is not created
246
247Scenario: Approver reviews a submitted invoice
248 Given approver has invoices awaiting approval
249 And an invoice has been submitted for approval
250 When approver opens the invoice review page
251 Then the invoice is visible with "Pending Review" status
252```
253
254### Project Test Case Format
255
256- **Format:** `TC-{FEATURE}-{NNN}` (e.g., TC-GM-001)
257- **Evidence:** `[Source: namespace/service/id]` abstract-anchor format (never `file:line`)
258- See `business-analyst` skill for detailed patterns
259
260---
261
262### Phase 5.1: AI-SDD Mandate Gate (M1-M5 and M7) — BLOCKING
263
264See `.claude/skills/shared/sdd-artifact-contract.md` → "AI-SDD Mandates (M1-M7)" for BLOCKING criteria. The generated PBI MUST satisfy M1-M5 and M7 or be reworked before Phase 8 writes it:
265
266- **Separate intent from implementation (M1/M2):** Keep a tech-agnostic **Business Intent** narrative (Description, Business Value, Acceptance Criteria) free of framework/product/language/design-pattern names and source identifiers. Put any optional implementation hints in a clearly separated **Implementation Notes** block, and put source references only in evidence carriers (`[Source: namespace/service/id]`, `**Evidence**`). Prose stays tech-agnostic per `docs/project-reference/spec-principles.md` §3.
267- **Logical Requirement ID first (M3):** Assign each requirement a logical ID (`FR-`/`BR-`) as the PRIMARY citation spine; keep `[Source: namespace/service/id]` abstract-anchor evidence (never physical code coordinates or repository-root paths — those live only in the provenance sidecar) as a SECONDARY carrier in a separate evidence column/section — KEEP it, never remove it.
268- **Testable, observable acceptance criteria (M4):** Every acceptance criterion has ONE valid interpretation, observable completion states, named failure modes, and NO implementation details. Reject vague phrasing ("handle appropriately", "fast", "user-friendly").
269- **Rebuild-from-scratch validation (M5):** Before emitting, confirm a competent team with zero codebase knowledge could re-implement identical business behavior on ANY stack from the PBI alone. If a reader would have to guess a rule, limit, role, or failure mode, add it as a clarification — never guess.
270- **Business-visibility (M7):** Apply the demo test to each acceptance criterion's BODY: _"what would a stakeholder SEE change?"_ — no answer → FAIL as TECHNICAL-ONLY and drop it from the PBI. Every `GIVEN` = a state a user could arrange; every `WHEN` = an action a user could take; every `THEN` = an outcome a user could see. FAIL a `WHEN` that is an invocation (a handler runs, a consumer receives, a job fires, data syncs) or a `THEN` asserting schema/type/nullability/call-count. Judge the BODY, never the AC's title or ID. Never derive the AC count from an architecture inventory (handlers, consumers, jobs) — that count moves when the system is re-architected though no business behavior changed, falsifying M5.
271
272> **M1 governs vocabulary; M7 governs subject matter.** A technical AC in impeccably tech-free prose satisfies M1 while violating M7 — _"the system correctly synchronizes the record"_ names no framework and is still a technical case in a business costume. That gap is the most common way business specs rot. Ask what a user could SEE, not which words were used.
273
274---
275
276### Phase 5.5: Testability Assessment
277
278Use ask the user directly with 2-3 questions:
279
2801. "Which testing approach fits this PBI?"
281 - TDD-first: Write test specs before implementation (Recommended for complex features)
282 - Implement-first: Build feature, then create test specs
283 - Parallel: Spec and implement simultaneously
284
2852. "What test levels are needed?"
286 - Integration tests only (Recommended for backend CQRS)
287 - Integration + E2E
288 - Unit + Integration + E2E
289
290For EACH acceptance criterion, generate corresponding test case outline:
291
292| AC | Test Outline | Priority |
293| ---- | ---------------------------------------------------------- | -------- |
294| AC-1 | TC: Create invoice with valid data → verify persisted | P0 |
295| AC-2 | TC: Create invoice without title → verify validation error | P1 |
296
297Seed for `$spec [mode=tests]` if user chooses TDD-first. Document in PBI under `## Testability Assessment`.
298
299---
300
301## Phase 6: Prioritization & Estimation
302
303Apply RICE score or MoSCoW for priority. Estimate using **Story Points (Modified Fibonacci 1-21)**.
304
305### Quick RICE Score
306
307```
308Score = (Reach x Impact x Confidence) / Effort
309
310Reach: Users affected per quarter (100, 500, 1000+)
311Impact: 0.25 (minimal) | 0.5 (low) | 1 (medium) | 2 (high) | 3 (massive)
312Confidence: 0.5 (low) | 0.8 (medium) | 1.0 (high)
313Effort: Story points (1, 2, 3, 5, 8, 13, 21)
314```
315
316### MoSCoW Categories
317
318| Category | Meaning | Action |
319| --------------- | ------------------------ | ------------------- |
320| **Must Have** | Critical, non-negotiable | Include in MVP |
321| **Should Have** | Important but not vital | Plan for release |
322| **Could Have** | Nice to have, low effort | If time permits |
323| **Won't Have** | Out of scope this cycle | Document for future |
324
325---
326
327## Phase 7: Validation Interview (MANDATORY)
328
329Generate 3-5 questions covering assumptions, scope, dependencies, edge cases. Use ask the user directly. Document in PBI. **NOT optional.**
330
331| Category | Example Question |
332| ------------------- | --------------------------------------------------------------------------- |
333| **Assumptions** | "We assume X is true. Correct?" |
334| **Scope** | "Should Y be included or explicitly excluded?" |
335| **Dependencies** | "This requires Z. Is that available?" |
336| **Edge Cases** | "What happens when data is empty/null?" |
337| **Business Impact** | "Will this affect existing reports/workflows?" |
338| **Entities** | "Create new entity or extend existing X?" |
339| **Prod Readiness** | "Does this feature need linting, error handling, loading, or Docker setup?" |
340| **Authorization** | "Who can perform this action? What roles/permissions are needed?" |
341| **Seed Data** | "Does this feature need reference/lookup data to function?" |
342| **Data Migration** | "Does this change entity schema? Is data transformation needed?" |
343
3441. Generate 3-5 questions from assumptions, scope, dependencies
3452. Use ask the user directly to interview
3463. Document in PBI under `## Validation Summary`
3474. Update PBI based on answers
348
349### Validation Output Format
350
351```markdown
352## Validation Summary
353
354**Validated:** {date}
355
356### Confirmed Decisions
357
358- {decision}: {user choice}
359
360### Assumptions Confirmed
361
362- {assumption}: Confirmed/Modified
363
364### Open Items
365
366- [ ] {follow-up items}
367```
368
369---
370
371## Cross-Cutting & Production Readiness
372
373> Capture in PBI template sections: Production Readiness Concerns, Authorization & Access Control, Seed Data, Data Migration.
374
375---
376
377## Phase 7.5: Re-evaluate Estimation (MANDATORY — runs after Validation Interview)
378
379> **Why this phase exists:** Phase 6 estimation runs against a draft scope. Phase 7 (Validation Interview) and Cross-Cutting capture often resolve unknowns, add constraints, or trim/expand scope. The numbers in `story_points`, `complexity`, `man_days_traditional`, `man_days_ai` MUST be re-derived against the locked scope BEFORE Phase 8 writes them into the PBI frontmatter. Estimating once at draft and forgetting is the #1 source of estimation drift in PBIs.
380
381### Inputs (locked by end of Phase 7)
382
383- Confirmed assumptions, scope inclusions/exclusions
384- Authorization, seed data, migration, prod-readiness decisions
385- Newly discovered dependencies or edge cases
386- Any rescoping the user requested during validation
387
388### Re-derive (per `SYNC:estimation-framework`)
389
3901. Walk the **locked** scope acceptance criteria + cross-cutting concerns; assign hours per slice.
3912. `bottom_up_hours = Σ slice_hours` (use the SP table mapping in Phase 6, not eyeballing).
3923. `likely_days = ceil(bottom_up_hours / 6)` × productivity factor for the team/AI mode.
3934. Recompute `risk_margin_pct` based on remaining unknowns AFTER Phase 7 (margin should usually shrink because validation removed unknowns; rises only if new risks surfaced).
3945. Recompute `min-max range` from the new likely_days ± margin.
3956. Re-pick the closest Fibonacci `story_points` and `complexity` bucket from the re-derived likely_days.
396
397### Compare against Phase 6 draft estimate
398
399Compute `delta_pct = (new_likely_days - draft_likely_days) / draft_likely_days × 100`.
400
401| Delta | Action |
402| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
403| `\|delta\| ≤ 20%` | Keep draft estimate. Note `reestimate_delta_pct: <signed>` + `reestimate_reason: "within tolerance, no change"` in PBI frontmatter for transparency. |
404| `\|delta\| > 20%` | UPDATE `story_points`, `complexity`, `man_days_traditional`, `man_days_ai`. Add `reestimate_delta_pct: <signed>` + 1-line `reestimate_reason` explaining what changed (e.g., "auth scope confirmed wider", "seed data dropped per validation"). |
405| `\|delta\| > 50%` | UPDATE values AND flag `SHOULD-RESCOPE`. Surface to user by asking the user directly BEFORE Phase 8 writes the PBI: "Re-estimate is +/-X% vs original. Options: (a) accept new estimate as-is, (b) split into 2 PBIs, (c) trim scope back to original estimate, (d) defer." Record the user's decision in `## Validation Summary`. |
406
407### Output
408
409- Updated estimation values (carry into Phase 8 frontmatter)
410- New frontmatter fields: `reestimate_delta_pct`, `reestimate_reason` (always populate even when within tolerance — creates a paper trail for retrospective comparison against actual implementation time)
411- If rescoped: updated acceptance criteria/scope sections reflecting the user's choice
412
413> **Run this re-estimation phase against the locked scope — never skip it.** A PBI that ships with stale Phase 6 estimates is the source of unreliable velocity data. The whole point is to make the post-validation numbers — not the pre-validation guesses — the ones the team commits to.
414
415---
416
417## Phase 8: PBI Artifact Generation
418
419**Path:** `team-artifacts/pbis/{YYMMDD}-pbi-{slug}.md` | **ID Pattern:** `PBI-{YYMMDD}-{NNN}`
420
421> **Artifact Path (canonical convention)** — Command `$refine` → base path `team-artifacts/pbis/`, role token `ba`, type `pbi`. General filename pattern: `{YYMMDD}-{role}-{type}-{slug}.md` → e.g. `260119-ba-pbi-invoice-approval.md`. Slug = lowercased basename, non-alphanumeric → `-`, trimmed, max 50 chars.
422
423### PBI Template
424
425```markdown
426---
427id: PBI-{YYMMDD}-{NNN}
428title: '{Brief descriptive title}'
429module: '{ModuleName — detect from project-config.json modules[]}'
430priority: Must Have | Should Have | Could Have | Won't Have
431rank: { numeric 1-999, ascending — populated/updated by $prioritize during cross-PBI ranking; omit until prioritized }
432story_points: 1 | 2 | 3 | 5 | 8 | 13 | 21
433complexity: Low | Medium | High | Very High
434man_days_traditional: '{ Xd (Yd code + Zd test) — from SP table }'
435man_days_ai: '{ Xd (Yd code + Zd test) — from SP table with AI }'
436status: draft | refined | ready | in_progress | done
437rice_score: { calculated }
438created: '{YYYY-MM-DD}'
439source_idea: '{idea artifact path or ID}'
440---
441
442# {PBI Title}
443
444> **Business Intent (tech-agnostic — M1/M2):** Description, Business Value, Business Rules, and Acceptance Criteria below describe observable business behavior only — no framework/product/language/design-pattern names, no source identifiers. Keep implementation hints in `## Implementation Notes` and source references in evidence carriers.
445
446## Requirement IDs (M3 — logical-IDs-first)
447
448| Logical ID | Statement (tech-agnostic) | Evidence (secondary, re-anchorable) |
449| ------------ | ------------------------- | ----------------------------------------- |
450| FR-{MOD}-XXX | {functional requirement} | `[Source: path:line]` or `TBD (pre-impl)` |
451| BR-{MOD}-XXX | {business rule} | `[Source: path:line]` or `TBD (pre-impl)` |
452
453## Description
454
455**As a** {user role}
456**I want** {capability}
457**So that** {business value}
458
459## Business Value
460
461- {Quantified benefit 1}
462- {Quantified benefit 2}
463
464## Problem Hypothesis
465
466**We believe** {target users}
467**Experience** {specific problem}
468**Because** {root cause}
469**We'll know this is true when** {validation metric}
470
471## Business Rules
472
473- BR-{MOD}-XXX: {Rule description}
474
475## Acceptance Criteria
476
477### AC-1: {Title}
478
479Scenario: {Happy path}
480Given {context}
481When {action}
482Then {outcome}
483
484### AC-2: {Title}
485
486Scenario: {Edge case}
487Given {edge state}
488When {action}
489Then {handling}
490
491### AC-3: {Title}
492
493Scenario: {Error case}
494Given {context}
495When {invalid action}
496Then error "{message}"
497
498## Testability Assessment
499
500| AC | Test Outline | Priority |
501| ---- | ------------------ | -------- |
502| AC-1 | {test description} | P0 |
503| AC-2 | {test description} | P1 |
504
505## Out of Scope
506
507- {Explicitly excluded item 1}
508- {Explicitly excluded item 2}
509
510## Dependencies
511
512| Dependency | Type | Description |
513| --------------------- | ------------ | ------------------------------ |
514| {PBI/service/feature} | must-before | {Why this must be done first} |
515| {PBI/service/feature} | can-parallel | {Why this can run in parallel} |
516| {PBI/service/feature} | blocked-by | {What blocks this PBI} |
517| - | independent | {No dependencies — first item} |
518
519## Production Readiness Concerns
520
521| Concern | Required | Notes |
522| ---------------------- | --------------- | ----------------------------------------------------------------------- |
523| Code linting/analyzers | Yes/No/Existing | {tool preference or "scaffold default"} |
524| Error handling setup | Yes/No/Existing | {pattern: toast/inline/error-page} |
525| Loading indicators | Yes/No/Existing | {pattern: spinner/skeleton/progress} |
526| Docker integration | Yes/No/Existing | {scope: infra-only/full/none} |
527| CI/CD quality gates | Yes/No/Existing | {mutation-score gate (line-coverage diagnostic only), lint enforcement} |
528| Security scanning | Yes/No/Existing | {dependency audit, SAST} |
529
530## Authorization & Access Control
531
532| Role | Can Create | Can Read | Can Update | Can Delete | Notes |
533| ------ | ---------- | -------- | ---------- | ---------- | ------------- |
534| {Role} | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | {scope notes} |
535
536**New permissions needed:** {Yes/No — list if yes}
537**Multi-tenant isolation:** {Yes/No}
538
539## Seed Data Requirements
540
541| Data Type | Description | Owner | Required |
542| ------------------ | ------------------------------------ | ------------ | -------- |
543| Reference data | {lookups, statuses, types} | Application | Yes/No |
544| Configuration data | {default settings} | Application | Yes/No |
545| Test seed data | {entities for integration tests} | Test project | Yes/No |
546| Performance data | {large-volume data for load testing} | Test tooling | Yes/No |
547
548> If no seed data needed: `N/A — no seed data required for this feature.`
549
550## Data Migration
551
552| Change | Type | Backward Compatible | Reversible |
553| --------------------------- | -------------------------------------- | ------------------- | ---------- |
554| {schema change description} | Add field / Remove field / Type change | Yes/No | Yes/No |
555
556> If no schema changes: `N/A — no schema changes required.`
557
558## Domain Context
559
560**Entities:** {Entity1}, {Entity2}
561**Related Features:** {feature doc paths}
562
563## Implementation Notes
564
565> Optional, clearly separated from Business Intent. Implementation hints / source identifiers may appear here and in evidence carriers only — never in the tech-agnostic sections above. If none: `N/A — no implementation hints; rebuild from Business Intent + Requirement IDs.`
566
567## UI Layout
568
569**Design Spec:** {link to the `$design-spec` artifact — or inline UI specs ref — that owns this PBI's screen/component design. REQUIRED for any PBI with UI work. Produce it AFTER inventorying existing UI + connected flows (per `SYNC:existing-ui-research`) so it faithfully matches the current UI system. If backend-only: `N/A — Backend-only change. No UI affected.`}
570
571### Wireframe
572
573{ASCII wireframe using box-drawing characters}
574
575**Layout:** {description with approximate proportions/dimensions}
576
577### Components
578
579- **{ComponentName}** — {behavior description} _(tier: common | domain-shared | page/app)_
580
581> Classify per **Component Hierarchy** in UI wireframe protocol — search existing libs before proposing new components.
582
583### States
584
585| State | Behavior |
586| ------- | -------------------------- |
587| Default | {what user sees initially} |
588| Loading | {spinner/skeleton} |
589| Empty | {empty state message} |
590| Error | {error handling} |
591
592> If backend-only: `## UI Layout` → `N/A — Backend-only change. No UI affected.`
593
594## Validation Summary
595
596**Validated:** {date}
597
598### Confirmed Decisions
599
600- {decision}: {user choice}
601
602### Assumptions Confirmed
603
604- {assumption}: Confirmed/Modified
605
606### Open Items
607
608- [ ] {follow-up items}
609```
610
611---
612
613## Anti-Patterns to Avoid
614
615| Anti-Pattern | Better Approach |
616| ------------------------------ | ----------------------------------- |
617| Refining vague ideas | Return to `$idea` for clarification |
618| Skipping hypothesis validation | Always run Phase 3 for new features |
619| Solution-first thinking | Start with problem, not solution |
620| Generic acceptance criteria | Use GIVEN/WHEN/THEN with specifics |
621| Ignoring domain context | Load project docs if applicable |
622| Too large PBI (XL+) | Break into smaller items |
623| Missing "Out of Scope" | Explicitly list exclusions |
624| Assuming instead of asking | Run validation interview |
625
626---
627
628## Key Rules
629
630- **Every PBI MUST ATTENTION include Dependencies table** — types: `must-before`, `can-parallel`, `blocked-by`, `independent`. Enables `$prioritize` and `$plan` to respect ordering.
631- **No vague dependency descriptions** — Each dependency must specify concrete PBI, service, or feature and WHY relationship exists.
632
633## BA Team Refinement Context (canonical)
634
635> Applies to Writes/Edits under `team-artifacts/pbis/`, `.../stories/`, `team-artifacts/ideas/`. Mirrored for Codex via `SYNC:ba-team-decision-model` / `SYNC:refinement-dor-checklist` in AGENTS.md (do not hand-edit the mirror).
636
637**Decision Model:** 2/3 majority vote (UX BA + Designer BA + Dev BA PIC). Dev BA PIC has technical veto.
638**Disagree-and-Commit:** Once decided, everyone commits. No re-litigating.
639**Grooming Override:** BA team decision changes only if >75% remaining team votes to override.
640
641**Role Scopes:**
642
643- **UX BA:** UI/UX flows, wireframes, interaction AC, user research
644- **Designer BA:** Design feasibility, product thinking, visual design, equal vote
645- **Dev BA PIC:** Technical feasibility review, AI pre-review, DoR gate, grooming presentation
646
647**DoR Gate (ALL must pass before grooming):**
648
649- [ ] User story template (As a... I want... So that...)
650- [ ] AC testable (GIVEN/WHEN/THEN, no vague language)
651- [ ] Wireframes attached (UX BA) + UI design ready (Designer BA)
652- [ ] (UI PBIs) Design spec linked — `$design-spec` artifact or inline UI specs present in `## UI Layout`; backend-only PBIs exempt (`N/A — Backend-only`)
653- [ ] AI pre-review passed (`$artifact-review --type=pbi` or `$pbi-challenge`)
654- [ ] Story points estimated by AI
655- [ ] Dependencies table complete
656
657**Refinement Cadence:** Always one sprint ahead. Weekly meeting (60 min + ~3h async).
658**Skills:** Use `$pbi-challenge` for collaborative review, `$dor-gate` before grooming.
659
660## Definition of Ready (INVEST)
661
662| Criterion | Check |
663| ------------------- | ---------------------------- |
664| **I**ndependent | No blocking dependencies |
665| **N**egotiable | Details can be refined |
666| **V**aluable | Clear user/business value |
667| **E**stimable | Team can estimate (XS-XL) |
668| **S**mall | Single sprint |
669| **T**estable | 3+ GIVEN/WHEN/THEN scenarios |
670| Problem Validated | Hypothesis confirmed |
671| Domain Context | BR/entity context loaded |
672| Stakeholder Aligned | Validation interview done |
673| Prod Readiness | Concerns documented |
674
675---
676
677## Project Integration
678
679For domain PBIs: detect module from `docs/specs/` directory names, extract business rules from `docs/specs/{module}/`, load entity context from feature doc. Target 8-12K tokens for feature context.
680
681---
682
683## Related
684
685- **Role Skill:** `business-analyst` (detailed patterns)
686- **Input:** `$idea` output
687- **Next Step:** `$story`, `$spec [mode=tests]` (Recommended for TDD), `$design-spec`
688- **Prioritization:** `$prioritize`
689
690---
691
692## Next Steps
693
694**MANDATORY IMPORTANT MUST ATTENTION** after completing this skill, use ask the user directly to present these options. NEVER skip because task seems "simple" or "obvious":
695
696- **"$why-review (Recommended)"** — Validate design rationale, alternatives, risk assessment before `$story` or implementation
697- **"$domain-analysis"** — If PBI creates/modifies domain entities, model bounded contexts before writing stories
698- **"$story"** — Break PBI into implementable user stories
699- **"$pbi-mockup"** — Generate HTML mockup from PBI
700- **"$spec [mode=tests]"** — If using TDD approach
701- **"Skip, continue manually"** — user decides
702
703---
704
705> **[IMPORTANT]** Use task tracking to break ALL work into small tasks BEFORE starting. Simple tasks: ask user whether to skip.
706
707> **External Memory:** Complex/lengthy work → write findings to `plans/reports/` — prevents context loss.
708
709> **Evidence Gate:** MANDATORY IMPORTANT MUST ATTENTION — every claim requires `file:line` proof or traced evidence, confidence >80% to act.
710
711<!-- SYNC:ai-mistake-prevention -->
712
713> **AI Mistake Prevention** — Failure modes to avoid on every task:
714>
715> **Re-read files after context changes.** Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
716> **Verify generated content against source evidence.** AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
717> **Check downstream references before deleting or renaming.** Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
718> **Trace the full impact chain after edits.** Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
719> **Verify ALL affected outputs, not just the first.** One green check is not all green checks; validate every output surface the change can affect.
720> **Assume existing values are intentional — ask WHY before changing OR flagging one as a defect.** Before changing or reporting a constant, limit, flag, cutoff, wording, or pattern, read nearby context and history, the CALLER's ordering, and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard.
721> **Surface ambiguity before acting — don't pick silently.** Multiple valid interpretations require an explicit question or stated assumption with risk.
722> **Assert the outcome your system owns, not the intermediate state your infrastructure owns.** When verifying async work, assert the final business state — never the delivery/retry bookkeeping held in shared infrastructure that any co-running process can write. Such a check passes when run alone and flakes the moment anything else shares that infrastructure.
723> **Keep shared guidance role-relevant.** Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
724
725<!-- /SYNC:ai-mistake-prevention -->
726
727<!-- SYNC:ui-system-context -->
728
729> **UI System Context** — For ANY task touching `.ts`, `.html`, `.scss`, or `.css` files:
730>
731> **MUST ATTENTION READ before implementing:**
732>
733> 1. `docs/project-reference/frontend-patterns-reference.md` — component base classes, stores, forms
734> 2. `docs/project-reference/scss-styling-guide.md` — BEM methodology, SCSS variables, mixins, responsive
735> 3. `docs/project-reference/design-system/README.md` — design tokens, component inventory, icons
736>
737> Reference `docs/project-config.json` for project-specific paths.
738
739<!-- /SYNC:ui-system-context
740
741…(truncated)