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-verifydoes not skip, covering repos push-mirrored to public GitHub. - Tracking: an audit log plus
agent-inventoryanswer “what did agents leave behind” without a prompt.
The baseline: 30 days of approval prompts
Section titled “The baseline: 30 days of approval prompts”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:
| Metric | Count |
|---|---|
| Sessions with gated git/gh commands | 205 of 485 |
| Gated git/gh commands | 3,833 |
| Per-session average | 19 |
git commit share | 74% |
git push share | 8% |
| User denials | 4 |
| Leaks caught by the prompt | 0 |
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.
Approval fatigue
Section titled “Approval fatigue”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.
What peers do
Section titled “What peers do”Five patterns from other coding agents, as of October 2026.
Claude Code auto mode
Section titled “Claude Code auto mode”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.
GitHub Copilot coding agent
Section titled “GitHub Copilot coding agent”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.
Gemini CLI policy engine
Section titled “Gemini CLI policy engine”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.
Aider auto-commit
Section titled “Aider auto-commit”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.
OpenHands OWASP audit
Section titled “OpenHands OWASP audit”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.
The design: gates instead of prompts
Section titled “The design: gates instead of prompts”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:
- The confidential-write guard blocks blocked terms and, in public-mirrored repos, tainted identifiers at write time, before a commit exists.
- The tiered git gate decides whether the command runs, prompts or is blocked.
- The pre-push hook scans the exact commits being pushed.
- The local-model review runs when the hook finds nothing, the target is public and a model is loaded.
- The Forgejo pre-receive hook scans the push again on the server.
- GitHub push protection runs on the mirrored push.
The tiered git gate
Section titled “The tiered git gate”Three tiers classify every git and gh command:
| Tier | Effect | Example | Mechanism |
|---|---|---|---|
| Routine | Runs without a prompt | git commit, git merge (including --ff-only), git worktree add, git push without --force, --delete, --mirror, --prune, a +refspec or a push option | Pattern match on the canonicalised command, plus the hooks-active check |
| Gated | Prompts the user | git reset --hard, git push --force, git worktree remove --force, git branch -D, gh repo edit, git push -o leak-gate.skip, --no-verify | Falls outside the routine tier: destructive, remote-changing, or a hook, signing or identity bypass |
| Blocked | Refused | Any mutating git/gh in a bg_bash job or a pi -p worker | The agent sees the reason and must take a different path |
- A command that does not mutate git or gh runs.
- A mutating command in
bg_bash, or in a session with no UI (a worker), is blocked. - In a session with a UI, a command whose segments are all routine runs, and is logged, if the repo’s effective
core.hooksPathis the global hooks directory. - 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).
The visibility map
Section titled “The visibility map”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 pre-push gate
Section titled “The pre-push gate”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
blockwith theconfidential_termstool. 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,.pubfiles and sops-encrypted content (thesops:header or anENC[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
clientandaccountare 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.
The local-model review
Section titled “The local-model review”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.
The server pre-receive
Section titled “The server pre-receive”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
Section titled “GitHub push protection”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.
The main-session-only rule
Section titled “The main-session-only rule”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.
Tracking: what replaces the prompt
Section titled “Tracking: what replaces the prompt”The prompt’s remaining function was telling the user what the agent had done. Four mechanisms replace it:
| Mechanism | What it records | Detail |
|---|---|---|
| Audit log | Every mutating git/gh decision | JSON lines, append-only: timestamp, harness name, session id, working directory, full command text, decision |
agent-inventory | Git state that outlives a session | Read-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 report | The open git state of the current session | After 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 convention | Who 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 |
What is not covered
Section titled “What is not covered”- 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 committhrough 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.
Measured results
Section titled “Measured results”The replay numbers (30 days, 485 sessions) with each gate applied:
| Gate | Before | After | Delta |
|---|---|---|---|
| Git/gh approval prompts | 3,648 | 496 | -3,152 (-86%) |
| Dangerous-command prompts | 212 | 187 | -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.
Evidence
Section titled “Evidence”| Claim | How it was checked | Source |
|---|---|---|
| 3,833 git/gh prompts in 30 days (measured); 3,648 replayed through tiered gate | Python 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 push | Same replay, subcommand histogram | Private measurement notes: 00-baseline-and-constraints.md |
| 4 denials, 0 leak catches | Same replay, user-message follow-up classifier | Private measurement notes: 00-baseline-and-constraints.md |
| 84% identical re-runs after confidential-write block | Replay, plain string comparison of the re-issued command | Private measurement notes: 00-baseline-and-constraints.md |
| Claude Code 93% acceptance rate; 0.4% false positives, 17% false negatives | Anthropic auto mode blog post (2026-03-25) | https://www.anthropic.com/engineering/claude-code-auto-mode |
Aider --no-verify default | Aider 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 main | GitHub 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 core | Private measurement notes: 00-baseline-and-constraints.md |
| Tiered gate replay: 3,648 -> 496 (-86%) | Replay of the 30-day command stream against the tier-matcher | Private measurement notes: 00-baseline-and-constraints.md |
| rm-guard: 212 -> 187, 24 bypasses closed | Replay of bash calls against the dangerous-command guard core after bypass fixes | Private measurement notes: 00-baseline-and-constraints.md |
| 128 repos flagged public, 12 actually public | Repository listing + visibility-cache comparison | Private measurement notes: 00-baseline-and-constraints.md |
| Server pre-receive blocks canary terms | Push 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 |
Related docs
Section titled “Related docs”- Guard extensions that enforce prose and process rules in a coding agent - the nine guards, the git gate among them
- Keeping credentials out of coding-agent transcripts - the secret-output guard that complements the leak gate
References
Section titled “References”-
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
-
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 ↩
-
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/ ↩
-
Google, “Policy engine,” Gemini CLI Docs. https://geminicli.com/docs/reference/policy-engine/ ↩
-
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 ↩
-
Aider, “Git integration,” Aider Docs. https://aider.chat/docs/git.html ↩
-
“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 ↩
-
“OWASP Agentic AI Security Assessment for OpenHands,” OpenHands/OpenHands issue #13378, 2026-03-13. https://github.com/OpenHands/OpenHands/issues/13378 ↩