Borrowing it
Nothing to install: this file belongs to HexamindOrganisation/hexgate. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/HexamindOrganisation/hexgate/main/.claude/skills/write-policy/SKILL.mdgit clone --depth 1 https://github.com/HexamindOrganisation/hexgateWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/hexamindorganisation/hexgate/write-policy)<a href="https://agentmods.dev/skills/hexamindorganisation/hexgate/write-policy"><img src="https://agentmods.dev/badge/skills/hexamindorganisation/hexgate/write-policy/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/hexamindorganisation/hexgate/write-policy"><img src="https://agentmods.dev/badge/skills/hexamindorganisation/hexgate/write-policy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00128 | $0.03271 |
| Opus 5.5 | $0.00051 | $0.01308 |
| Sonnet 5.5 | $0.00026 | $0.00654 |
| Haiku 4.5 | $0.00013 | $0.00327 |
Grade A, and why
write-policy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Write a Hexgate policy
The user describes intent in prose; you produce a policy YAML that validates, plus a set of dry-run cases that prove it does what they asked. A policy you have not run through the CLI is not finished.
Sources of truth — read the relevant one before using a feature you are unsure of, and prefer them over this file if they disagree:
| Topic | File |
|---|---|
| Document shape, modes | docs/policy/yaml-shape.mdx |
| Constraint grammar (full reference) | docs/policy/constraints.mdx |
| Worked condition examples | docs/policy/writing-conditions.mdx |
Roles, policies/ dir, inheritance |
docs/concepts/user-scope.mdx |
| Egress | docs/concepts/egress.mdx |
| Admission / agent reach | docs/concepts/agent-level-enforcement.mdx |
| Cross-run quotas, fail mode | docs/policy/constraints.mdx (Agent usage), docs/adr/R-USAGE-001-cross-run-usage-is-soft-and-fails-open.md |
| Modules (boundaries / capabilities) | docs/internals/policy-modules.md |
| CLI | docs/cli/policy.mdx |
| Schema (authoritative) | hexgate/security/models.py, hexgate/security/constraints.py |
| Examples | examples/demo_policy.yaml, deploy/demo_policies/ |
Workflow
-
Pin down the inputs. You need:
- the tool names and their argument names/types. Take these from the agent code or its
AgentManifest. Otherwise, use what the requester named in their prompt, or ask them; - the roles (who calls);
- the caller attributes available as
ctx.*; - the shape to write in: a single file, a
policies/dir, or modules.
Never invent a tool or argument name. A typo'd tool is silently default-denied, and a typo'd arg fails closed. If a name is unknown, ask, or state the assumption explicitly. If the agent's manifest JSON is available, pass it to
validate(step 4), which flags tool, skill and argument names the agent doesn't have. - the tool names and their argument names/types. Take these from the agent code or its
-
Restate the intent as a decision table before writing YAML. List role × tool × condition → ALLOW / DENY / APPROVAL_REQUIRED, plus what happens to anything unlisted. Surface every ambiguity here, e.g. "refunds up to 500 — inclusive? which currency?".
-
Write the YAML. Start deny-by-default and grant the minimum. Put each constraint at the narrowest scope that works (see Where constraints live).
-
Validate until clean:
uv run hexgate policy validate <file> --max-severity warning [--manifest m.json]If
uvfails buildingbiscuit-pythonon Python 3.14, add--python 3.13. For a module tree, useuv run hexgate policy check --dir <root> [--manifest m.json]anduv run hexgate policy resolve --dir <root>. -
Prove it. Turn every row of the decision table into a
policy testrun, including the negative cases and the boundary values (== limit,limit + 1, missing arg, wrong type):uv run hexgate policy test <file> --role billing --tool refund_order \ --args '{"amount": 500, "currency": "USD"}' [--attributes '{"department": "finance"}'] \ [--agent-usage '{"invocations_1h": 100}'] [--user-usage '{"invocations_1h": 50}']Test a usage cap at
limit - 1and atlimit, with--agent-usageforagent_usage.*and--user-usageforuser_usage.*(a path left out reads zero). Also use--roles a,bto check a multi-role caller, where the most permissive role wins. Pass--engine wasmon everypolicy testrun, since that engine matches production. If it fails because OPA itself is unusable (e.g.opa not found,HEXGATE_OPA_BIN points to…,below the tested floor), drop the flag and say in the report that the production engine went unchecked, and why; any other wasm error is a problem in the policy to fix. Every result must match the table. When one doesn't, fix the policy, not the table, unless the table was wrong. -
Report. Give the YAML, the decision table with each case's actual CLI result, and any assumptions or residual risks, e.g. "egress on HTTPS is host-level only".
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago Changed · +6 lines · +3 tokens per session e4cf4b36e943
- 13d ago Changed · -1 lines d2c3ffb61829
- 14d ago Changed · +9 lines · +9 tokens per session 6f44f67ed662
- 16d ago Changed · +1 lines 21c60ac942ba
- 22d ago Changed 1d424587dc6b
- 23d ago Changed 53806fe1b4d3
- 1mo ago First seen · 146 lines · 116 tokens per session scan A 3f88b526978a
write-policy is a skill published in the GitHub repository HexamindOrganisation/hexgate (23 stars, last pushed today), licensed MIT. It adds 128 tokens to every session and 3,271 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-25.
Other skills, from other repositories
theauth
Install and use theAuth (@glinr/theauth), the TypeScript auth SDK for AI agents and humans. Use when adding agent identity, scoped permissions, delegation, audit logs, human sign-in plugins, or an MCP OAuth 2.1 authorization server to a Node, Bun, Deno or edge project.
agent-harness-fault-injection
Use when an agent workflow needs deterministic recovery evidence for sandbox, MCP/tool, worker, checkpoint, memory, or orchestration failures.
requirements-writer
Use when converting PM intake into a slice SPEC.md with observable acceptance outcomes, explicit scope, and advisory sibling build dependencies.
refocusing
Use when a long-running agent may have lost the product outcome, when context was compacted, when work has crossed a major boundary, or when a fresh path-based trace is needed before the next consequential action. Not for fresh-session orientation, waking an idle seat, or checkpoints.
orchestration-team
Use when coordinating assignments, selected review boundaries, or blocked work across a rig.
oversight-team
Use when you are a seat on the oversight pod (a standing monitor-mode rig that keeps OTHER rigs healthy), configuring or running the drift detectors, or choosing whether to intervene vs escalate. Covers the pull-not-poll posture, the v0 detectors (premature-park, process-drift, off-task, token-burn), the intervention…