원클릭으로
policy-runner
Run policy-as-code checks (e.g., OPA/Conftest) based on the policy_plan. Use in Flow 2 and Flow 4.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Run policy-as-code checks (e.g., OPA/Conftest) based on the policy_plan. Use in Flow 2 and Flow 4.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Run the relevant tests for the current change and summarize results. Use in Flow 3 (Build) and optionally in Flow 5 (Gate).
Run linters/formatters on changed files and apply safe, mechanical fixes. Use in Flow 3 and Flow 4.
Open questions register. Use for: QID generation, OQ-SIG-001 format IDs, append questions, open_questions.md. Generate sequential QIDs, append questions with context. Use in clarifier when registering open questions instead of guessing. Invoke via bash .claude/scripts/demoswarm.sh openq next-id|append.
Grep/wc replacement for .runs artifacts. Use for: count, extract, Machine Summary, receipt reading, marker counts. Null-safe counting (REQ/NFR/QID/RSK markers), YAML block parsing, BDD scenario counting. Deterministic read-only - no judgment. Use when cleanup agents need mechanical counts/extraction. Invoke via bash .claude/scripts/demoswarm.sh.
Update index.json status. Use for: upsert index.json, update status/last_flow/updated_at. Deterministic writes - stable diffs, no creation. Use only in run-prep and *-cleanup agents. Invoke via bash .claude/scripts/demoswarm.sh index upsert-status.
Publish gate secrets scanning. Use for: safe_to_publish, scan for secrets, redact in-place. Determines publish gate status. Scan files for secrets (locations only - NEVER prints secret content). GitHub tokens, AWS keys, private keys, bearer tokens. Use ONLY in secrets-sanitizer. Invoke via bash .claude/scripts/demoswarm.sh secrets scan|redact.
| name | policy-runner |
| description | Run policy-as-code checks (e.g., OPA/Conftest) based on the policy_plan. Use in Flow 2 and Flow 4. |
| allowed-tools | Bash, Read |
Run policy-as-code checks against plan artifacts, code, and configurations. This skill executes OPA/Conftest/Rego policies and produces structured evidence for compliance verification.
Policy-as-code transforms governance rules from documentation into executable checks. Instead of "the security team reviews PRs," you get "the policy runner verifies authentication requirements are met."
What this skill does:
policy_plan.mdWhat this skill does not do:
| Flow | Purpose |
|---|---|
| Flow 2 (Plan) | Validate contracts/ADR against architectural policies |
| Flow 4 (Review) | Re-check policies after implementation changes |
| Flow 5 (Gate) | Final policy verification before merge decision |
The skill is typically invoked by:
policy-analyst agent (for compliance mapping)OPA is a general-purpose policy engine. Policies are written in Rego, a declarative query language.
# example: require auth on all endpoints
package api.security
default allow = false
allow {
input.endpoint.auth_required == true
}
deny[msg] {
not input.endpoint.auth_required
msg := sprintf("Endpoint %v requires authentication", [input.endpoint.path])
}
Conftest is a tool for testing structured data (YAML, JSON, HCL) against OPA policies. It's commonly used for:
# Run conftest against API contracts
conftest test api_contracts.yaml -p policies/api/
The policy language for OPA. Key concepts:
Always invoke via the shim when available:
bash .claude/scripts/demoswarm.sh policy <command> [options]
If the shim doesn't support policy commands, fall back to direct tool invocation:
conftest test <path> -p <policy-dir> --output json
opa eval --data <policy.rego> --input <target.json> "data.policy.deny"
policy_runner_output.log.policy_runner_summary.md.policy_plan.md)The policy_plan.md file defines which policies to run. Located at:
.runs/<run-id>/plan/policy_plan.md (run-specific)policies/policy_plan.md (repo default)Format:
# Policy Plan
## Active Policies
| Policy | Target | Command | Required |
| ------------------ | ------------------ | ------------------------------------------ | -------- |
| api-security | api_contracts.yaml | conftest test {target} -p policies/api/ | yes |
| data-retention | schema.md | opa eval -d policies/data/retention.rego | no |
| naming-conventions | \*.yaml | conftest test {target} -p policies/naming/ | yes |
## Policy Roots
- policies/
- .policies/
policies/
api/
security.rego # Auth requirements
versioning.rego # API versioning rules
data/
retention.rego # Data retention rules
pii.rego # PII handling rules
naming/
conventions.rego # Naming standards
conftest.toml # Conftest configuration
conftest.toml)# policies/conftest.toml
policy = ["policies/"]
output = "json"
# If policy_plan.md exists, run all configured checks
bash .claude/scripts/demoswarm.sh policy run \
--plan ".runs/feat-auth/plan/policy_plan.md" \
--output ".runs/feat-auth/plan/policy_runner_output.log"
# Run a single named policy
conftest test .runs/feat-auth/plan/api_contracts.yaml \
-p policies/api/ \
--output json
# Verify policies are configured
bash .claude/scripts/demoswarm.sh policy check-setup
# stdout: CONFIGURED | NOT_CONFIGURED | PARTIAL
# Validate API contracts against security policies
conftest test .runs/feat-auth/plan/api_contracts.yaml \
-p policies/api/security.rego \
--output json
# Example output (pass):
# []
# Example output (fail):
# [
# {
# "filename": "api_contracts.yaml",
# "failures": [
# {"msg": "Endpoint /users requires authentication"}
# ]
# }
# ]
# Validate data models against retention policies
opa eval \
--data policies/data/retention.rego \
--input .runs/feat-auth/plan/schema.json \
"data.retention.deny" \
--format pretty
# Example output (pass):
# []
# Example output (fail):
# [
# "Field 'email' in User model must have retention period defined"
# ]
# Validate k8s manifests (if applicable)
conftest test k8s/*.yaml \
-p policies/k8s/ \
--output json
# Check ADR against architectural policies
conftest test .runs/feat-auth/plan/adr.md \
-p policies/architecture/ \
--parser yaml \
--output json
Read policy_plan.md (if it exists) to discover which policies and paths to evaluate.
For each configured policy entry:
conftest test <path> or opa eval ...), run it.Capture output:
policy_runner_output.log.policy_runner_summary.md summarizing checks run, passed, failed, and planned-only policies.Do not modify policy files or code.
policy_runner_output.logRaw output from all policy executions:
=== Policy: api-security ===
Command: conftest test api_contracts.yaml -p policies/api/
Exit code: 0
Output:
[]
=== Policy: data-retention ===
Command: opa eval -d policies/data/retention.rego ...
Exit code: 1
Output:
["Field 'email' in User model must have retention period defined"]
policy_runner_summary.md# Policy Runner Summary
## Execution Context
- Run ID: feat-auth
- Timestamp: 2025-12-12T10:30:00Z
- Policy Plan: .runs/feat-auth/plan/policy_plan.md
## Results
| Policy | Target | Status | Violations |
| ------------------ | ------------------ | ------ | ---------- |
| api-security | api_contracts.yaml | PASS | 0 |
| data-retention | schema.md | FAIL | 1 |
| naming-conventions | \*.yaml | PASS | 0 |
## Violations Detail
### data-retention (FAIL)
- Target: schema.md
- Violation: Field 'email' in User model must have retention period defined
- Policy file: policies/data/retention.rego:L42
## Planned Only (Not Executed)
- pii-classification: No auto-execute command configured
## Summary
- Total policies: 4
- Executed: 3
- Passed: 2
- Failed: 1
- Planned only: 1
Symptom: "No policy checks wired for this change"
Resolution:
policies/ directory with Rego filespolicy_plan.md with policy-to-target mappingsSymptom: conftest: command not found or opa: command not found
Resolution:
# Install conftest
brew install conftest # macOS
# or download from: https://github.com/open-policy-agent/conftest/releases
# Install OPA
brew install opa # macOS
# or download from: https://www.openpolicyagent.org/docs/latest/#running-opa
Symptom: Rego syntax errors in output
Resolution:
opa check policies/*.rego to validate syntaxSymptom: error: file not found: api_contracts.yaml
Resolution:
policy_plan.md references the correct locationSymptom: Unexpected failures or passes
Resolution:
opa eval --data policy.rego --input test.json "data.policy.deny"opa eval ... --explain fullThe policy-analyst agent uses policy-runner output to:
Flow:
policy-runner (execute)
|
v
policy_runner_summary.md
|
v
policy-analyst (interpret)
|
v
policy_analysis.md (compliance register)
The skill executes; the agent interprets. Keep these concerns separate.
# policies/api/security.rego
package api.security
deny[msg] {
endpoint := input.paths[path][method]
not endpoint.security
msg := sprintf("Endpoint %v %v must have security defined", [upper(method), path])
}
# policies/api/versioning.rego
package api.versioning
deny[msg] {
not input.info.version
msg := "API must have version defined in info block"
}
deny[msg] {
path := input.paths[p]
not startswith(p, "/v")
msg := sprintf("Path %v must be versioned (e.g., /v1/...)", [p])
}
# policies/data/pii.rego
package data.pii
pii_fields := ["email", "phone", "ssn", "address"]
deny[msg] {
field := input.models[model].fields[f]
field.name == pii_fields[_]
not field.encrypted
msg := sprintf("PII field %v.%v must be encrypted", [model, field.name])
}
# policies/naming/conventions.rego
package naming
deny[msg] {
endpoint := input.paths[path]
not regex.match(`^/[a-z][a-z0-9-]*(/[a-z][a-z0-9-]*)*$`, path)
msg := sprintf("Path %v must use kebab-case", [path])
}
# Run with verbose output
conftest test target.yaml -p policies/ --trace
# OPA with full explanation
opa eval --data policy.rego --input target.json "data.policy.deny" --explain full
# Create test input
echo '{"endpoint": {"path": "/users", "auth_required": false}}' > test_input.json
# Run policy against test input
opa eval --data policies/api/security.rego --input test_input.json "data.api.security.deny"
# Check all policies for syntax errors
opa check policies/**/*.rego
# Format Rego files
opa fmt -w policies/
When using policy-runner in agents:
policy_runner_output.log for audit trail0 = pass, non-zero = fail or errorExample pattern in agent code:
# Check if policies are configured
if [[ -f ".runs/${RUN_ID}/plan/policy_plan.md" ]]; then
# Run policies
conftest test .runs/${RUN_ID}/plan/api_contracts.yaml \
-p policies/api/ \
--output json > .runs/${RUN_ID}/plan/policy_runner_output.log 2>&1
EXIT_CODE=$?
if [[ $EXIT_CODE -eq 0 ]]; then
echo "PASS"
else
echo "FAIL"
fi
else
echo "No policies configured for this run"
fi
# macOS
brew install conftest
# Linux
wget https://github.com/open-policy-agent/conftest/releases/download/v0.48.0/conftest_0.48.0_Linux_x86_64.tar.gz
tar xzf conftest_0.48.0_Linux_x86_64.tar.gz
sudo mv conftest /usr/local/bin/
# Windows (scoop)
scoop install conftest
# macOS
brew install opa
# Linux
curl -L -o opa https://openpolicyagent.org/downloads/latest/opa_linux_amd64
chmod +x opa
sudo mv opa /usr/local/bin/
# Windows (scoop)
scoop install opa
conftest --version
opa version