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>-NNNin<module-slug>to refine check logic and exceptions." - "Add a global policy rule to enforce
<cross-project-constraint>." - "Update global rule
RP-GLOBAL-NNNto tighten evidence expectation."
- Locate
<docs-dir>/review/policies/global-policy.mdormodule-<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-NNNorRP-<MODULE>-NNN) for add mode, or keep the existing ID for modify mode. - Write or merge rule YAML under
## Rulesand update- Updated: YYYY-MM-DD. - When applicable, update
POLICY_INDEX.mdmetadata 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
globalormoduleif not explicit. - Route to
global-policy.mdfor global scope andmodule-<slug>.mdfor module scope. - If file missing, create it using the appropriate template.
- Resolve
-
Run AskTheUser interview
- Collect:
- rule scope (
globalormodule) - 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
- rule scope (
- Offer defaults when user is unsure:
severity: highsource: user-specifiedstatus: activeallowed_exceptions: none
- If
automationis added/changed/removed, ask:- "Should I update
POLICY_INDEX.md->Automated Checksfor this rule?" - Recommend
Yeswhen automation exists or changed. - Recommend
Yeswhen automation was removed (to remove stale row). - Recommend
Noonly when user explicitly wants to defer index updates.
- "Should I update
- Explain purpose before asking:
Automated Checksis the governance index of machine-checkable rules used for review traceability and deterministic enforcement visibility.
- Collect:
-
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
- global:
-
Write contract-compliant rule
- Required fields:
id,title,scope,severity,intent,check_logic,evidence_expectation,allowed_exceptions,source,status
- Optional fields:
related_adrautomationmetadata
- Scope rules:
global-policy.mdmust usescope: globalmodule-<slug>.mdmust usescope: module:<slug>
- Required fields:
-
Update
POLICY_INDEX.mdwhen applicable- Update only if
<docs-dir>/review/policies/POLICY_INDEX.mdexists. - If missing, do not create it in this skill; report warning and remediation.
- Always update after policy file edits:
- Updated: YYYY-MM-DD
- Update
## Needs Decisionwhen rule status isneeds-decision. - Update
## Automated Checksonly 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.
- Update only if
-
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.
- Validate against checklist in
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.mdwhen applicable. - Keep policy language testable and evidence-oriented.
- If user input conflicts with ADR constraints, mark
status: needs-decisionand 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 removeAutomated Checksrow by Rule ID. - If
No, leaveAutomated Checksunchanged and report user override. - If
POLICY_INDEX.mdis missing, report warning and skip index update.