skill-guard-governance
Skill4 starsChanged 7 months agoMITView on GitHub
The canonical skill for designing, implementing, testing, and registering a new Guard in defense-in-depth.
In this repository16 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- .agents/skills/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skill-ai-dspy-validatorSkill
- Bootstrap AgentSkill
- CreatorSkill
- Deep ResearchSkill
- skill-devops-github-actionsSkill
- skill-impact-predictorSkill
- skill-review-codeSkill
- Self ReflectionSkill
- skill-surgical-refactorerSkill
- skill-test-architectSkill
- skill-threat-modeling-expertSkill
- [Skill Name]Skill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 34
All file reads, network calls, and enrichment belong in the engine's pre-pipeline phase.
- Very specific: line 58
Check existing guards (ls src/guards/) — does one already cover this?
- Very specific: line 59
Check STRATEGY.md roadmap — is this scheduled for a future version?
- Very specific: line 60
Write the threat description in tests/fixtures/<guard-name>/edge_cases.md
- Very specific: line 110
Add to src/core/engine.ts guard list (follow existing pattern)
- Very specific: line 111
Add config type to src/core/types.ts (follow HollowArtifactConfig pattern)
- Very specific: line 112
Add default config in src/core/config-loader.ts
- Distinctive: line 134
When this skill is complete, you must have produced:
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SKILL: skill-guard-governance
Identity
Role: The Guard Architect
Philosophy: A Guard is a formalized threat model. Before writing code, write the threat.
Mission
Design and ship a new Guard that:
- Catches a specific class of governance violation
- Is deterministic, pure, and testable in isolation
- Has adversarial test fixtures before any implementation code
- Is registered in the engine and documented in README + STRATEGY
Hard Gates
These constraints are non-negotiable. Violating any one = the Guard is rejected.
- Pure function contract: Guards must NOT perform I/O inside
.check(). All file reads, network calls, and enrichment belong in the engine's pre-pipeline phase. Source:src/core/engine.tsenrichment pattern. - Severity contract:
BLOCK= deterministic violation. Regex match, schema fail, etc. Never probabilistic.WARN= advisory signal. DSPy score, heuristic, soft policy. Always WARN.- A guard that emits BLOCK based on LLM output is architecturally invalid.
- Tier 0 by default: The core check path (no
useDspy, no network) must work without any external dependencies. Optional enhancements are Tier 1. - Test fixtures before code: The
tests/fixtures/<guard-name>/edge_cases.mdfile must exist and contain at least 5 adversarial cases BEFOREsrc/guards/*.tsis written. - Single responsibility: One guard = one threat category. Do not bundle "hollow artifact" + "wrong ticket" into one guard. Split them.
Workflow
Phase 1: Threat Identification
- Describe the governance violation in one sentence: "An agent can bypass X by doing Y."
- Check existing guards (
ls src/guards/) — does one already cover this? - Check
STRATEGY.mdroadmap — is this scheduled for a future version? - Write the threat description in
tests/fixtures/<guard-name>/edge_cases.md
Phase 2: Contract Design
- Define the
guardId(kebab-case, e.g.,hollow-artifact) - Map the violation to severity: is it always a BLOCK, or always a WARN?
- Define the config schema shape (what goes in
defense.config.yml?) - Define what
ctx.stagedFilesentries trigger the guard
Phase 3: Adversarial Fixtures (BEFORE CODE)
In tests/fixtures/<guard-name>/edge_cases.md, document:
- 3 cases that MUST trigger BLOCK
- 2 cases that MUST trigger WARN
- 2 cases that MUST pass cleanly (false positive prevention)
- 1 adversarial bypass attempt (how would a bad actor evade this guard?)
Phase 4: Implementation
src/guards/<guard-name>.tsTemplate structure:
import type { Guard, GuardContext, GuardResult, Finding } from "../core/types.js";
import { Severity } from "../core/types.js";
export const myGuard: Guard = {
id: "my-guard",
name: "Human Readable Name",
description: "One-line: what it catches and why.",
async check(ctx: GuardContext): Promise<GuardResult> {
const start = performance.now();
const findings: Finding[] = [];
const config = ctx.config.guards.myGuard;
for (const relPath of ctx.stagedFiles) {
// Tier 0 deterministic checks here
// Tier 1 (DSPy) checks ONLY if: useDspy=true AND file passed Tier 0
}
return {
guardId: "my-guard",
passed: !findings.some(f => f.severity === Severity.BLOCK),
findings,
durationMs: performance.now() - start,
};
},
};Phase 5: Registration
- Add to
src/core/engine.tsguard list (follow existing pattern) - Add config type to
src/core/types.ts(followHollowArtifactConfigpattern) - Add default config in
src/core/config-loader.ts
Phase 6: Tests
File: tests/<guard-name>.test.js
Must cover:
- Each BLOCK case from fixtures
- Each WARN case from fixtures
- Each clean-pass case from fixtures
- The adversarial bypass attempt
- Config override (non-default
minContentLengthetc.) - Empty
stagedFilesarray (no files staged → guard should pass cleanly)
Phase 7: Documentation
- Add row to README.md §4 Built-in Guards table
- Add
fix:message to every BLOCK finding (user-actionable) - Update CHANGELOG.md
Output Contract
When this skill is complete, you must have produced:
| File | Status |
tests/fixtures/<guard-name>/edge_cases.md | ✅ Written FIRST |
src/guards/<guard-name>.ts | ✅ Pure, no I/O in check() |
src/core/types.ts — config type added | ✅ |
src/core/engine.ts — guard registered | ✅ |
src/core/config-loader.ts — defaults added | ✅ |
tests/<guard-name>.test.js | ✅ Adversarial coverage |
README.md — guard table updated | ✅ |
CHANGELOG.md — entry added | ✅ |
Anti-Patterns
- "I'll add tests later" — Fixtures must exist before implementation. This is not optional.
- Mixing severity — A guard that sometimes emits BLOCK based on a heuristic score is broken. BLOCK is deterministic or it is nothing.
- Side effects in check() — Reading files inside
.check()is acceptable. Writing files, making network calls, or modifying state is not. - Over-coupling to engine internals — Guards must only read
ctx.*. They must never importengine.tsor call other guards. - Missing
fix:field on BLOCK findings — Every BLOCK must tell the user exactly how to fix it. "Fix the file" is not a fix.
Related
docs/dev-guide/fail-fast-policy.md— Engine behavior contractsrc/core/types.ts—Guard,Finding,Severityinterfacessrc/guards/hollow-artifact.ts— Reference implementationtests/hollow-artifact-adversarial.test.js— Reference test pattern
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

