Review Policy Rule Builder
Adds a new rule or updates an existing rule in global or module policy files under <docs-dir>/review/policies/.
Read references/policy-rule-checklist.md before editing any policy file.
Quick start
Example user prompts:
- "Add a new high-severity rule for
<module-slug> to enforce <constraint>."
- "Update rule
RP-<MODULE>-NNN in <module-slug> to refine check logic and exceptions."
- "Add a global policy rule to enforce
<cross-project-constraint>."
- "Update global rule
RP-GLOBAL-NNN to tighten evidence expectation."
- Locate
<docs-dir>/review/policies/global-policy.md or module-<slug>.md.
- Ask for missing fields: scope, domain/module, intent, severity, check logic, evidence expectation, exceptions, optional automation.
- Create a new rule ID (
RP-GLOBAL-NNN or RP-<MODULE>-NNN) for add mode, or keep the existing ID for modify mode.
- Write or merge rule YAML under
## Rules and update - Updated: YYYY-MM-DD.
- When applicable, update
POLICY_INDEX.md metadata tables.
- Validate required schema fields and report result.
Workflow
Locate target policy file
- Resolve
<docs-dir> from repository contract docs.
- Ask whether the target is
global or module if not explicit.
- Route to
global-policy.md for global scope and module-<slug>.md for module scope.
- If file missing, create it using the appropriate template.
Run AskTheUser interview
- Collect:
- rule scope (
global or module)
- policy domain/module
- policy description (title + intent)
- code sample(s) from repo or user snippet
- additional metadata (severity, evidence expectation, exceptions, source, ADR, status)
- for global scope: cross-project impact and why module-local scope is insufficient
- Offer defaults when user is unsure:
severity: high
source: user-specified
status: active
allowed_exceptions: none
- If
automation is added/changed/removed, ask:
- "Should I update
POLICY_INDEX.md -> Automated Checks for this rule?"
- Recommend
Yes when automation exists or changed.
- Recommend
Yes when automation was removed (to remove stale row).
- Recommend
No only when user explicitly wants to defer index updates.
- Explain purpose before asking:
Automated Checks is the governance index of machine-checkable rules used for review traceability and deterministic enforcement visibility.
Decide operation mode
- Add: no matching rule ID/intent found.
- Modify: user names rule ID, or intent clearly maps to an existing rule.
- Preserve stable IDs when intent is unchanged.
- If intent changes materially, add a new ID and deprecate old rule with rationale.
- ID family:
- global:
RP-GLOBAL-NNN
- module:
RP-<MODULE>-NNN
Write contract-compliant rule
- Required fields:
id, title, scope, severity, intent, check_logic, evidence_expectation, allowed_exceptions, source, status
- Optional fields:
related_adr
automation metadata
- Scope rules:
global-policy.md must use scope: global
module-<slug>.md must use scope: module:<slug>
Update POLICY_INDEX.md when applicable
- Update only if
<docs-dir>/review/policies/POLICY_INDEX.md exists.
- If missing, do not create it in this skill; report warning and remediation.
- Always update after policy file edits:
- Update
## Needs Decision when rule status is needs-decision.
- Update
## Automated Checks only when automation changed and based on AskTheUser decision:
Yes: upsert/remove row keyed by rule ID.
No: leave unchanged and report explicit user override.
- If a global rule is added/deprecated/needs-decision, ensure index reflects it in relevant sections.
Validate and report
- Validate against checklist in
references/policy-rule-checklist.md.
- If available, run
python skills/review-policy-rule-builder/scripts/validate_policy_rule.py <policy-file>.
- Report created/updated rule IDs, file path, and any unresolved ambiguity.
Guardrails
- Never silently delete existing rules.
- If replacing policy intent, mark prior rule
status: deprecated.
- Keep edits minimal and localized to target policy file plus
POLICY_INDEX.md when applicable.
- Keep policy language testable and evidence-oriented.
- If user input conflicts with ADR constraints, mark
status: needs-decision and note conflict.
AskTheUser prompt snippet
Use this prompt when automation metadata was added, changed, or removed:
"This rule has automation metadata changes. Should I update POLICY_INDEX.md -> Automated Checks for traceability of machine-enforced rules?"
Options:
Yes (Recommended) - keep index aligned with deterministic checks.
No - keep policy rule change only and defer index update.
Decision handling:
- If
Yes, upsert or remove Automated Checks row by Rule ID.
- If
No, leave Automated Checks unchanged and report user override.
- If
POLICY_INDEX.md is missing, report warning and skip index update.
1---2name: review-policy-rule-builder3description: Creates or updates `agentic-review` policy rules in `<docs-dir>/review/policies/global-policy.md` and `module-<slug>.md` using a structured interview and contract-safe merge behavior. Use when the user asks to add, modify, refine, deprecate, or clarify global or module review policy rules, or mentions rule severity, intent, evidence, automation metadata, or policy IDs like `RP-GLOBAL-###` and `RP-<MODULE>-###`.4---56# Review Policy Rule Builder78Adds a new rule or updates an existing rule in global or module policy files under `<docs-dir>/review/policies/`.910Read [references/policy-rule-checklist.md](references/policy-rule-checklist.md) before editing any policy file.1112## Quick start1314Example user prompts:15- "Add a new high-severity rule for `<module-slug>` to enforce `<constraint>`."16- "Update rule `RP-<MODULE>-NNN` in `<module-slug>` to refine check logic and exceptions."17- "Add a global policy rule to enforce `<cross-project-constraint>`."18- "Update global rule `RP-GLOBAL-NNN` to tighten evidence expectation."19201. Locate `<docs-dir>/review/policies/global-policy.md` or `module-<slug>.md`.212. Ask for missing fields: scope, domain/module, intent, severity, check logic, evidence expectation, exceptions, optional automation.223. Create a new rule ID (`RP-GLOBAL-NNN` or `RP-<MODULE>-NNN`) for add mode, or keep the existing ID for modify mode.234. Write or merge rule YAML under `## Rules` and update `- Updated: YYYY-MM-DD`.245. When applicable, update `POLICY_INDEX.md` metadata tables.256. Validate required schema fields and report result.2627## Workflow28291. **Locate target policy file**30 - Resolve `<docs-dir>` from repository contract docs.31 - Ask whether the target is `global` or `module` if not explicit.32 - Route to `global-policy.md` for global scope and `module-<slug>.md` for module scope.33 - If file missing, create it using the appropriate template.34352. **Run AskTheUser interview**36 - Collect:37 - rule scope (`global` or `module`)38 - policy domain/module39 - policy description (title + intent)40 - code sample(s) from repo or user snippet41 - additional metadata (severity, evidence expectation, exceptions, source, ADR, status)42 - for global scope: cross-project impact and why module-local scope is insufficient43 - Offer defaults when user is unsure:44 - `severity: high`45 - `source: user-specified`46 - `status: active`47 - `allowed_exceptions: none`48 - If `automation` is added/changed/removed, ask:49 - "Should I update `POLICY_INDEX.md` -> `Automated Checks` for this rule?"50 - Recommend `Yes` when automation exists or changed.51 - Recommend `Yes` when automation was removed (to remove stale row).52 - Recommend `No` only when user explicitly wants to defer index updates.53 - Explain purpose before asking: `Automated Checks` is the governance index of machine-checkable rules used for review traceability and deterministic enforcement visibility.54553. **Decide operation mode**56 - **Add**: no matching rule ID/intent found.57 - **Modify**: user names rule ID, or intent clearly maps to an existing rule.58 - Preserve stable IDs when intent is unchanged.59 - If intent changes materially, add a new ID and deprecate old rule with rationale.60 - ID family:61 - global: `RP-GLOBAL-NNN`62 - module: `RP-<MODULE>-NNN`63644. **Write contract-compliant rule**65 - Required fields:66 - `id`, `title`, `scope`, `severity`, `intent`, `check_logic`, `evidence_expectation`, `allowed_exceptions`, `source`, `status`67 - Optional fields:68 - `related_adr`69 - `automation` metadata70 - Scope rules:71 - `global-policy.md` must use `scope: global`72 - `module-<slug>.md` must use `scope: module:<slug>`73745. **Update `POLICY_INDEX.md` when applicable**75 - Update only if `<docs-dir>/review/policies/POLICY_INDEX.md` exists.76 - If missing, do not create it in this skill; report warning and remediation.77 - Always update after policy file edits:78 - `- Updated: YYYY-MM-DD`79 - Update `## Needs Decision` when rule status is `needs-decision`.80 - Update `## Automated Checks` only when automation changed and based on AskTheUser decision:81 - `Yes`: upsert/remove row keyed by rule ID.82 - `No`: leave unchanged and report explicit user override.83 - If a global rule is added/deprecated/needs-decision, ensure index reflects it in relevant sections.84856. **Validate and report**86 - Validate against checklist in `references/policy-rule-checklist.md`.87 - If available, run `python skills/review-policy-rule-builder/scripts/validate_policy_rule.py <policy-file>`.88 - Report created/updated rule IDs, file path, and any unresolved ambiguity.8990## Guardrails9192- Never silently delete existing rules.93- If replacing policy intent, mark prior rule `status: deprecated`.94- Keep edits minimal and localized to target policy file plus `POLICY_INDEX.md` when applicable.95- Keep policy language testable and evidence-oriented.96- If user input conflicts with ADR constraints, mark `status: needs-decision` and note conflict.9798## AskTheUser prompt snippet99100Use this prompt when `automation` metadata was added, changed, or removed:101102"This rule has automation metadata changes. Should I update `POLICY_INDEX.md` -> `Automated Checks` for traceability of machine-enforced rules?"103104Options:105- `Yes (Recommended)` - keep index aligned with deterministic checks.106- `No` - keep policy rule change only and defer index update.107108Decision handling:109- If `Yes`, upsert or remove `Automated Checks` row by Rule ID.110- If `No`, leave `Automated Checks` unchanged and report user override.111- If `POLICY_INDEX.md` is missing, report warning and skip index update.