reassert-guards-on-rewrite
Skill2 starsChanged 13 days agoMITView on GitHub
Use when refactoring, porting or replacing a path that enforces authentication, tenant isolation, validation, redaction, idempotency, quotas or scoped-operation limits.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- apply-review-findingsSkill
- author-workflow-fanoutSkill
- chain-launcherSkill
- delegateSkill
- design-consultationSkill
- design-fail-closed-gateSkill
- document-releaseSkill
- gistSkill
- goal-promptSkill
- grokbotSkill
- incident-as-codeSkill
- investigateSkill
- learn-captureSkill
- office-hoursSkill
- orion-deep-researchSkill
- oss-loopSkill
- pre-compactSkill
- pre-prSkill
- prove-control-bindsSkill
- prove-deploy-is-liveSkill
- readonlySkill
- reprobe-stale-premiseSkill
- scope-guardSkill
- shipSkill
- tdd-loopSkill
- tools-routerSkill
- triage-fanout-verdictsSkill
- xSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 67
Read access to both revisions and the contract, and authority to run the consumer's focused checks, are prerequisites.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Reassert guards on rewrite
A guard must still control the protected effect after a rewrite. A passing happy path, matching fields or unchanged guard counts cannot establish that.
Procedure
- Identify the original and candidate revisions, guarded entry points and protected effects. If either source is unavailable, leave verification unresolved. Use the consumer repository's contract and declared checks.
- Inventory each original safety property. Record its old enforcement site, new enforcement site and disposition: preserved, moved, superseded or unresolved. Superseded requires an explicit reason and equivalent or stronger protection; a lower textual count alone says nothing about safety.
- Trace every affected entry point to the effect. A moved check must execute before the effect on every route. Inspect sibling wrappers, alternate modes and direct callers for bypasses. Enumerate gaps outside your authorized scope; obtain the needed ownership before repairing them.
- Exercise each prohibited condition at the actual entry points. Require both denial and evidence that no protected effect occurred. Also exercise the allowed case. A raised exception after a write is a failed guard.
- Record commands, revisions, observed effects and remaining uncertainty in a guard ledger. For commit-specific claims, execute against source materialized from that immutable revision without working-tree overlays; a clean Git status can hide changed bytes. Label uncommitted proof with its patch/tree identity, not as proof that HEAD contains the change. Re-read the final candidate after repairs. Accept only when every relevant guard has binding evidence; otherwise report the precise gap.
Textual searches and optional external diff tools are advisory. They can miss changed ordering, bypasses or semantics, and flag harmless consolidation. Equal regex/count scores never certify safety. Missing inputs, tool errors and unrun negative paths are inconclusive, never a clean verdict.
For scoped operations, compare the intended scope, unaffected survivor set and effective guard configuration before and after. A broader operation requires separate authority. Missing survivor evidence leaves acceptance blocked.
Worked example and evidence
The tenant-write example contains an original guard, a dropped guard, an unsafe move after the write and a safe move into a shared wrapper. With Python 3, run it from this directory:
python3 examples/guarded_write.pyFor both api and batch, an allowed write appends once. A denied request must
raise and leave the recorder empty. The unsafe move still raises, with the same
textual guard counts, but has already appended. The safe move guards both paths.
The example is illustrative; apply the same probe to the real consumer boundary.
| Guard | Candidate | Evidence required | Disposition |
| Tenant equality before write | Dropped | Negative probe appends | Unresolved; reject |
| Tenant equality before write | After append | Raises but appends | Unresolved; reject |
| Tenant equality before write | Shared wrapper | Both paths deny, zero appends; allowed cases pass | Moved; supported |
Prerequisites and authority
Read access to both revisions and the contract, and authority to run the consumer's focused checks, are prerequisites. Python 3 is only needed for the example. There is no bundled safety analyzer or required sibling skill. This procedure grants no source-write, commit, push, deployment, installation, service, hook, credential or external-communication authority.
Retain provenance and the notice with a standalone copy.
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.

