JPeetz/agent-skills / skills/code-quality/clean-pro-review-gates
clean-pro-review-gates
FlaggedUse this skill when reviewing any AI-generated or modified code, tests, docs, or infrastructure before merging. Applies a 5-gate review framework — code quality (15 LLM failure modes), tests, docs, security (OWASP Top 10:2025/CWE Top 25/LLM Top 10), and CI/CD/container/IaC hardening — with each gate mapping violations to published research on how LLMs systematically fail.
| File | Kind | Size |
|---|---|---|
| CHANGELOG.md | markdown | 1.9 KB |
| LICENSE | other | 1.1 KB |
| SKILL.md | skill md | 12.9 KB |
| evals/evals.json | config | 10.4 KB |
| references/code-quality-gate.md | markdown | 5.9 KB |
| references/docs-review-gate.md | markdown | 3.1 KB |
| references/infra-hardening-gate.md | markdown | 5.0 KB |
| references/security-review-gate.md | markdown | 6.8 KB |
| references/security-scan-notes.md | markdown | 1.1 KB |
| references/test-review-gate.md | markdown | 4.3 KB |
references/infra-hardening-gate.md
View on GitHub# Gate 5: Infra Hardening — CI/CD, Containers, and IaC
## Overview
This gate catches the systematic ways LLMs produce insecure infrastructure config. Where other gates stop (clean-code-pro excludes CI/tooling config, security reviews application code), agents write workflow YAML, Dockerfiles, and Terraform constantly — and the training data for these is dominated by tutorial-grade examples whose defaults are permissive on purpose (root containers, `write-all` tokens, `0.0.0.0/0` ingress, mutable `latest` tags). A single finding here — a poisoned pipeline, an exfiltrated `GITHUB_TOKEN` — compromises every artifact the pipeline ships.
## The 18 Imperatives
### CI/CD Workflows
1. **Untrusted context never reaches a shell inline.** Attacker-controlled workflow context — issue titles, PR titles/bodies, branch names — must not appear inside `run:` via `${{ }}` interpolation. Pass through an env var and quote it. (CICD-SEC-4)
2. **`pull_request_target` never executes fork code with secrets.** These triggers run with secret access; checking out and running the PR's head code under them hands secrets to any forker. Use `pull_request` or split privileged steps into a separate workflow. (CICD-SEC-4)
3. **Token permissions are minimal and explicit.** Every workflow declares `permissions:` with only what it needs — start from `contents: read`. Never `write-all`. (CICD-SEC-2)
4. **Third-party actions are pinned to a full commit SHA.** A moving tag (`@v4`, `@main`) is a supply-chain handle anyone who compromises the action repo can yank. Pin SHA, comment version. (CICD-SEC-3)
5. **Secrets stay out of logs, artifacts, and forks.** No `echo` of secrets, no secrets in artifact uploads or build args, no secrets available to fork-triggerable workflows. Prefer OIDC federation over long-lived keys. (CICD-SEC-6)
6. **Artifacts, caches, and outputs from untrusted runs are untrusted input.** A `workflow_run` that downloads an artifact from fork code and executes it re-opens imperative 2. Validate provenance. (CICD-SEC-9)
7. **Self-hosted runners never serve public-repo or fork workloads** without isolation — a fork PR on a self-hosted runner is remote code execution on your infrastructure. (CICD-SEC-5)
### Containers
8. **Containers run as non-root.** A `USER` directive with a non-zero UID in every final image. No `privileged: true`, no docker-socket mount, no `--cap-add` beyond need. (CIS Docker Benchmark)
9. **No secrets in images — ever.** Not in `ENV`, not in `ARG`, not in a `COPY`'d file deleted "later" — every layer is preserved. Use BuildKit secret mounts or runtime injection. (CWE-798 applied to layers)
10. **Base images are pinned and minimal.** Digest-pinned (`@sha256:...`) or exact-version base; never bare `latest`. Multi-stage builds keep compilers and source out of the runtime image. (CICD-SEC-3)
11. **Nothing is piped from the network into a shell during build.** `curl | sh` in a Dockerfile is third-party code execution baked into every build. Download, verify checksum, then run.
### IaC and Cloud
12. **No wildcard IAM.** `Action: "*"`, `Resource: "*"`, or both is a finding. Grant specific actions on specific resources. (CIS; least privilege)
13. **No open ingress to admin or data ports.** `0.0.0.0/0` (or `::/0`) to SSH/RDP/databases/k8s API is exposed-to-the-internet. Allow-list sources or use a bastion/VPN.
14. **Storage and state are private and encrypted.** Buckets block public access unless serving a public website. Terraform state lives in an encrypted, access-controlled backend; never committed.
15. **Modules and providers are pinned and verified.** Version-pinned module sources from verified namespaces. Kubernetes workloads declare `securityContext` (`runAsNonRoot`, no privilege escalation) and resource limits.
### AI-Specific Infra Guardrails
16. **Never weaken the pipeline to make it green.** No `continue-on-error: true` on a failing security step, no `|| true`, no deleting the scan job, no `--no-verify`. (The infra twin of security imperative 26)
17. **Demo config is not production config.** The model emits the tutorial default — root user, `write-all`, open ingress, `latest`. Re-derive each privilege from actual workload need.
18. **Verify every action, image, and module name against its registry** before use — existence, publisher, popularity. The package-hallucination mechanism applies identically to Actions marketplace, Docker Hub, and module registries.
## Self-Check (Gate 5)
1. Walk imperatives 1–18 against your diff. Fix or flag every violation.
2. Any `${{ }}` of attacker-controlled context inside `run:`? Any `pull_request_target` that touches fork code?
3. Does every workflow declare minimal `permissions:`? Is every third-party action SHA-pinned?
4. Any secret in a layer, build arg, env literal, or log path? Any `curl | sh` in a build?
5. Final image non-root and minimal? Base image pinned?
6. Any wildcard IAM, `0.0.0.0/0` to an admin port, public bucket, or committed state file?
7. Did you loosen any permission, disable any check, or add `continue-on-error` to make something pass? If yes, revert and solve properly.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |