Permissions and gates
GameFrame and every project made with scripts/new-project.sh come with gates. A gate is a small check that runs before a commit, a push, a file write or a shell command. It stops the few mistakes that cost the most: game material in git, decompiled code in tracked files, commits by agents that should hand off instead, and deleting the user's copy of the game. The gates run in git itself, so they protect people and every agent. Each agent's own hooks add earlier checks, and permissions decide what runs without a prompt.
Gates are a safety net for honest mistakes. They are not a security boundary. A person or an agent that means to get around them can. The rules in AGENTS.md and the skills still apply in full.
What the gates check
The checks live in scripts/hooks/gates/checks.py. They know nothing about any agent. scripts/hooks/gate.py is the command that every hook calls. A gate that blocks exits with status 2 and writes the reason on stderr. Git and every agent below treat that as a refusal and show the reason. In every other case the gate exits 0 and changes nothing.
| Check | It blocks |
|---|---|
| Commit | Staged files in game/, media/, saves/, analysis/, derived/, target/, game-data/ or save-game/, or those links themselves. Staged game binaries and data files (.exe, .dll, .ovl, .pkg, .sav, .wad, .pak, ROM images and others). Added lines that look like Ghidra's decompiled code. A commit made by a GameFrame agent other than re-lander. A commit while .claude-plugin/plugin.json still names a release that has its vX.Y.Z tag: python3 scripts/release.py next opens the next -dev version first. |
| Push | A push made by a GameFrame agent other than re-lander. |
| Write | Writing two or more lines of decompiled code into a file outside analysis/, derived/ and game/. |
| Delete | A shell command that would delete or move a game's files: a project's game/ (or the older target/), or games/ID/game/ and games/ID/media/ in the GameFrame home. It catches rm, trash, mv of it or into the Trash, find -delete, git clean -x, cargo clean into target/, build-folder cleaners (kondo, cargo sweep, npkill) and scripts that call rmtree or send2trash on it. A command that starts with GAMEFRAME_DELETE_GAME=1 passes. |
The game folder
A project's game/ holds the user's own copy of the game, and media/ the discs and installers it came from. Both are links into the GameFrame home (~/gameframe/games/ID/), so they sit outside every repository, and git ignores the links. No commit keeps a copy. Older projects keep the game in target/ inside the project. Cargo's build output has the same default name, and a project with a Rust port has a Cargo.toml beside it, so cleaners and agents take it for build output. The project's .cargo/config.toml sends Cargo to build/.
scripts/hooks/gates/game_folder.py decides which folders are game folders:
game/ormedia/in the home, beside agame.json;- a project's
game/ortarget/that holdsGAME-FILES-NOT-BUILD-OUTPUT.txt; - a project's
game/ortarget/whose project names GameFrame in itsAGENTS.md; - a
target/whose project sets anothertarget-dirin.cargo/config.toml.
The delete gate (scripts/hooks/gates/deletes.py) blocks a command that would remove one, or a folder that holds one, such as the whole home. Removing a project's link (rm game, with no slash) passes, since the files stay in the home. Renaming a project folder passes. When the user wants the game folder gone, the command starts with GAMEFRAME_DELETE_GAME=1, or the user runs it themselves. ./gameframe doctor reports a missing or empty game folder, and ./gameframe home doctor a broken link. See the know-how entry for what happened.
What counts as decompiled code
Ghidra's decompiler writes names and forms that people do not write by hand. The gates look for these: undefined4, CONCAT44(, SUB41(, ZEXT14(, (**(code **), /* WARNING: , and variables such as unaff_EBX, in_stack_00000008 and extraout_EAX. They also look for pointers and variables declared with those types, and for statements with Ghidra's names: a call to a FUN_ function ending in a semicolon, an assignment to or from a DAT_ name, and a function declared with a FUN_ name. One such line can appear in prose that explains a type. Two or more lines in one write or one commit are blocked.
Function addresses such as FUN_1400be770, offsets such as +0x44 and constants pass. They are how findings cite the original. Plain English that uses the word in its usual sense passes too.
Which agents may commit
Only re-lander commits and pushes. The other stage and task agents end with a hand-off that names the next agent. When an agent such as re-tracer tries to commit, the gate tells it to hand off to re-lander. The main session and people are not GameFrame agents, so they can commit and push.
The gate learns which agent is running in one of three ways, in this order:
- Claude Code puts the subagent's name in the hook input (
agent_type). - The environment variable
GAMEFRAME_AGENTholds the agent's name, such asre-tracer. - The shell command starts with it:
GAMEFRAME_AGENT=re-tracer git commit -m "...".
The other agents have no field for the subagent, so their agent files set the variable on the command. With none of the three, the gate treats the commit as the main session's.
The git hook
scripts/hooks/git/pre-commit runs the commit check inside git, with no agent at all. It runs gate.py staged, which reads the commit's index and GAMEFRAME_AGENT. It catches commits from a terminal, from an editor and from any agent, including git commit -a.
- In GameFrame,
scripts/setup.shsetsgit config core.hooksPath scripts/hooks/git. - In a project,
scripts/new-project.shcopies the hook to.githooks/pre-commitand setscore.hooksPath .githooks. In a plugin project the hook finds GameFrame through./gameframe root(orGAMEFRAME_ROOT). In a project made with--copyit uses the project's ownscripts/hooks/gate.py. scripts/setup.sh(and./gameframe doctor) setscore.hooksPathonly when it is unset. When you already use a hooks folder of your own, it says so and leaves it. Call the GameFrame hook from your ownpre-committo keep both.- When the hook cannot find
gate.py, it warns and lets the commit through.
Git does not run hooks from a fresh clone until core.hooksPath is set, so run scripts/setup.sh (or ./gameframe doctor) once after cloning. git commit --no-verify skips the hook for one commit. The hook checks commits only. The push rule runs in the agents' hooks.
Each agent's hooks
The agent hooks run earlier than git, before the tool call. They also check file writes, which git never sees until a commit. Each agent has its own input format, so gate.py takes the agent's name and reads that agent's fields (scripts/hooks/gates/adapters.py). The formats below follow each agent's documentation as of October 2026.
| Agent | Config file | Event | What is checked |
|---|---|---|---|
| Claude Code | hooks/hooks.json (the plugin), .claude/settings.json | PreToolUse on Bash, Write, Edit; SessionStart; PostToolUse and PostToolUseFailure on Bash | Commit, push, write; a session note; known failures after a command |
| Codex | .codex/hooks.json | PreToolUse on Bash and apply_patch; PostToolUse on Bash | Commit, push; write (the added lines of each file in a patch); known failures after a command |
| Gemini CLI | hooks/gemini-settings.json, merged into .gemini/settings.json | BeforeTool on run_shell_command, write_file, replace; AfterTool on run_shell_command | Commit, push, write; known failures after a command |
| Cursor | .cursor/hooks.json | beforeShellExecution; postToolUse on Shell | Commit, push; known failures after a command |
| GitHub Copilot | .github/hooks/gameframe.json | preToolUse (bash); postToolUse, postToolUseFailure | Commit, push; known failures after a command |
A project gets these files for the agents it names with --agent (scripts/clients.py). In a project made with --copy they call the project's own scripts/hooks/gate.py. A plugin project has no scripts/, so its hooks call ./gameframe gate KIND instead, and the launcher runs GameFrame's gate.py. A plugin project's know-how hook calls ./gameframe advise-hook AGENT in the same way.
Claude Code
The plugin brings the hooks in hooks/hooks.json. GameFrame itself, and projects made with --copy, also list them in .claude/settings.json. Each hook calls one gate: gate.py commit, push, write or session. The hook's if field picks out git commit and git push. The session gate adds a short note to the start of a session: whether .env, .venv and the Ghidra export exist, and the next three open items in docs/CHECKLIST.md.
One more hook is not a gate. After each shell command, scripts/hooks/advise.py post looks for know-how entries whose error signature matches the output, or whose command pattern matches the command, and adds them to the agent's context. It never blocks anything (Know-how).
Codex
.codex/hooks.json runs gate.py codex before Bash and apply_patch. Codex loads a project's hooks only when the project is trusted, and asks you to review each new or changed hook with /hooks before it runs. For apply_patch, the gate reads the patch text and checks the + lines under each *** Add File: and *** Update File: header.
Gemini CLI
Gemini CLI reads hooks from .gemini/settings.json. GameFrame ships its entry as hooks/gemini-settings.json. Copy its hooks section into .gemini/settings.json, or merge it with the settings you have. It runs gate.py gemini before run_shell_command, write_file and replace.
Cursor
.cursor/hooks.json runs gate.py cursor before shell commands that contain git. Cursor's documentation gives no file fields for a hook that runs before a write. Its afterFileEdit hook runs after the file is written and cannot stop it. So Cursor's writes are checked only at commit, by the git hook.
GitHub Copilot
.github/hooks/gameframe.json runs gate.py copilot before every tool call. The gate acts only on bash calls that commit or push. Copilot's documentation gives no argument fields for its edit and create tools, so writes are checked only at commit, by the git hook. Copilot denies the tool call when a preToolUse hook fails, so python3 must be on the path.
Permissions
Permissions decide which commands run without a prompt. Each agent has its own system. GameFrame ships Claude Code's lists. For the others, the table below says where the same choices live. Set them up for your own agent and project.
Claude Code checks the deny list first, then the ask list, then the allow list. A command on none of the lists follows the session's permission mode.
| List | Commands | Why |
|---|---|---|
| Allow | ./gameframe, the scripts in scripts/ (Ghidra export and run, DOSBox, the installer extractor, setup.sh without --install), tests/run.sh, the tools under .venv/bin/python tools/ and truth/ | The toolkit's own commands. They read the game and write only to ignored folders. |
| Allow | git status, diff, log, show, add, commit, pull | Every slice ends with a commit. The commit gate checks each one. |
| Ask | git push | A push publishes the work. The user sees each one. |
| Ask | scripts/setup.sh --install, brew install, cargo install, npx -y rea-agents@6.7.0 setup, sudo, curl, wget | These install software or download files. The project asks before any download. |
| Deny | git add -f, git add --force, git push --force, git push -f | A forced add is the usual way game material reaches git. A forced push can destroy another session's work. |
Everything else, such as reading files, running cargo, objdump or python3, is left to the session's mode. The lists do not try to name every tool an agent may need.
| Agent | Where the same choices live |
|---|---|
| Claude Code | permissions.allow, ask and deny in .claude/settings.json. |
| Codex | sandbox_mode (read-only, workspace-write, danger-full-access) sets what commands can touch. approval_policy (on-request, never, or a granular policy) sets when Codex asks. Execution-policy rules allow, prompt for or forbid single commands. Both settings live in config.toml. |
| Gemini CLI | The policy engine. Rules in TOML files under ~/.gemini/policies/ match a toolName, a commandPrefix or a commandRegex, and give a decision of allow, ask_user or deny. Workspace policy files are not read yet, so the rules live in your user folder. |
| Cursor | The agent's command allowlist in Cursor's settings, and its run mode. |
| GitHub Copilot | The tools you allow or deny when you start the CLI, and the permissionDecision a preToolUse hook returns. |
To match GameFrame's Claude lists elsewhere: allow the toolkit and the everyday git commands, ask before git push and before installs or downloads, and deny forced adds and forced pushes.
Changing them
Put personal additions in .claude/settings.local.json, which git ignores. Claude Code merges its lists with the ones in .claude/settings.json. An entry there can allow more commands. It cannot undo an ask or a deny entry from the shared file, because deny and ask are checked first. To change those for everyone, edit .claude/settings.json in the project. To turn a gate off for one project, remove its entry from that agent's hook file, or unset core.hooksPath for the git hook.
When a gate blocks something that is correct, change the gate rather than working around it. Add a test for the case to tests/run.sh, in the section named "Gates".