About Portfolio Cases Services Blog Contact 🎙 Talk to AI
EN DE RU
🎙 Talk to AI
November 16, 2026 · 5 min read

When 5 AI agents push code into one repo, chaos starts on day two: how agent source control restores control

I’m Denis Shokhirev, an Agentic AI Systems Architect based in Freiburg im Breisgau, Germany, and at DennisCraft AI Studio I ship production AI systems for DACH B2B clients on Claude, Supabase, n8n, Doppler, and self-hosted Postgres. The ugly moment in multi-agent coding isn’t when one agent writes bad code; it’s when five agents write acceptable code into the same repository, and by day two nobody can explain who broke a migration, who removed a guardrail, or why a staging secret ended up in a c

Denis Shokhirev
Denis Shokhirev
Agentic AI Systems Architect
Telegram LinkedIn

I’m Denis Shokhirev, an Agentic AI Systems Architect based in Freiburg im Breisgau, Germany, and at DennisCraft AI Studio I ship production AI systems for DACH B2B clients on Claude, Supabase, n8n, Doppler, and self-hosted Postgres. The ugly moment in multi-agent coding isn’t when one agent writes bad code; it’s when five agents write acceptable code into the same repository, and by day two nobody can explain who broke a migration, who removed a guardrail, or why a staging secret ended up in a config file.

This is not a Git problem by itself. It’s a mismatch between human-oriented source control and agent-driven throughput. Traditional Git workflows assume a developer who owns context, intent, and accountability. Agent systems create a stream of small, frequent, partially dependent changes from multiple autonomous actors. If you do not add branch rules, path restrictions, policy gates, and provenance tracking, your repo turns into an event log with no operational control.

Why day two is where things break

Day one looks efficient. One agent scaffolds endpoints, another writes tests, a third updates docs, a fourth edits SQL, and a fifth tweaks an n8n workflow. The demo feels smooth because each task is narrow and the initial repo state is shared. Day two introduces drift. One agent works on an old branch base, another fixes lint and touches imports globally, another regenerates a file that a different agent already modified, and a fourth slips a token into code because the prompt never defined a secret-handling rule.

The failure modes repeat

Across recent deployments, I see the same four classes of issues. First, collisions in shared artifacts: dependency manifests, migrations, schema files, API contracts. Second, stale context: the agent solves the right task against the wrong repo state. Third, policy violations: hardcoded credentials, unparameterized SQL, unsafe subprocess usage, or dependency drift. Fourth, blurred accountability: there is a commit SHA, but no clean answer to which agent produced it, under what task, with which model, and after which checks.

OWASP’s Top 10 for LLM Applications highlights insecure output handling and excessive agency as practical risks in LLM systems, not abstract theory. That maps directly to AI-generated code flowing into CI/CD. If the output can trigger file changes, shell calls, database actions, or merges, your control model matters as much as the model quality. Source: OWASP GenAI Project, 2025, https://owasp.org/www-project-top-10-for-large-language-model-applications/

What “agent source control” actually means

I am not talking about a new branded platform. I mean a set of operating rules on top of normal Git. An agent should not have the same repository freedom as a staff engineer. It should operate in a constrained lane: dedicated branch, explicit file scope, mandatory checks, and traceable metadata for every proposed change.

LayerHuman developerAI agent
IdentityName and emailagent_id, task_id, model, prompt hash
Branchingfeature/*agent/{agent_id}/{task_id}
PermissionsBroad repo accessPath allowlist
ChecksReview + CIReview + CI + policy gates
Rollbackgit revertgit revert + agent disable switch

The mental model is simple: an agent does not “commit code,” it proposes a change. That proposed change should go through equal or stricter control than code from a junior developer. If an agent can push directly to main, you do not have automation discipline; you have removed control and renamed it autonomy.

A minimum setup that holds in production

1. Isolate branches and file boundaries

Give each agent its own branch and a path allowlist. A documentation agent should not edit database migrations. A database-focused agent should not modify workflow automation without separate authorization. This reduces conflict surface and makes review readable.

#!/usr/bin/env bash
set -euo pipefail

AGENT_ID="$1"
TASK_ID="$2"

git fetch origin main
git checkout -B "agent/${AGENT_ID}/${TASK_ID}" origin/main

printf "agent_id=%s\n" "$AGENT_ID" > .agent_meta
printf "task_id=%s\n" "$TASK_ID" >> .agent_meta
printf "created_at=%s\n" "$(date -u +%FT%TZ)" >> .agent_meta

2. Record provenance outside the commit message

Git history is not enough when you need incident analysis. I store agent metadata in Postgres so I can answer basic operational questions quickly: which agent produced the commit, which task triggered it, which model was used, and what branch state existed at creation time.

import os
import psycopg
from datetime import datetime, timezone

conn = psycopg.connect(os.environ["DATABASE_URL"])
with conn, conn.cursor() as cur:
    cur.execute(
        """
        insert into agent_commits
        (agent_id, task_id, commit_sha, branch, model, created_at)
        values (%s, %s, %s, %s, %s, %s)
        """,
        (
            os.environ["AGENT_ID"],
            os.environ["TASK_ID"],
            os.environ["COMMIT_SHA"],
            os.environ["BRANCH_NAME"],
            os.environ["MODEL_NAME"],
            datetime.now(timezone.utc),
        ),
    )

3. Put policy gates before merge, not after an incident

For Python-heavy stacks, a practical baseline is semgrep for code patterns, bandit for common security smells, and gitleaks for secrets. These tools do not replace review, but they remove obvious failure cases before staging.

name: agent-pr-checks
on: [pull_request]
jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: returntocorp/semgrep-action@v1
      - run: pip install bandit
      - run: bandit -r src -q
      - uses: gitleaks/gitleaks-action@v2

Why this matters more in regulated European markets

If you ship AI systems into fintech, logistics, or industrial automation in DACH, repository hygiene becomes an auditability problem. When a client asks who changed a classification rule, a document-processing workflow, or a database access path, “the agent did it” is not an acceptable operating answer.

The controls I care about are traceability, reproducibility, and revocability. Traceability means you can reconstruct the path from task to merge. Reproducibility means you can rerun the same checks on the same file set. Revocability means you can disable one agent or one permission set quickly without freezing the entire engineering system.

Anthropic’s documentation for Claude and tool use repeatedly emphasizes permissioning, controlled tool access, and human oversight for agentic workflows. That lines up with what I see in production. An agent with wide tool access and no source-control discipline will often make locally sensible but systemically risky edits. Source: Anthropic Docs, 2026, https://docs.anthropic.com/

The operating model I recommend

I do not recommend starting with a fully autonomous “AI dev team.” A stable setup is more boring and more useful. One or two agents generate code and tests. Another agent reviews diffs for policy violations. Merge into a protected branch stays with a human owner or a tightly constrained service account after checks pass.

RoleAllowed to doNot allowed to do
Code agentWrite scoped code changesMerge directly to main
Review agentInspect diff and policy issuesChange business logic
Human ownerAccept merge riskDebug blind after the fact

Yes, this is slower than letting every agent write directly into the repo. In production, I will choose controlled speed over a flashy autonomy demo almost every time, especially where customer data, financial processes, or ERP integrations are involved.

FAQ

Can I let an agent push straight to main if tests are green?

I would not do that without path restrictions and additional policy gates. Green tests do not catch secrets, unsafe coding patterns, or broken implicit invariants.

Is one human code review enough?

Not if you have multiple agents and high change velocity. Human review should inspect already filtered diffs, not act as the only barrier before merge.

Do I really need separate agent logs if I already have Git history?

Yes. Git shows the result, but not always the decision context: task ID, model, prompt hash, tools used, sequence of actions, and check outcomes.

Which checks should I add first?

Start with protected branches, gitleaks, semgrep, and bandit. That baseline is cheap to add and catches a meaningful share of preventable issues quickly.

Is this only for large teams?

No. Even two humans with two or three active agents can create repo chaos because change throughput grows faster than human understanding.

Which stage in your LLM engineering pipeline catches the most issues in production right now: static analysis, diff review, staging validation, or runtime behavior? I’d genuinely like to compare that with what I’m seeing across DACH client systems.
I run a free 30-minute stack audit for DACH founders building AI in regulated markets. DM me on LinkedIn or write to @ger_dennis_ai.

For your business

I build agents like this for businesses in Germany and the EU.

Tell me in two sentences what eats your team’s time – reply within 24 hours.

Custom AI agents (German page) →
Continue reading
How not to drown in MCP chaos: 50+ remote MCP servers already exist, but without curation your production agent becomes a security hole
Your AI agent breaks on mobile UI: how to connect iOS and Android via MCP and run real workflows instead of screenshot demos
One stolen key put 5,000 developers at risk: what the Cursor breach and trojanized Claude Code extension change for AI IDE security
Your customers ask ChatGPT for a tradesman. Does it name your business
All articles →
Where this is applied
Services — what we build
Talk to the voice agent
Case studies
Ready to build?

Turn your process into an AI system

Production quality. DACH B2B focus.

Start a project → ← All articles