Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Other skills

add-guardrail

Block repeated mistakes with types, lint, CI, hooks, or permission rules, with AGENTS.md last. Use after a correction recurs or to mine past sessions with droid search; not for opening /hooks or editing permissionRules by hand.

Cynnamoroll · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add Cynnamoroll/factory-stack --skill add-guardrail

About this skill


name: add-guardrail description: "Block repeated mistakes with types, lint, CI, hooks, or permission rules, with AGENTS.md last. Use after a correction recurs or to mine past sessions with droid search; not for opening /hooks or editing permissionRules by hand." license: MIT compatibility: droid disable-model-invocation: true

Add guardrail

Make the mistake impossible to repeat. Assume contributors see only opened files, copy the nearest example, and take the shortest path that compiles.

1. Find the mistake classes

Gather the corrections from one of these sources:

  • this session
  • past sessions: droid search "<phrase>" --kind message_text --json, then read the matching turns
  • recent commits, reverts, review comments, and AGENTS.md

Group corrections into classes with at least two occurrences. Show each class's evidence.

2. Pick the highest rung that works

  1. Architecture. One owner per piece of state and one supported way per task. Hide internals so the wrong import fails. Replace hand-synced lists with one source. Delete the old way an agent would copy.
  2. Types, lint, or CI. Make the bad state fail to compile. If it still compiles, add a lint rule or CI check whose error names the right file, type, or function. If the pattern is already common, fail only when a change adds more.
  3. Hook or permission rule. For agent actions code cannot catch:
    • a PreToolUse hook in .factory/hooks.json that exits 2 with the reason on stderr, matched on Execute, Edit, Create, or ApplyPatch, with the script under .factory/hooks/ and called through "$FACTORY_PROJECT_DIR"
    • a permissionRules entry in .factory/settings.json with block or ask and tests.match / tests.noMatch cases, for shell commands only
  4. AGENTS.md, last. Only for judgment calls nothing can check. A personal habit goes in ~/.factory/AGENTS.md. A repo rule goes in the project AGENTS.md.

Pick the highest effective rung. Explain why higher rungs failed.

Changes to a skill go through /create-skill, not a hand edit here.

3. Prove each guardrail fails

Show each new check failing on a real past instance of the mistake, then passing on the corrected code:

  • type, lint, or CI: run the same command locally that CI runs
  • hook: pipe a sample payload into the script and check the exit code, for example echo '{"tool_name":"Edit","tool_input":{"file_path":"gen/x.ts"}}' | .factory/hooks/protect.sh; echo $?
  • permission rule: droid rules check --command '<bad command>' reports the decision, and droid rules check passes its self-tests

If a check does not fail on the real mistake, fix the check, not the example. Hooks load at session start, so tell the user to review the new hook in /hooks and start a new session.

4. Record it

Keep a table in AGENTS.md that pairs each rule with what enforces it. Drop a rule once its mistake cannot happen.

Done when

Each class has its evidence, the rung chosen, why higher rungs failed, and a pasted run showing the guardrail fail then pass. One commit per class.