skills/guardrails/SKILL.md
Code quality verification gates wired into the agent lifecycle. Use this skill whenever writing, modifying, reviewing, or debugging code — including new features, bug fixes, refactors, troubleshooting, CI/CD setup, or project bootstrapping. Also use when the user mentions "quality", "testing strategy", "CI pipeline", "guardrails", "debugging", or asks how to improve code reliability. If you're writing code or trying to understand why code isn't working, this skill applies. Do not use for README/prose-only edits, copywriting, or documentation wording changes unless the user asks for code/build/CI verification or the docs change affects generated/runtime output.
npx skillsauth add adewale/guardrails-skill guardrailsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Verification gates that block the agent from proceeding until checks pass. The agent already knows what linting, testing, type checking, and security scanning are. This skill doesn't re-teach those concepts. Instead, it specifies:
These are the behaviors a coding agent wouldn't exhibit without being told. Everything else — which linter to use, how to structure a unit test — the agent already knows from training and discovers from the project's existing config.
Bundled resources: references/tool-building.md contains the diagnostic tool and
notation catalogs with worked examples. references/language-defaults.md is a lookup
table for tool selection by ecosystem. Read these when directed, not proactively.
Not every check applies to every project. The common base applies everywhere: lint,
format, types, SAST, dependency audit, secrets scan, dead/duplicate code detection,
coverage, unit tests (tool lookup: references/language-defaults.md). Beyond that,
add layers by project type:
Scale up as the project matures. A prototype needs the common base. A production system serving users needs the full suite.
Hooks make guardrails real: they block the agent from proceeding until checks pass. A failing check gives concrete, unambiguous feedback; prose alone competes for attention.
The enforcement system needs two commands in the target project — one fast, one full:
Fast check — Runs in seconds. Fires on every agent stop. Covers: format check, lint, type check, unit tests.
Full suite — Runs before every commit. Covers: everything in the fast check plus integration tests, property tests, secrets scan, dead code detection, duplicate code detection, coverage floor.
Discover, don't impose. Every ecosystem has its own convention: npm scripts
(npm test, npm run test:unit), Makefile targets (make test, make check), Go
commands (go test ./...), pytest (pytest tests/unit), bun scripts, Cargo, etc.
During SessionStart, find what the project already uses by inspecting package.json
scripts, Makefile targets, CI workflow steps, and README instructions. Adapt to the
project's existing runner — don't create a new one alongside it.
If no test runner exists at all, create one using the project's native tooling. Consult
references/language-defaults.md for tool selection. The runner must exit non-zero on
failure.
Fires when the agent boots up. Discovery and baseline before touching anything.
LESSONS_LEARNED.md if it exists. Apply project-specific lessons.script/agent-tools/. Read the directory and description comments to know
what diagnostic tools are available from previous sessions.Defer to existing conventions. When the project has tooling or patterns in place, follow them — even when they conflict with this skill. Do not switch tools or frameworks without explicit user approval.
Fires every time the agent returns control. Prevents declaring success without verification.
Return a decision with evidence, not just a label:
Thrashing circuit breaker. If the fast check fails and the agent has already attempted the same fix twice, it cannot try a third direct fix:
references/tool-building.md). Two failed attempts means the agent's model
of the problem is wrong — re-reading the same code produces the same wrong model.
New information or a different representation breaks the loop.The breaker resets when the user provides new direction. Persist useful diagnostics
to script/agent-tools/.
Completion check. After the fast check passes, check your task list. If planned work items remain and you are not blocked, continue to the next slice — do not hand off. Hand off only when: all items are done, the circuit breaker fired, or context is running low (in which case, commit completed slices and report remaining items).
Work in slices, but finish the job. Verify frequently — a good slice is 1-3 production files plus tests. An agent that writes 15 files then discovers a type error in file 3 has wasted 4-15. But verifying a slice is not completing the task. Do not hand off to the user until all planned work items are done or you are explicitly blocked.
Fires on any git commit, whether from the agent or a human. Same enforcement for both.
fix: prefix or fixing
a reported issue), answer three questions before committing:
When direct fixes fail, the agent needs new information or a different problem
representation. Read references/tool-building.md for the full catalog of
diagnostic tools, notations, and three worked examples.
The circuit breaker (Stop hook) mandates reading this reference after 2 failed attempts. But the best use is proactive: recognize the problem shape during planning and build scaffolding before writing code. Common patterns:
Diagnostic tools often graduate into permanent infrastructure — reproduction scripts become test cases, schema checkers become health checks, dependency mappers feed the integration check. Building a diagnostic tool is not a detour; it's often the most direct path to completing the task.
The agent does not edit its own guardrail configuration. An agent under pressure to make tests pass has an incentive to weaken the tests rather than fix the code. Block the agent from modifying: test scripts, lint/format/type config, CI definitions, pre-commit config, and coverage thresholds. If config needs changing, propose it to the user.
Some operations have blast radius beyond the current code change. Even if the user's request implies them, the agent stops and asks because these are irreversible or affect systems beyond the codebase:
Describe the operation and blast radius, then wait for confirmation.
The agent accumulates project-specific knowledge across sessions. Without a persistent record, each session starts from zero and risks repeating the same mistakes.
Maintain LESSONS_LEARNED.md in the project root. Append an entry when encountering:
a guardrail failure requiring multiple attempts, a non-obvious project convention, a
surprising tool behavior, a deployment gap tests didn't catch, a bug fix retrospective
that revealed a detection gap, a thrashing episode, or a diagnostic tool that proved
useful.
Entry template:
### YYYY-MM-DD — [short title]
**Context:** What task was being performed.
**What happened:** The surprising behavior or failure.
**Resolution:** How it was resolved.
**Rule:** [One-line directive for future sessions to follow.]
Example:
### 2026-02-14 — Custom validation framework
**Context:** Adding input validation to /users endpoint.
**What happened:** Started with express-validator, broke existing tests. Project uses a custom rule-based validator in src/validation/ — not documented anywhere except inline comments in rules.js.
**Resolution:** Rewrote validation using the custom framework (validate() + rules).
**Rule:** Always check src/validation/ for this project's validation pattern before reaching for a third-party library.
Commit to version control. If a lesson reveals a missing guardrail, propose adding one — don't just document the workaround.
Behaviors the agent follows because the reasoning is sound, not because a hook enforces them.
Planning: Define completion criteria — what "done" looks like for this task (files
changed, tests added, routes wired, etc.). Decide testing layers before writing code.
Check problem shape against the proactive table in references/tool-building.md.
Assess security relevance.
Code writing: Format and type-check incrementally. If the same type error reappears after one fix, that signals a structural misunderstanding — switch to a notation rather than continuing to guess.
Handoff / PR: Report what was verified, which layers were skipped and why, security findings, and coverage delta. Do not present work as complete if any hook failed.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.
development
End-to-end Parallels smoke, upgrade, and rerun workflow for OpenClaw across macOS, Windows, and Linux guests. Use when Codex needs to run, rerun, debug, or interpret VM-based install, onboarding, gateway smoke tests, latest-release-to-main upgrade checks, fresh snapshot retests, or optional Discord roundtrip verification under Parallels.