Turn a repeated mistake into a tested local Codex hook rule. Use for $forge, requests to prevent a recurring tool action, or requests to backtest, list, audit, harvest, or remove project guardrails.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Forge?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mohammedatya-forge-guardrail-forge)
---
name: forge
description: Turn a repeated mistake into a tested local Codex hook rule. Use for $forge, requests to prevent a recurring tool action, or requests to backtest, list, audit, harvest, or remove project guardrails.
---
# Forge for Codex
For a standing task such as “after editing Python, run the tests,” use the sibling [always skill](../always/SKILL.md). For a judgment call that a tool hook cannot observe, propose wording for the project's AGENTS.md.
Use the target project root for all commands. The bundled engine is `scripts/codex_forge.py` relative to this skill. The project's installed engine is `.codex/guardrails/codex_forge.py`.
1. Translate the correction into a narrow trigger, the response Codex should receive, and three fixtures showing a violation, allowed work, and a similar allowed action. Use the [rule format and examples](reference/rules.md). For file rules include `Edit|Write|Bash` and match `path`. Codex patches map to one Edit or Write per affected path. Shell commands map to Bash. Choose a pre-tool denial or a post-tool reminder. If the user wants an interactive approval prompt, explain the Codex hook limitation before proposing a denial.
2. Write a candidate JSON file in a temporary directory. Run `python3 <bundled-engine> backtest <candidate> --project-dir <root>`. Review hits against the user's intent. Report historical coverage and the day-one checks separately. Missing rollout history gives no evidence about past behavior.
3. Show the rule, examples and backtest result. Get the user's agreement to the rule and any first-time hook installation. Run `python3 <bundled-engine> install --project-dir <root>` for setup or upgrade. Ask the user to review the four Forge registrations in Codex's `/hooks` in the trusted project. Installation and hook trust are separate.
4. Run `python3 <installed-engine> add <candidate>`. A green fixture suite and a successful add confirm that the rule was saved. Report any conflict or overly broad match and revise the rule against the examples.
Use the installed engine for `list`, `audit`, `doctor`, `test`, and `split`. Use `harvest --project-dir <root>` with the bundled engine to find repeated corrections in available Codex JSONL sessions. The user can archive a rule from their terminal with `python3 .codex/guardrails/codex_forge.py remove <id>`.
Rules apply in the installed project. Codex handles its own permissions and sandbox. The adapter accepts declarative rules and reminders. Claude settings fields, hook-launched fix commands, and approval-prompt rules are unsupported.