agentleFS
89jobrien89jobrien/godmode/skills/agent-governance/SKILL.md

godmode:agent-governance

Skill1 starsChanged 58 days agoMITView on GitHub

Patterns and techniques for adding governance, safety, and trust controls to AI agent systems in Rust. Use this skill when building agents that call external tools, implementing policy-based access controls, adding semantic intent classification to detect dangerous prompts, creating trust scoring systems for multi-agent workflows, building audit trails, or enforcing rate limits and content filters. Covers policy composition, tool wrappers, trust decay, and JSONL audit trails — all in Rust.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the file named in a row before doing the task in its right column.

    line 21
  2. Distinctive:

    Every agent dispatch passes through the governance hook.

    line 51
  3. Very specific:

    All subcommands support --json.

    line 73
  4. Very specific:

    When the godmode binary isn't on PATH (e.g., during plugin development), the hook falls back to the nushell helpers in helpers/:

    line 89
  5. Very specific:

    All governance decisions are logged to .ctx/godmode/traces/governance-audit.jsonl.

    line 106

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Agent Governance

Policy-driven controls for AI agent tool access, content filtering, subagent constraints, and audit trails.

Reference files

Read the file named in a row before doing the task in its right column. These files are not loaded automatically.

FileRead before
references/policy-layout.mdcreating, moving, or reviewing a policy file under policies/, or choosing an agent's category
references/policy-schema.mdwriting or editing a policy YAML file
references/hook-behavior.mdchanging hook.nu, its PreToolUse/Agent registration, or any approve/block check
references/audit-trail.mdreading, aggregating, or changing the governance audit log, or the audit: block
references/adding-policies.mdadding a new agent category or a one-off custom policy
references/rust-patterns.mdbuilding a policy struct for a Rust agent system (Pattern 1)
references/rust-patterns-policy-composition.mdcomposing policies or adding a policy to a Rust agent (Pattern 2)
references/rust-patterns-governed-tool.mdwrapping a tool call in a governance check (Pattern 3)
references/rust-patterns-trust-and-audit.mdadding trust scoring or an audit trail to an agent (Patterns 4 and 5)
references/governance-levels.mdchoosing a governance level for an agent
references/policy-example.yamlseeing a filled-in policy before writing one

How It Works

Agent Dispatch
  → hook.nu (PreToolUse/Agent)
    → detect-agent-name (from tool_input)
    → resolve-policy.nu (default + category + level)
    → check blocked_tools, allowed_tools, blocked_patterns
    → check subagent constraints (max_concurrent, no_commit_to_main)
    → emit governance-audit.jsonl event
    → approve or block with reason

Every agent dispatch passes through the governance hook. The hook resolves the effective policy by composing three layers:

  1. Default (policies/default.yaml) — baseline all agents inherit
  2. Category (policies/by-category/<cat>.yaml) — per-category overrides
  3. Level (policies/levels/<level>.yaml) — governance level overlay

Composition follows most-restrictive-wins: blocked lists union, allowed lists intersect, rate limits take minimum, human-approval lists union.

Policies

The directory layout, category principles, and schema are in references/policy-layout.md and references/policy-schema.md. Read them before touching policies/.

CLI (godmode policy)

godmode policy subcommands (resolve, check, list, audit) are available in the CLI. The examples below document the API; the Nushell helpers remain as an alternative for scripting.

All subcommands support --json.

godmode policy resolve

Resolve the effective policy for an agent by composing default + category + level.

godmode policy resolve gm-orchestrator
godmode policy resolve gm-cap-agent --json
godmode policy check gm-cap-agent Bash --input "..."
godmode policy list [--json]
godmode policy audit [--date YYYY-MM-DD] [--json]

Nushell Helpers (fallback)

When the godmode binary isn't on PATH (e.g., during plugin development), the hook falls back to the nushell helpers in helpers/:

  • resolve-policy.nu <agent> [--level <level>] [--json]
  • check-tool.nu <agent> <tool> [--input <content>] [--level <level>]
  • audit-report.nu [--date YYYY-MM-DD] [--json]

These implement the same logic as the Rust module but run as standalone scripts.

Hook Behavior

The hook.nu runs as a PreToolUse/Agent hook (registered in hooks/hooks.json). Its dispatch steps, the checks it runs, and the reminders it injects on approval are in references/hook-behavior.md.

Audit Trail

All governance decisions are logged to .ctx/godmode/traces/governance-audit.jsonl. The record format and the audit-report.nu aggregation are in references/audit-trail.md.

Governance Levels

See references/governance-levels.md for full details.

LevelToolsSubagentsApprovalMax calls
Openall5none1000
StandardR/W/E/Bash/Glob/G5force-push200
StrictR/Glob/Grep2writes+bash50
LockedR/Glob/Grep0everything25

Adding Categories and Custom Policies

Steps for a new category and the (not yet implemented) custom policy path are in references/adding-policies.md.

Implementation Patterns (Rust)

The Rust reference implementations are split by pattern. Pattern 1 (policy struct) is in references/rust-patterns.md. Pattern 2 (composition) is in references/rust-patterns-policy-composition.md. Pattern 3 (governed tool wrapper) is in references/rust-patterns-governed-tool.md. Patterns 4 and 5 (trust scoring, append-only audit) are in references/rust-patterns-trust-and-audit.md. They are not used by the hook, which is Nushell, but document the architectural approach.

Best Practices

PracticeRationale
Policy as configurationYAML, not code — change without rebuilding
Most-restrictive-winsWhen composing, deny always overrides allow
Pre-flight, not post-hocCheck before execution, not after side effects
Fail closedIf governance check errors, deny rather than allow
Separate policy from logicGovernance is independent of agent business logic
Append-only auditNever modify audit entries — immutability enables compliance
Inject reminders, not just logAgents see governance rules in stderr before acting

Related

  • skills/observability-as-infrastructure/SKILL.md — trace events for audit
  • skills/parallel-agents/SKILL.md — subagent dispatch protocol
  • references/governance-levels.md — level detail and choosing guide
  • helpers/policy-template.yaml — blank policy for new categories

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.