---
name: 'BUSINESS-RULES: Check'
description: Focused validation against the business-rules catalog (aggregate / rule / branch / PR / working tree).
category: Business Rules
tags: [business-rules, validation, ad-hoc]
---

Focused, fast validation against the business-rules catalog. Four modes:

- **Aggregate**: list rules for a specific aggregate.
- **Rule ID**: detailed status of one rule.
- **Branch / PR**: rules potentially impacted by changes in a branch or pull request.
- **Working tree**: rules potentially impacted by uncommitted local changes.

---

**Modes**

```bash
# Mode 1 — aggregate
pnpm br:check production-planning/production-order-position-event

# Mode 2 — rule
pnpm br:check BR-PROD-HEADER-001

# Mode 3a — branch (diff vs main)
pnpm br:check --branch feature/cancel-event

# Mode 3b — pull request (uses gh CLI)
pnpm br:check --pr 123

# Mode 4 — working tree (uncommitted)
pnpm br:check
```

---

**When to use each mode**

- **Aggregate** — before starting work on an aggregate, to know what rules govern it.
- **Rule ID** — when investigating "what does this rule say exactly?" or when the audit reports a finding for a specific rule.
- **Branch / PR** — before requesting code review, to verify whether the change touches active rules and confirm the proposal's `Business rules affected` section is accurate.
- **Working tree** — during development, as a quick sanity check that the local edits match the rule expectations.

**Output**

- Aggregate / rule modes: list the rules with id, title, state, severity, type, and file path.
- Branch / PR / working modes: list the modified files and the rules whose `paths` glob matches; suggest reviewing them and updating the proposal if rules change.

**Guardrails**

- Read-only. The script never modifies the catalog.
- Branch and PR modes require git (and `gh` for `--pr`). If `gh` isn't authenticated, the script aborts with a clear message.
- For PR mode the resolution is repository-local (`gh pr view --json files`); doesn't fetch remotely.
- A modified file that doesn't match any rule's `paths` is fine — not all code is rule-governed. The check just reports relevance, doesn't enforce.
