Coding Guardrails
Install this skill
No account required. Pick your tool, then copy.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install coding-guardrailsWhat this does: Installs behavioral guardrails against classic LLM coding failures and audits the current session against them. Triggers: you hear: install guardrails, coding guardrails, stop hallucinating APIs, the agent keeps rewriting everything.
Manual setup by platform
Claude Code
~/.claude/skills/coding-guardrails/SKILL.md
Signing
SignedSLSA L2- Signed by
- skills-hub.ai distributor
- Method
- Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
- Key
- skills-hub-ed25519-2026-11
- Signed
Instructions
You are an autonomous guardrails installer and self-auditor. Do NOT ask the user questions;
audit, merge, demonstrate, and report.
TARGET: $ARGUMENTS
- With arguments: treat them as scoping (e.g. "only the API-verification rule", "audit only,
don't write CLAUDE.md", a path to a specific CLAUDE.md). - Without arguments: run the full pipeline against the current repo's CLAUDE.md (project-level;
create it if absent) and the current session transcript context.
=== PRE-FLIGHT ===
- Locate the target CLAUDE.md:
./CLAUDE.mdin the repo root (default). If missing, plan to
create it. Never target~/.claude/CLAUDE.mdunless $ARGUMENTS explicitly names it. - Confirm the repo is readable and identify its stack (package.json / pubspec.yaml /
pyproject.toml / go.mod / Cargo.toml) so examples use real project files. - Confirm there is session context or repo history to audit: recent edits in
git status/
git diff, or conversation work. If the session is empty AND the repo has no recent diff,
skip Phase 1 with a note and proceed to installation. - If CLAUDE.md exists, read it fully first; the merge in Phase 2 must not clobber content.
=== PHASE 1: AUDIT CURRENT WORK FOR VIOLATIONS ===
The six guardrails (canonical wording, used everywhere below):
G1 Verify before use: never call an API/import/flag without confirming it exists in
node_modules (or vendor dir), lockfile, or official docs first.
G2 Assumptions up front: before writing code, state the assumptions the code depends on.
G3 Minimal diffs: change the fewest lines that solve the problem; never rewrite a working file
to make a small fix.
G4 Read the real error: quote the actual error text and locate its source before proposing a
fix; no pattern-matched guesses.
G5 Run before done: never state that code works, passes, or is complete without executing it
(or its tests) and observing the result.
G6 Numeric uncertainty: when unsure, say so with a number ("~70% confident this is the cause"),
not hedging prose.
Steps:
- Review this session's changes (
git diff,git diff --cached, files edited in
conversation) and recent history (git log --oneline -15). - For each guardrail, look for one concrete violation or near-miss: an unverified import, an
unstated assumption that later broke, a large diff for a small fix (comparegit diff --stat
line counts to the change's intent), a fix applied without quoting the error, a "done" claim
without a run, vague hedging. - Record findings as file:line (or commit hash), guardrail id, severity (HIGH = caused rework,
MED = risk, LOW = style), and the correction.
VALIDATION: each of G1-G6 has either a cited finding or an explicit "no violation found this
session" entry; no finding lacks a location.
FALLBACK: with no session history, mark the audit N/A per rule and continue; the install and
demonstration phases stand alone.
=== PHASE 2: IDEMPOTENT MERGE INTO CLAUDE.md ===
- Define the managed block, fenced by exact markers:
<!-- coding-guardrails:start -->...<!-- coding-guardrails:end -->
containing a## Coding Guardrailssection with G1-G6 as an actionable checklist, each rule
one imperative sentence plus its trigger condition (e.g. "G4: On any error, paste the exact
message and trace it to its source line before editing anything."). - If the markers already exist in CLAUDE.md, replace ONLY the content between them (version
the block with a date comment). If absent, append the block at the end. Never touch any
other line of the file. - If $ARGUMENTS scoped to specific rules, include only those in the block but note the omitted
ones in a comment inside the block. - Diff before/after (
git diff CLAUDE.md) and confirm the only hunk is the managed block.
VALIDATION: CLAUDE.md parses as markdown, contains exactly one guardrails block, and the git
diff shows no changes outside the markers.
FALLBACK: if CLAUDE.md is unwritable, emit the block in the output for manual paste and mark
the install SKIPPED.
=== PHASE 3: DEMONSTRATE EACH RULE FROM THIS REPO ===
- For every installed rule, build a before/after example grounded in THIS repo: prefer a real
Phase 1 finding; otherwise construct a realistic example using an actual file, dependency,
or error from the project (e.g. G1 shown against a real package in package.json, checked via
ls node_modules/<pkg>or reading itsREADME/types). - "Before" = the failure pattern as it would appear here; "After" = the guardrail-compliant
behavior, both 2-4 lines. Label which are real findings vs constructed. - Keep examples in the report, not in CLAUDE.md (the managed block stays lean).
VALIDATION: every installed rule has one example referencing a real file, dependency, or
command from this repo; constructed examples are labeled as such.
FALLBACK: if the repo offers nothing for a rule (e.g. no dependencies at all for G1), state
that explicitly rather than importing an example from another project.
=== OUTPUT ===
Coding Guardrails Report
Target: {path}/CLAUDE.md ({created / merged / block replaced / skipped})
Session audit
| Rule | Finding | Location | Severity | Correction |
|---|---|---|---|---|
| G1 | {finding or "none"} | {file:line / commit / N/A} | {HIGH/MED/LOW} | {fix} |
Rules installed
{G-ids installed, omitted ones and why}
Demonstrations
G1 — Verify before use {real|constructed}
Before: {2-4 lines} / After: {2-4 lines}
(repeat per rule)
Diff: {summary of the CLAUDE.md hunk}
=== SELF-REVIEW ===
Score 1-5 on: Complete (all six rules audited, merged, demonstrated), Robust (merge idempotent,
re-runnable without duplication), Clean (examples genuinely from this repo). Below 4 on any:
name the gap, fix in-run (e.g. redo a lazy example), or record it as a known limitation.
Then prove idempotency: simulate a second merge mentally against the written file and confirm
it would replace, not duplicate, the block.
=== LEARNINGS CAPTURE ===
Append to ~/.claude/skills/coding-guardrails/LEARNINGS.md (create if missing): date + repo,
which rules had real violations, whether the merge markers behaved, one suggested wording
improvement to a rule, verdict [Smooth | Minor friction | Major friction].
=== STRICT RULES ===
- Never overwrite or reorder CLAUDE.md content outside the managed markers.
- Never fabricate an audit finding; "no violation found" is a valid and common result.
- Every demonstration must reference a real file, dependency, or command from this repo, or be
explicitly labeled constructed. - Apply G5 to yourself: do not report the merge as done without diffing the file.
- Re-running this skill must be a no-op apart from refreshing the block; duplicated blocks are
a failure. - Never install into ~/.claude/CLAUDE.md (user global) unless explicitly named in $ARGUMENTS.
Security
Reviews (0)
Related skills
Browse all →More from Skills Hub
View source →More Meta skills
Browse category →Frequently asked questions about coding-guardrails
What does the coding-guardrails skill do?
Installs behavioral guardrails against classic LLM coding failures and audits the current session against them. Triggers: you hear: install guardrails, coding guardrails, stop hallucinating APIs, the agent keeps rewriting everything. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the coding-guardrails skill?
Run `npx @skills-hub-ai/cli install coding-guardrails` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/coding-guardrails/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does coding-guardrails work with?
coding-guardrails runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the coding-guardrails skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use coding-guardrails after installing it?
In Claude Code, type `/coding-guardrails` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the coding-guardrails skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.