AGENT SKILL

global-agent-guardrails

Install, audit, test, or update the Development System's global destructive-command guard for Codex, Claude Code and T3 Code. Use when configuring agent safety hooks or investigating whether dangerous shell operations are blocked.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 0
Forks
0

01 前言 Front Matter

name
global-agent-guardrails
description
Install, audit, test, or update the Development System's global destructive-command guard for Codex, Claude Code and T3 Code. Use when configuring agent safety hooks or investigating whether dangerous shell operations are blocked.

02 资源文件 5

03 SKILL.md 正文

Global Agent Guardrails

This skill is the operator guide for the executable destructive-command policy. The hook is the enforcement layer; instructions alone are not protection.

Contract

  • Codex and T3 Code share the Codex PreToolUse adapter, matched on Bash|exec|apply_patch|mcp__.* (whether Codex sends MCP calls to hooks is not yet observed; until a live sentinel shows it, Codex MCP calls are a declared gap).
  • Claude Code uses a PreToolUse hook in its user settings, matched on Bash|Monitor|Edit|Write|MultiEdit|NotebookEdit|mcp__.*.
  • Existing Codex hooks and Claude Code settings are merged, never replaced.
  • Factory settings, skills, logs, and executables are outside the current runtime and are never read or changed.
  • The guard fails closed when a matched shell tool has malformed or missing command input.
  • Hard blocks do not imply sandboxing and do not replace repository permissions, review, backups, or explicit authorization.
  • The agent cannot bypass a block. A human may run the command outside the harness or deliberately remove the guard after reviewing the exact target and recovery plan.
  • Test-file writes are the block the operator lifts without removing the guard: development-system allow-tests <dir> [--hours N] [--reason text] in their own terminal grants that directory for up to 24 hours (default 2); --revoke <dir> ends it and development-system test-grants lists active grants. Grants live in ~/.development-system/test-grants.json. allow-tests refuses agent shells (CLAUDECODE, AI_AGENT, CODEX_THREAD_ID or CODEX_SANDBOX set) and non-interactive terminals, and asks the operator to type the directory's name, so no spelling of the command (variables, xargs, runners) grants from an agent shell. The guard also blocks literal allow-tests invocations (except inside read-only Git commands such as git grep or git log) and writes to the grant file through inspected commands. Threat model: grants stop habitual or accidental self-granting. Like every other limit of this guard, they do not stop an agent that deliberately writes files through interpreter APIs or races a symlink into a granted path within one command.

Operate

Use the Development System CLI from its canonical checkout:

./bin/development-system guardrails-enable
./bin/development-system guardrails-audit
./bin/development-system guardrails-rollback

Use --home <isolated-home> for verification. Enabling requires the catalogued Codex and Claude global-agent-guardrails skills to be installed first.

The policy hard-blocks recursive forced deletion, catastrophic disk operations, destructive Git history/worktree operations, forced pushes, repository deletion, high-impact infrastructure destruction, and downloaded-code-to-shell pipelines. It intentionally does not block normal reads, ordinary file edits, dependency installation, or non-recursive deletion of a named file. For tracked paths, use git rm -r instead of rm -rf.

Policy 2.1.0: quote-aware evaluation and operator test grants

references/policy.json is evaluated against a parsed command, not raw text:

  • Quoted text, heredoc bodies with a quoted delimiter, and redirections such as 2>/dev/null are data. grep "git reset --hard" docs and git commit -m "..." pass.
  • $(…), backticks, <(…) and >(…) are evaluated recursively up to maxSubstitutionDepth (4); $((…)) is arithmetic. $(cat <<'EOF' … EOF) (the usual commit-message form) is read as its literal heredoc text unless the command can change what cat runs, in which case it is dynamic: a cat function (also zsh function a cat { … }), alias, hash or enable naming cat (also after command, builtin, noglob or nocorrect and their options), a trap action naming cat or PATH or built at run time, zsh autoload cat or functions -c f cat, a PATH or zsh path assignment or loop variable, an assigning expansion (${PATH:=…}, ${path::=…}), arithmetic that assigns and names PATH or holds an expansion, quote, backtick or backslash that can build that name ((( PATH = 5 )), (( "PATH" = 5 )), (( $(echo PATH) = 5 )), $[PATH=5], a[PATH=5]=1, ${a[PATH=5]}, ${s:PATH=1}, [[ PATH=5 -eq 1 ]], let x=PATH=5; reading, as in n = ${#path} + $#, and plain names, as in i += 1, do not count; (( n = $x )) counts), a variable, array element or integer value that arithmetic reads again and that assigns a PATH name (n='PATH=5', a=('PATH=5'), declare -i x=PATH=5; NODE_OPTIONS=--require=./path/x.js does not count), a name-taking builtin that sets PATH or takes a variable name (export, declare, read, getopts, readarray, printf -v, print -v, wait -p, zsh set -A, also inside an option cluster such as print -rv, …), a nameref (declare -n, local -n), or a function table entry (bash BASH_CMDS/BASH_ALIASES, zsh functions, commands, aliases). Unquoted heredoc bodies are scanned for substitutions. A heredoc or here-string fed to a shell (or source /dev/stdin) is evaluated as shell. For other interpreters (python -c, node -e/--eval/-p, deno eval, perl -e, ruby -e, osascript -e, php -r/-R/-B/-E, Rscript -e, lua -e, an awk program or awk -f, or a heredoc fed to one of them), each string literal in the code that contains whitespace, including literals joined with +, , or adjacency, and each code fragment between quotes, brackets and ; is evaluated as a shell command with interpolations (${…}, $name, {name}, %s) replaced by a placeholder. Code that calls a process API (system, exec*, spawn*, popen, run, backticks, …) with a lone shell name (os.system("sh")) is blocked. Native file APIs in that code (shutil.rmtree, fs.rmSync, open(…, 'w')) are not inspected.
  • Destructive rules apply to each simple command after wrappers (sudo, env, xargs, timeout, nohup, find -exec, …) are stripped, and to any argument position that names a destructive-capable command or shell (ssh host rm -rf …, watch 'git reset --hard', tmux new -d 'true; git reset --hard', parallel ::: '…'), including command positions inside one argument after ;, &, |, (, { or then/do. They are skipped for pure-read commands (readOnlyCommands, sed without -i/e/w, awk without system(/pipes/redirection).
  • Rule match values: command (default; canonical name args…, for git starting at the subcommand), pipeline (command names joined by |), raw (full source text).
  • Always blocked (structuralRules): eval, $'…' outside single quotes, ${!x}, a variable or substitution as the command name, sh|bash|zsh -c with a non-literal script, a shell or interpreter reading its program from a pipe, inherited or non-literal stdin, a process substitution or a device (echo … | sh, node -, python3 <<< "$x", awk -f -, bash <(…)), Git configuration that makes an ordinary command destructive (help.autocorrect, clean.requireForce=false, deleting or forced push refspecs, remote.*.mirror), unparseable input, and variable arguments to sensitiveCommands (rm, dd, mkfs, diskutil, gh, terraform, pulumi, kubectl, wrangler, vercel, and git outside readOnlyGitSubcommands). Executed inline Git configuration (-c alias.x=…, core.pager) and program-naming variables (GIT_PAGER=…) are evaluated as commands.
  • git-discard allows git checkout --ours/--theirs and git restore --staged.
  • test-file-write blocks creating or modifying paths matching testFilePatterns inside the payload cwd, unless a valid operator grant holds the target after symlinks resolve: unexpired, at most 24 hours long, for the same directory (same inode, not replaced by a symlink). A target with a variable, glob or .. segment, or a relative target after a cd, is never granted: redirections, tee, cp/mv/install destinations, sed -i targets, git diff --output, Edit/Write/MultiEdit file_path, NotebookEdit notebook_path, and apply_patch *** Add File:/*** Update File:/*** Move to:. Deleting test files is allowed.
  • guard-config-write blocks writes to protectedWriteTargets: ~/.codex/hooks.json, ~/.codex/config.toml, ~/.claude/settings.json, ~/.claude/settings.local.json and the installed global-agent-guardrails skills and the operator's ~/.development-system/test-grants.json and ~/.development-system/docs-grants.json (~, $HOME and absolute spellings), plus protectedProjectWriteTargets inside the payload cwd (.claude/settings.json, .claude/settings.local.json, .codex/hooks.json, .codex/config.toml, and .git/config, whose aliases run commands; use git config instead). Writers include redirections, tee, sponge, cp/mv/install/ln, recursive cp/rsync/ditto and tar/unzip/patch rooted above a protected path, perl/ruby -i, curl -o/-O (under the --output-dir of the same transfer; --next starts another), the -f/--file (or GIT_CONFIG, GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM file) of a git config that changes a setting (.git/config included), rsync --log-file/--write-batch files, wget -O/-P, dd of=, ex/vi/vim/nvim/view/ed file operands (also under -R, since :w! still writes), -w/-W logs, files named by write, open or dump commands in any abbreviation, after a line address (also *, \/, \?, \&, marks such as 'a, '<, '( and '{, and an address on a later | command) or :g (:w, %w, 1,$w, :wri, :sav, :x, :up, :wa, :e, :sp, :drop, :args, :redir >, :mksession, :wviminfo, :hardcopy >, ed W and f, with !, ++opt, +, +cmd or >>, and inside a literal :execute string, also after \| or an escaped space, as :execute and a cpo+=b mapping read them (exe "sil\ w FILE"); the +cmd run on the opened file, with its escaped spaces, is read as an editor command itself, as in e +w!\ FILE notes.txt or e +w!\ FILE with no file after it; a +cmd nested more than maxSubstitutionDepth deep is blocked) in -c, --cmd or +cmd scripts and in ed, ex and vim -e/-es scripts from a heredoc or here-string, and chmod/chown/chflags on a protected path or any ancestor, deleting or moving the project's settings directory (.codex, .claude, .git) itself, by name or by a glob that selects it, a write, delete, move, glob or find root through link/.. read from the link's target directory (for docs names and trees too; a cd/env -C to such a path, where logical and physical directories differ, leaves the directory unknown), and the files a recursive copy or sync tree, a patch (below git apply --directory), an archive member (at every suffix of its name under --strip-components or unzip -j) or a Git restore writes there (a patch, archive or remote source the guard cannot read is blocked above guard configuration; no docs grant lifts these), a recursive removal or move (rm -r, rsync --delete, --remove-source-files, mv, Git moves and removals) of a directory holding one that exists or whose directory exists (rsync -a --delete empty/ ., except below a plain --exclude name with no wildcards, --filter, --include or --delete-excluded; no docs grant lifts it), and find … -delete from a starting point that is, is inside or holds one (an existing protected file below it or, under -L/-follow, reached through a linked directory, or a link to one, unless a plain conjunction of -name/-iname and -type/-xtype tests before -delete excludes it, read from the last top-level -o before that -delete, since each -delete of A -delete -o B -delete removes only what its own branch selects; a missing one when find removes the existing directory that would hold it; a protected directory below it always). An editor file name expands ~, $VAR, %/# and wildcards, and after :cd a relative name has an unknown base. Substitution text is data. In an ed script the lines typed after a, i or c up to . are data too (ed exits at the first error in a script), except inside g/v or after G/V, where they are commands. vim and ex run those lines as commands when the append fails or is skipped (inside :g, a missing line or mark, nomodifiable, :if 0), so every line of a vim or ex script is read as a command. Shell commands in those editor scripts (:!, range filters such as %! and 1,2!, :r !, :w !) are evaluated as shell. A non-literal editor script, keys typed into a visual editor from a heredoc, here-string or pipe, a backtick file name, a vimscript process, file or option function (system(), writefile(), delete(), execute(), setbufvar(), …, also in a \= substitution), an embedded language (:lua, :python, …), :terminal, :shell, :source, :runtime, :make, :grep, :cscope, a :set or :let & of a program or shell option (shell, shellcmdflag/shcf, shellquote/shq, makeprg, …, also cleared, since an empty shellcmdflag runs :!notes.txt as a script) or of an expression option to a value (diffexpr, indentexpr, …; clearing one with set indentexpr= is allowed), :normal keys that run commands (!, Q, @, "=, <C-R>) or a built :execute is blocked. A glob target (*, ?, […], **, brace expansion, extglob and zsh groups, qualifiers and ^ # ~ operators, also with quoted or escaped characters inside a pattern; a fully quoted name such as "(backup)/settings.json" is not a glob) is read broadly: each group, brace, qualifier or operator becomes any text (any depth when it spans /; a repeated group spanning / also counts as absent, and from the fifth such group on the rest of the pattern is read as any path), and the target is blocked when that reading can match a protected path; * skips a leading dot unless the command mentions dotglob, GLOBIGNORE or GLOB_DOTS. cd, pushd, env -C and sudo -D move the directory used for later relative targets, and git -C the one its own targets are read from; after a conditional, backgrounded, piped or branch cd, cd -, popd, cd $(…), a missing directory or a CDPATH lookup, the directory is unknown. A path under an unknown directory (a variable prefix, ~-, or an unknown working directory) is blocked when its literal tail can name a protected path or a file below a protected directory.
  • shell-arithmetic-injection blocks text shaped like name[$(…)] in assignments, [[ … ]], for lists and name-taking builtins (let, printf -v, read, declare, export, test -v, …): bash runs that subscript when the text is later evaluated.
  • Known false positives, by design: interpreter code naming a shell next to a process API (shutil.which('bash') with subprocess in the same program), an interpreter with only preload options and no program (node -r ts-node/register), backtick prose with a destructive command inside a runner argument, glob or brace targets that could match a protected path, read-only editor sessions (vim -R, view) on a protected or test path, editor script text outside substitutions and ed typed lines that reads like a write, open or shell command (:echo "e tests/a.test.ts", or vim and ex append text such as terminal output below), conservative vimscript blocks (:make, :grep, :source, :normal keys containing ! or @), and a $(cat <<'EOF' …) commit message read as dynamic when the same command assigns arithmetic through an expansion ((( n = $x )), for ((i=0; i<$n; i++)), (( total += $x )), let i=$i+1) or stores text that assigns or steps a PATH name in a variable or array element (ARGS=--path=src, a=(--path=src), f=${f//--path/}). Known gaps: arithmetic that reads a variable holding a built assignment ((( $x )), (( n )) after read n) is not traced; editor settings such as .vscode/settings.json are not protected; editor script files (-s, -S, -u, ed < file), a SHELL prefix for the editor's :! and vimscript beyond the forms above are not read. The engine denies input over 64 KB and evaluations that exceed its own 3 s budget; the hook command denies when the engine exits abnormally, and the harness enforces the 5 s hook timeout, whose outcome on expiry is the harness's own behavior and is not verified here.

Policy 2.2.1: merge gate

  • merge-gate blocks gh pr merge unless it names the PR explicitly (its URL, or a number with -R owner/repo), --match-head-commit <40-hex head>, and ~/.development-system/private/merge-gates/<owner>-<repo>-<n>-<head>.json holds an unexpired pass (two hours) for that exact PR and head with mergeReady: true. Options are read wherever they sit (gh --repo o/r pr merge …); -R and --repo are one option and the last one wins, as in gh. development-system pr-review-status <pr> --gate writes the pass: a clean Codex review and, when the base is develop, behavioral evidence ok, nonvisual, waived (the owner's exact words quoted in the PR) or nonfunctional (every changed file is prose documentation). GitHub refuses the merge itself if the head moves after the check. gh api calls to the REST merge route (any host, query, encoding or slash spelling) and GraphQL mergePullRequest/enablePullRequestAutoMerge are blocked, as are a GraphQL body from --input and a GraphQL field read from a file or stdin (key=@file, @-), whatever the GraphQL endpoint's spelling. gh pr merge --disable-auto (cancelling) passes only when its value is effectively true. A gh alias set whose expansion mentions merging, gh alias import, and an existing alias in gh's config.yml that expands to a merge are blocked; URL schemes are matched case-insensitively. Read-only gh and quoted text are not affected.
  • The merge passes, evidence receipts and review records under ~/.development-system/private/merge-gates/**, ~/.development-system/private/evidence/** and ~/.development-system/private/reviews/** (locks included) are protected write targets: only the Development System CLI writes them.
  • The pass records evidence and review; it never authorizes a merge. Main, releases and production still wait for the owner.
  • Known gap: merges outside a shell (the GitHub MCP merge_pull_request tool, the web UI) and files an interpreter writes from its own code do not pass through this hook.

Policy 2.3.0: fewer false positives

  • A read-only gh api with a variable in its endpoint passes sensitive-dynamic-argument: gh api "repos/$R/pulls" (also with -X GET, --paginate, --jq, --template, an Accept header). It must be a GET (no other method, no -f/-F/--input field, no method-override header), every option literal, and the endpoint one double-quoted word after a literal prefix with plain $name/${name} variables, so it cannot split into options or a second endpoint. gh api -X DELETE "repos/$R/…", an unquoted repos/$R/pulls and any other dynamic gh argument stay blocked; literal gh calls are unchanged.

Policy 2.4.0: GNU parallel is inspected like xargs

  • parallel used to be a runner the guard did not open, so parallel touch ::: src/a.test.ts passed every write check. It is now unwrapped: options are skipped, the command runs up to :::/:::+, and literal operands after it are checked as that command's arguments; replacement strings ({}, {.}, {/}, ...) are filled with each operand, so parallel touch out/{.}.test.ts ::: a is a test-file-write. Arguments read from standard input or from :::: files are unknown text, exactly as for xargs, so a writer fed that way blocks. A single quoted command with spaces (parallel 'touch {}' ::: x) is shell text built at run time and is blocked as shell-dynamic-command, as is parallel with no command (parallel ::: ls). Readers pass (parallel node --check ::: a.mjs b.mjs).

Check a decision without installing:

node scripts/command-guard.mjs check --command 'git status --short' --cwd <repo>
node scripts/command-guard.mjs check --tool-json '{"tool_name":"Write","cwd":"<repo>","tool_input":{"file_path":"src/a.test.ts"}}'

Exit 0 means allowed, 2 means blocked; the JSON output names the rule. --no-grants evaluates as if no test-write grant existed; the audit uses it so an active grant cannot make a healthy guard look broken.

Policy 2.5.0: MCP spend guard, spend CLI rule

DS 2.12.0 limits owner stops to five: incremental spend, destruction the owner did not order, new messages to real people, account-security changes and production (merge to main, production deploy). This policy enforces the parts a hook can see.

  • MCP tools (mcp__<server>__<tool>) are checked by scripts/mcp-guard.mjs against references/mcp-policy.json before any field is read as a shell command. Precedence: the named stop list (rule mcp-incremental-spend, mcp-destruction, mcp-message-to-people, mcp-account-security) wins; then generic executors are inspected (posthog exec passes only help|tools|search|info|schema|learn and call [--json] <target> where the target is one of the exact read targets in the policy and is followed by nothing or one JSON object; TikTok tool_execute is stopped, use the dedicated *_get tools; Linear merge_diff is stopped, merge through gh and the merge pass; expect playwright is stopped because its code runs with full Node.js access that no text scan can bound; drive pages with Browse execute, which runs in a restricted realm without process, require, import(), fs or child_process, or with the other expect tools; OpenCode Browse (browse) page tools pass, while secrets_refresh, secrets_run, network capture and settings are account-security stops; Convex run is stopped because a function may mutate, use runOneoffQuery; GitHub merge_pull_request is checked by the same merge pass as gh pr merge); then the exact allow list per governed server; anything else is mcp-unknown. No server is exempt and a name or verb never grants: an invented get_* tool, an unknown server, or a server whose tools were not observed when the policy was written (computer use, browser extensions, IDE, Jev MCP) is stopped. Comments and replies that publish to teammates (Vercel toolbar, Linear comments, reviews and status updates, Notion comments, Mobbin comments, GitHub issue and review comments through MCP) are message stops; the PR review workflow answers review threads with gh api, which this MCP policy does not govern; tools that return secrets (env values, Edge Config tokens, SDK keys, Convex envList/envGet) are account-security stops. Widening the lists is a new DS version, never an agent decision.
  • Interpreter programs are evaluated as before (every string may be a command). Each process call (run(, system(, exec*(, spawn*(, popen*(, posix_spawnp(, shell_exec(, ...) is also read as one command: the literals inside its own parentheses in order, with names the same program binds by name = ... or name += ... expanded (subprocess.run(['git'] + ['reset', '--hard']), base = ['git']; run(base + [...]), [*base, ...]). Every multi-word form is also read without its second word, since execvp/posix_spawnp(file, argv) repeat the file as argv[0]. Strings outside a call stay data. Not seen: values computed at run time (input, files, reflection, encoding); this guard stops accidents, not a deliberate bypass. To write text that only mentions a guarded command (a plan that names the merge command), use the Write tool, a cat heredoc or a commit message; those are data.
  • incremental-spend (command rule): vercel [global options] domains [options] buy|transfer-in and stripe with --live or a live key in its arguments. Test mode and reads pass. Not covered (declared gaps): paid wrangler products, paid EAS builds, spend inside a browser session.
  • The merge gate itself is unchanged: a merge to develop or main still needs --match-head-commit and a fresh pass from development-system pr-review-status <pr> --gate. A merge to main, a release and a production deploy are stop 5: after the gate passes they still wait for the owner's explicit production answer, which a general approval does not give.
node scripts/command-guard.mjs check --tool-json '{"tool_name":"mcp__plugin_vercel_vercel__buy_domain","tool_input":{"name":"x.com"}}'   # exit 2, mcp-incremental-spend
node scripts/command-guard.mjs check --tool-json '{"tool_name":"mcp__plugin_vercel_vercel__list_projects","tool_input":{}}'           # exit 0

Policy 2.6.0: the guard blocks harm, not what it cannot read at a glance

DS 2.13.0. The rules that stop real harm stay as they were: spend, disk destruction, git reset --hard, git clean, git-discard, forced pushes, repository deletion, infrastructure destruction, download-to-shell, fork bombs, destructive Git configuration, test files without a grant, the guard's own configuration, the merge gate and the MCP stops.

  • Retired: tmp-write (writing to /tmp, $TMPDIR and the like passes) and docs-config-write with its grant (AGENTS.md, CLAUDE.md and lint configuration inside a repository are ordinary files, reviewed in the PR). docsConfigNames is empty. The installed instructions (~/.claude/CLAUDE.md, ~/.claude/rules/**, ~/.codex/AGENTS.md) are protectedWriteTargets: only installing a version changes them. Retiring the docs names retired no check that fails closed: contents the guard cannot read (a recursive copy, move or sync from a source it cannot read or too large to walk) are blocked as guard-config-write when a protected file lies below the destination folder written out (cp -R "$S" ~/.codex/) or when the destination cannot be read either (cp -R "$S" "$D"/; a tree the guard can read copied to "$D"/ passes); an archive or a remote transfer into a directory the guard cannot read is blocked when guard configuration lies below the folder written out (tar -xf a.tar -C ~/.claude/"$dir"), and with no folder written out (-C "$dir") it passes only when the guard can list the archive and no member's name can end a protected path; a patch applied in such a directory is judged the same way (patch -d ~/.claude/"$dir" blocks; patch -d "$dir" -p1 < fix.patch passes only when the guard can read the patch and it names no protected path), and Git paths restored there block when one can select guard configuration (git checkout origin/develop .), while a branch switch passes; a relative write under find -execdir is blocked; a find … -delete whose starting point or options the guard cannot read is blocked when its -name/-type tests pass an existing protected file (find "$D" -name settings.json -delete blocks, find "$D" -name '*.tmp' -delete passes); a find … -exec there stands for every protected file whatever its tests ask for, because an entry can be a link with any name that the action writes through (find "$D" -name notes -exec truncate -s 0 {} \; blocks, -exec grep passes); and the words xargs reads from standard input stand for every protected file too (git ls-files | xargs sed -i … blocks, … | xargs grep passes).
  • The guard never takes its own ignorance as permission. A sensitive program (sensitiveCommands) is judged by its subcommand: the forms in readOnlySensitiveSubcommands (gh pr view, gh run list, kubectl get, vercel ls, terraform show, ...), read-only Git subcommands and a read-only gh api pass with any arguments, gh pr view "$n" included. A program with options that write a file or a folder (sensitiveWriteOptions: pulumi --save-plan, --tracing, --profiling; kubectl --output-directory, --cache-dir) is stricter: such an option written out makes the command a write and its file is checked like any write target (pulumi preview --save-plan ~/.codex/config.toml blocks, with or without a variable elsewhere), and a word the guard cannot read passes only where it cannot be that option: after --, as the value of an option listed in sensitiveValueOptions (-n "$ns", --stack "$s"), or starting with written text that is not a dash. Before -- its expansions must be inside double quotes: unquoted, the shell may split the value into several arguments and one can be the option (pulumi preview --stack $s blocks). Every other subcommand, listed or not, changes something and passes only when each word is known: written out, or a variable assigned a plain literal in the same command.
  • Variables are followed through the whole command, not only its leading lines: name=literal assignments, the bodies of if, while, { } and case, and for name in a b c over 1 to 24 written-out values, which is read once per value (for n in 12 13; do gh pr merge "$n" ... is judged as two merges). A value is forgotten when anything could have changed it: an assignment that an &&/|| may skip (one right after || is never kept, since a later && link can run without it: true || B=echo && "$B" …), one made in a pipe, a subshell or the background, read, unset, export, a function definition, eval, a builtin the guard does not model, arithmetic anywhere ((( )), $(( )), a subscript or a substring offset that is not plain numbers such as ${s:D++}, zsh $s[…]), a printf or print -f whose format is not written out, stores with %n, or formats a number from an argument that is not a plain number (zsh reads it as arithmetic), or a loop body that reassigns what an earlier command of the same loop read. A forgotten or never-assigned variable is unknown: rm -rf "$x" blocks, x=~; rm -rf "$x" is judged as rm -rf ~. A value with blanks ("/Applications/Google Chrome.app/...") is read only where the variable expands inside double quotes.
  • A program named by a variable passes only when the variable resolves to a literal in the same command, and the resolved program is judged like any other (B=rm; $B -rf ~ is rm -rf ~). A command string in a variable (C="git reset --hard"; $C), an unassigned variable and a substitution as the program stay dynamic-command-name.
  • A shell or interpreter script written as a quoted heredoc or literal -c text is inspected as text, as before; one read from a pipe, an inherited stream or a variable stays blocked (shell-dynamic-stdin, shell-dynamic-command). A failed inspection still blocks (shell-parse-error): the cases in the 2.12.0 history were real syntax errors that zsh and bash reject too.
  • Multi-word arguments of sed, grep, rg, echo, printf and jq are patterns or text, not commands: sed -i '' 's/a; b/c/' file passes. A word that names a sensitive command or a shell is still evaluated, and sed's e command stays blocked.
  • inertTools (TaskStop, KillShell, KillBash, TaskOutput, BashOutput) carry no command and pass; any other tool without a recognizable command is still malformed-payload.
  • broad-recursive-delete lets through what the agent can make again, with every operand written out or verified: a path strictly inside regenerableDelete.roots (~/.development-system/private/scratch) or a temporary folder, by its written and its physical path, that holds no repository at any depth (a .git entry or a bare repository; a tree the guard cannot read to the end, past 200000 entries, 32 levels or 1.5 s, counts as holding one) and, inside a clone, no uncommitted work; or a folder named in regenerableDelete.names (node_modules, dist, .next, .turbo, ...) that git ignores and that has no tracked file. A glob is accepted only as the last segment below such a root. Home, /, a repository root (a scratch clone included), .., paths outside those roots, tracked paths, xargs rm -rf and operands from a substitution stay blocked.
  • git-branch-delete-force lets through git branch -D when every named branch is reachable from HEAD, develop, main or master (local or origin/), so no commit is lost. A branch merged by squash is not reachable and stays blocked; use git branch -d after fetching, or ask. The question is asked of the repository in the command's directory (or its -C), so the exception ends when anything can point git elsewhere: a GIT_ variable in the environment or named anywhere in the command, --git-dir or another option before the subcommand, a construct that can export a name it does not write out (export, declare, typeset, env, sudo, eval, source, ., set -a), or any expansion at all ($, a backtick), which could spell one of those piece by piece: the exception holds only in a command written out in full.
node scripts/command-guard.mjs check --command 'for n in 1 2; do gh pr view "$n"; done' --cwd <repo>     # exit 0
node scripts/command-guard.mjs check --command 'rm -rf "$x"' --cwd <repo>                                  # exit 2, sensitive-dynamic-argument
node scripts/command-guard.mjs check --command 'x=~; rm -rf "$x"' --cwd <repo>                             # exit 2, broad-recursive-delete

Verify

Audit must prove all of the following:

  • the exact managed Codex and Claude Code hook entries exist alongside pre-existing entries;
  • the installed policy engine matches the current catalogued skill bytes;
  • a harmless command with a redirection (grep -n "x" f 2>/dev/null | head) is allowed;
  • git reset --hard is blocked, and a --tool-json Write to src/a.test.ts is blocked;
  • an MCP buy_domain call is stopped and an MCP list_projects read is allowed;
  • rollback restores the exact prior Codex hooks and Claude Code settings bytes when each file still holds the installed bytes; when a file changed after activation (Claude Code rewrote its settings, or the report gate or orchestration added hooks), it removes only the managed guard entry from that file and rewrites it as 2-space JSON, without touching Factory.

Do not claim T3 Code has an independent hook runtime: each T3 thread inherits the adapter of its Codex or Claude Code provider.

04 同仓库更多 Skills