Skip to content

Agents and LLMsHarness and toolingreference

Running agent git commands without per-command approval prompts

Over 30 days, 205 pi sessions produced 3,833 git and gh approval prompts, about 19 per session. The user accepted 3,829 and denied 4, and the prompts caught no leaks. This page covers what replaced them: scanning gates on the push, an audit log of every mutating git decision, and a rule that background workers never mutate git. The how-to for building the gates is Leak gates for coding agents.

The numbers come from a 30-day replay of 485 pi session files (43,912 tool results, 29,820 bash calls) against the live guard cores, run 2026-10-20 on the author’s Linux dev box. Every figure is measured from that replay or from the source code described inline; asserted claims are labelled as such.

  • Baseline: 3,833 git/gh approval prompts in 30 days across 205 sessions, 4 denials, 0 caught leaks.
  • Tiered gate: a replay of the 3,648 recorded commands dropped them to 496 prompts (-86%).
  • Dangerous-command guard: 212 prompts to 187, with 24 bypasses closed.
  • Pre-push gate: a replay of 909 commits across 6 public repos produced 14 blocks (2 true positives, 5 unconfirmed identifier-shaped refs, 7 false positives).
  • Server pre-receive: a gate on the self-hosted Forgejo instance that --no-verify does not skip, covering repos push-mirrored to public GitHub.
  • Tracking: an audit log plus agent-inventory answer “what did agents leave behind” without a prompt.

A scan of 485 pi session files (2026-09-19 to 2026-10-19) classified every bash command with the same guard cores that would later gate them:

MetricCount
Sessions with gated git/gh commands205 of 485
Gated git/gh commands3,833
Per-session average19
git commit share74%
git push share8%
User denials4
Leaks caught by the prompt0

The four denials were two misclicks (“retry that commit”, “again”), a change-of-mind (“leave it” on a gh api repo edit) and a “check first” on a compound command. The pre-existing hooks (pre-commit reminder, pre-push gitleaks and blocked-term check) had already caught everything the prompt could.

Three leak classes had needed git filter-repo remediation before the study window: a secret in a committed file, internal identifiers in a public repo, and wording that disclosed where content came from.

Anthropic reports that users accept 93% of Claude Code permission prompts, and describes auto mode, a classifier that stands in for the human approver, as the response1. The author’s data matches. The confidential-write guard blocked 662 commits and 317 prose writes in the same 30-day window, and 84% of the blocked commits were re-run byte-identically. The git prompt was approved 3,829 times out of 3,833.

Five patterns from other coding agents, as of October 2026.

A two-tier classifier (a fast single-token filter, then chain-of-thought reasoning on Sonnet 4.6) replaces per-command approval. It gates shell commands, web fetches and filesystem writes outside the project directory. In-project file edits skip it, because version control provides the audit trail. Anthropic reports a 0.4% false-positive rate on real traffic and a 17% false-negative rate on known overeager actions1.

Branch restriction is server-side: the agent can push only to a copilot/* branch or the existing PR (pull request) branch. It cannot push to the default branch, cannot run git push directly (the platform mediates the push), cannot mark its PRs ready for review, and cannot approve or merge. The user who triggered the agent cannot approve the resulting PR. Secret scanning runs at code-generation time (CodeQL, secret scanning, dependency analysis). The agent’s ephemeral VM (virtual machine) sits behind a configurable egress allowlist2 3.

TOML (Tom’s Obvious, Minimal Language) rules combine tool name, command prefix and arguments into allow, deny or ask decisions with a numeric priority. Conseca, an LLM-based security checker, generates and enforces policies dynamically. Trusted-folders mode disables project settings, .env files and MCP (Model Context Protocol) servers in untrusted directories. disableYoloMode can be forced at policy level4.

The default --git-commit-verify was False until at least July 2026 (PR #5377 to change it was still open as of that date)5. Every aider commit therefore ran with --no-verify and skipped every pre-commit hook in the repo: secret scanners, linters, formatters and test runners. Aider’s docs describe the behaviour6 7.

Score 70/100, fail. The audit flagged unsafe execution (subprocess calls), inadequate sandboxing (the agent has root inside the Docker container) and excessive agency (autonomous PR creation without mandatory human review)8.

A prompt that is approved without reading adds nothing a deterministic scan of the pushed bytes cannot do, and a log of what ran records more than the user remembers. The layers, in the order a leak meets them:

confidential-write guard(file write: blocked terms, taint)tiered git gate(allow, prompt or block the command)client pre-push hook(gitleaks, blocked terms, sensitive files;public target adds taint, identifiers, provenance)local-model review(public target, model loaded)Forgejo pre-receive(repos mirrored to public GitHub)GitHub push protection(public repos)
  1. The confidential-write guard blocks blocked terms and, in public-mirrored repos, tainted identifiers at write time, before a commit exists.
  2. The tiered git gate decides whether the command runs, prompts or is blocked.
  3. The pre-push hook scans the exact commits being pushed.
  4. The local-model review runs when the hook finds nothing, the target is public and a model is loaded.
  5. The Forgejo pre-receive hook scans the push again on the server.
  6. GitHub push protection runs on the mirrored push.

Three tiers classify every git and gh command:

TierEffectExampleMechanism
RoutineRuns without a promptgit commit, git merge (including --ff-only), git worktree add, git push without --force, --delete, --mirror, --prune, a +refspec or a push optionPattern match on the canonicalised command, plus the hooks-active check
GatedPrompts the usergit reset --hard, git push --force, git worktree remove --force, git branch -D, gh repo edit, git push -o leak-gate.skip, --no-verifyFalls outside the routine tier: destructive, remote-changing, or a hook, signing or identity bypass
BlockedRefusedAny mutating git/gh in a bg_bash job or a pi -p workerThe agent sees the reason and must take a different path
git/gh commandmutating?outside bg_bash, in asession with a UI?yesrunsnoall segments routine,hooksPath = global hooks?yesblocked:main session onlynoruns, one linein the audit logyesprompt the userno
  1. A command that does not mutate git or gh runs.
  2. A mutating command in bg_bash, or in a session with no UI (a worker), is blocked.
  3. In a session with a UI, a command whose segments are all routine runs, and is logged, if the repo’s effective core.hooksPath is the global hooks directory.
  4. Anything else prompts.

The hooksActiveFor check exists because the global hooks directory holds the pre-push gate. A repo using Husky (which sets .husky) or an unset hooksPath (git’s default .git/hooks) fails the check, and its commands stay gated. If the pre-push gate does not run, the prompt is the only remaining check before a push leaves the machine.

Every mutating git/gh decision (auto, approved, denied, blocked) is appended to an audit log with a timestamp, harness name, session id, working directory, the full command text and the decision (since 2026-10-26).

Before 2026-10-20, any remote on github.com, gitlab.com or codeberg.org counted as public. That flagged 128 local repos as public, while only 12 GitHub repos were. A self-hosted Forgejo instance also push-mirrored repos server-side: a local git remote showed only the Forgejo URL (Uniform Resource Locator), but the content reached public GitHub through a mirror the local git config never saw.

The replacement reads a daily cache, built by a systemd user timer, that lists every public repo key, every known key and the Forgejo-to-GitHub mirror map. A public-forge URL missing from the cache counts as public. With a stale cache (older than 7 days) or no cache, every public-forge URL counts as public.

The gate runs as the repo’s pre-push hook. It scans the exact commits being pushed, not the working tree, so a commit made hours ago and since forgotten is still checked. The rules differ by target.

Every repo, public or private:

  • User-confirmed blocked terms, marked block with the confidential_terms tool. A match blocks the push. For a public target the gate uses every repo’s blocked terms, the set the server enforces.
  • Sensitive filenames: .env, .pem, .p12, .kdbx, id_rsa, .viminfo, .netrc, .git-credentials, credentials JSON/YAML (YAML Ain’t Markup Language) and .ssh/ paths. Exceptions are .env.example, .env.sample, .env.template, .pub files and sops-encrypted content (the sops: header or an ENC[AES256_GCM, prefix).
  • Gitleaks over the pushed range. A finding blocks the push. A missing gitleaks binary blocks a public target and prints a warning for a private one.

Public repos only:

  • Tainted terms: identifier-shaped tokens from pasted text or private sources that entered the agent’s context in the last 30 days. A term already published at the remote is cleared. Tainted terms are hints, not blocks: they are passed to the local-model review, which judges whether any identifies a third party.
  • Identifier shapes: twenty-letter lowercase tokens (the shape of a project reference) and email addresses not on the author’s own domains.
  • Provenance framing: prose that reveals where information came from, meaning a word naming an outside party within one sentence of a word for a channel or event, plus a few fixed phrases. Applied to commit messages and prose files only. Code is exempt, because words like client and account are ordinary technical terms there.

The pre-push gate is a client-side hook, so an agent can skip it with --no-verify. That flag sits in the gated tier, and so does git push -o leak-gate.skip: both need the user’s approval.

When the deterministic gate blocks nothing, the push targets a public repo and llmc (RTX 5090) already has a model loaded, a second pass sends the commit messages and added lines to that model with a classification prompt. It receives the tainted terms as hints and is asked only to flag confidential context: named outside parties, internal-only plans and statements of where information came from. If the answer is leak=true, the push is blocked with the model’s reason printed verbatim.

This layer targets framing a regex cannot match; the deterministic rule only hits sentences built from its fixed word lists. It never cold-starts a model for a push. The prompt is capped at 16,000 characters, and a larger diff is truncated with a note of how many lines were left out. The answer is parsed as a JSON (JavaScript Object Notation) verdict, and the reasoning string shown to the agent contains no line from the diff and no name.

A pre-receive hook runs on the self-hosted Forgejo instance in the repos that are push-mirrored to public GitHub, plus a private canary repo. As of 2026-10-20 that is 10 public-mirrored repos. --no-verify and other client flags do not skip it. The one skip is the push option -o leak-gate.skip, which the tier gate holds for user approval.

The hook runs gitleaks over the pushed range with the server’s own config (a repo’s .gitleaks.toml or .gitleaksignore is not read, because a bare repo has no worktree) and checks every term from the user’s blocked-terms list. It fails closed: a scanner error, a 120 s timeout or a missing gitleaks binary blocks the push. The rejection message never prints the blocked term.

The terms reach the server through leak-gate-terms-sync, a script that copies the union of the user’s blocked terms into the stack’s SOPS-encrypted (Secrets OPerationS) config. It is run by hand, followed by a push of the Forgejo stack so composer redeploys the seed.

GitHub push protection is enabled on all 12 public repos (as of 2026-10-20). It blocks a push that contains a secret matching one of its high-confidence patterns. The server pre-receive runs before the mirror push, so a block there means GitHub never sees the push.

A background pi -p worker or a bg_bash command cannot mutate git. The gate blocks every mutating git/gh command in a session with no UI: commit, push, merge, worktree add, branch delete. The worker edits files in a worktree the main session created, and the main session commits and pushes.

The tiers first applied to headless workers too, which let them commit and push. That was reversed on 2026-10-20, so every commit and push comes from the session the user is watching.

An unanswered prompt counts as a denial. On 2026-11-05 a session’s git worktree remove --force and git branch -D cleanup ran while the user was away; the audit log records both as denied, and four empty worktrees stayed until the next session approved the same command. Cleanup that should not wait for a human uses the routine forms: git worktree remove on a clean worktree and git branch -d on a merged or unmoved branch.

The prompt’s remaining function was telling the user what the agent had done. Four mechanisms replace it:

MechanismWhat it recordsDetail
Audit logEvery mutating git/gh decisionJSON lines, append-only: timestamp, harness name, session id, working directory, full command text, decision
agent-inventoryGit state that outlives a sessionRead-only script over every local repo: extra worktrees, unmerged branches, unpushed commits, stashes, dirty trees. Each item carries age and details, and the session that created it when the audit log has a match. Flags: --session <id>, --stale 7 (idle a week or more), --json
Session reportThe open git state of the current sessionAfter each agent turn, a notification to the user listing the worktrees, branches, unpushed commits and dirty trees the session left open, shown only when the set changes. A second log records every file the agent writes through a file tool, so a repo it only wrote into is covered too, and files it wrote but left uncommitted also go back to the model as a follow-up message (at most three per session) asking it to commit them or say why not
Naming conventionWho owns a worktree<repo>/.worktrees/<card>-<slug> on branch agent/<card>-<slug>, so git worktree list shows which are agent-owned and which kanban card they belong to
  • Deliberate exfiltration by a compromised model. The pre-push gate and the server pre-receive catch secrets and blocked terms. They do not catch a model that encodes data into variable names or comment phrasing, and no coding-agent harness addresses that today.
  • A worker that finds another way to mutate git. The blocked tier covers the known git and gh subcommands. A worker could write a shell script that calls git commit through an alias or an indirect path. The rule is a policy backstop, not a sandbox.
  • Pre-commit hooks as a security boundary. The pre-commit hook here is a non-blocking reminder that prints what the agent is about to commit. The pre-push gate is the first blocking layer.
  • Files the agent writes but never commits. The confidential-write guard screens every write for blocked terms and tainted identifiers (sensitive filenames are first caught by the pre-push gate); it is described in Guard extensions that enforce prose and process rules in a coding agent.

The replay numbers (30 days, 485 sessions) with each gate applied:

GateBeforeAfterDelta
Git/gh approval prompts3,648496-3,152 (-86%)
Dangerous-command prompts212187-25 (-12%, 24 bypasses closed)
Pre-push gate (909 public commits replayed)-14 blocks-
Blocked: true positives-2-
Blocked: identifier-shaped refs, unconfirmed-5-
Blocked: provenance framing, false positives-7-
Server pre-receive, canary repo-2 blocked (canary terms)-
Server pre-receive, lexicanum pushes (2026-10-20)-2 blocked (a term blocked only in a sibling repo)-

The pre-push gate blocked 14 of 909 commits (1.5%). The 2 true positives were reworded afterwards. The 7 false positives came from the provenance scanner’s generic-wording matches. The 5 identifier-shaped refs sit in test fixtures and plan docs, and it is unconfirmed whether any names a real internal project. After the two lexicanum pushes, the client gate took the union of every repo’s blocked terms for public targets.

ClaimHow it was checkedSource
3,833 git/gh prompts in 30 days (measured); 3,648 replayed through tiered gatePython classifier over 485 session JSONL (JSON Lines) files (43,912 tool results)Private measurement notes: 00-baseline-and-constraints.md
74% git commit, 8% git pushSame replay, subcommand histogramPrivate measurement notes: 00-baseline-and-constraints.md
4 denials, 0 leak catchesSame replay, user-message follow-up classifierPrivate measurement notes: 00-baseline-and-constraints.md
84% identical re-runs after confidential-write blockReplay, plain string comparison of the re-issued commandPrivate measurement notes: 00-baseline-and-constraints.md
Claude Code 93% acceptance rate; 0.4% false positives, 17% false negativesAnthropic auto mode blog post (2026-03-25)https://www.anthropic.com/engineering/claude-code-auto-mode
Aider --no-verify defaultAider docs + PR #5377 (open as of July 2026)https://aider.chat/docs/git.html ; https://github.com/Aider-AI/aider/pull/5377
Copilot branch restriction, cannot push to mainGitHub docs (risks and mitigations)https://docs.github.com/en/copilot/concepts/security-governance-and-network-settings/risks-and-mitigations
Pre-push replay: 909 commits across 6 public repos, 14 blocks (2 TP (true positive), 5 unconfirmed, 7 FP (false positive))Re-scan of public-repo push history against the pre-push gate corePrivate measurement notes: 00-baseline-and-constraints.md
Tiered gate replay: 3,648 -> 496 (-86%)Replay of the 30-day command stream against the tier-matcherPrivate measurement notes: 00-baseline-and-constraints.md
rm-guard: 212 -> 187, 24 bypasses closedReplay of bash calls against the dangerous-command guard core after bypass fixesPrivate measurement notes: 00-baseline-and-constraints.md
128 repos flagged public, 12 actually publicRepository listing + visibility-cache comparisonPrivate measurement notes: 00-baseline-and-constraints.md
Server pre-receive blocks canary termsPush of a commit containing the canary term to the canary repo over Forgejo API (bypasses client hooks)Forgejo compose stack config, leak gate section
LLM (large language model) review in the source code blocks on leak=true (no replay was ever run)Read from .config/git/hooks/lib/prepush-gate.ts llmReview() + main: “BLOCKED - the local model flagged”Source: prepush-gate.ts
  1. Anthropic, “How we built Claude Code auto mode: a safer way to skip permissions,” Anthropic Engineering Blog, 2026-03-25. https://www.anthropic.com/engineering/claude-code-auto-mode ↩ ↩2

  2. GitHub, “Risks and mitigations for GitHub Copilot cloud agent,” GitHub Docs. https://docs.github.com/en/copilot/concepts/security-governance-and-network-settings/risks-and-mitigations ↩

  3. Rahul Zhade, “How GitHub’s agentic security principles make our AI agents as secure as possible,” GitHub Blog, 2025-11-25. https://github.blog/ai-and-ml/github-copilot/how-githubs-agentic-security-principles-make-our-ai-agents-as-secure-as-possible/ ↩

  4. Google, “Policy engine,” Gemini CLI Docs. https://geminicli.com/docs/reference/policy-engine/ ↩

  5. Sarthak816, “fix: enable git pre-commit hooks by default (—git-commit-verify),” Aider-AI/aider PR #5377, 2026-07-01. https://github.com/Aider-AI/aider/pull/5377 ↩

  6. Aider, “Git integration,” Aider Docs. https://aider.chat/docs/git.html ↩

  7. “Default runtime commits bypass pre-commit hooks via —no-verify,” Aider-AI/aider issue #5057, 2026-04-21. https://github.com/Aider-AI/aider/issues/5057 ↩

  8. “OWASP Agentic AI Security Assessment for OpenHands,” OpenHands/OpenHands issue #13378, 2026-03-13. https://github.com/OpenHands/OpenHands/issues/13378 ↩