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 using Claude, Supabase, n8n, Doppler, and self-hosted Postgres. The failure mode I worry about most is not a broken build; it’s a clean-looking AI-generated diff that passes tests, gets merged fast, and quietly inserts a security or data-integrity problem into production.
I see this pattern in real agentic systems, not toy demos. When Claude Code or SDK-driven agents touch integration code, database access layers, or workflow logic, the output is often plausible enough to lower human suspicion. That is exactly why AI-generated code needs a different audit path than ordinary teammate code: not because it is always worse, but because it scales repeated mistakes faster than a human does.
The real risk is repeatability, not just correctness
Engineers usually review AI-generated changes as if the main question were “Does this compile?” In production, the harder question is “What bad pattern did the model reproduce three times in this branch?” Across recent client work, I keep seeing the same classes of defects: string-built SQL, missing authorization checks on internal endpoints, broad exception handling, and secrets drifting into code or config.
Why this happens
Models optimize for likely continuations. They do not preserve your operational invariants unless those invariants are made explicit in code, tests, or review gates. If your repository contains one bad example of raw SQL or loose subprocess execution, the model may spread that pattern across a whole feature.
Why teams miss it
Small diffs feel low risk. That’s misleading. Ten changed lines in a Postgres access function can carry more production risk than 200 lines of UI code. AI assistants also produce well-formatted, readable patches, which makes reviewers over-trust them.
Audit by risk surface, not by authorship
I do not treat AI code as “special” in a philosophical sense. I treat it as a source of high-throughput changes that need controls mapped to the surface they touch. For regulated European B2B systems, that framing works much better than generic policy language.
| Layer | Typical failure | What to verify | Useful control |
|---|---|---|---|
| SQL / Postgres | Injection, overly broad writes | Parameterized queries, roles, migrations | semgrep, manual review |
| Python backend | Unsafe subprocess, broad except | CWE patterns, error handling | bandit, semgrep |
| Secrets / CI | Credential leaks | Repo history, env handling | gitleaks, Doppler |
| n8n workflows | Duplicate side effects, weak boundaries | Idempotency, retries, credentials | staging replay, manual review |
OWASP remains a useful frame here. The OWASP Top 10 for LLM Applications, 2025, highlights risks around insecure tool use and data handling in LLM-enabled systems: https://genai.owasp.org/. That aligns with what I see in production. The issue is rarely that the model writes obviously broken code. The issue is that it writes code that looks acceptable while violating security or operations assumptions.
A minimum pre-merge gate that actually helps
If AI is generating code every week, you need executable checks in CI. A Notion page saying “please review carefully” is not a control. My default minimum for Python-heavy stacks is simple: static analysis, secret scanning, tests, and a hard rule that database-access changes require human review.
#!/usr/bin/env bash
set -euo pipefail
echo "Run semgrep rules"
semgrep --config=p/owasp-top-ten --error .
echo "Run Python checks"
bandit -r app -x tests
echo "Scan for leaked secrets"
gitleaks detect --source . --no-banner
echo "Run test suite"
pytest -q
This catches a meaningful class of repeated mistakes. The important part is tuning the rules to your codebase. Look for raw SQL construction, subprocess usage, file-system access, unvalidated webhook payloads, and direct calls to internal APIs without authorization checks.
Safe database access should be boring
import psycopg
def get_account(conn: psycopg.Connection, account_id: int):
with conn.cursor() as cur:
cur.execute(
"SELECT id, status FROM accounts WHERE id = %s",
(account_id,)
)
return cur.fetchone()
def update_status(conn: psycopg.Connection, account_id: int, status: str):
with conn.cursor() as cur:
cur.execute(
"UPDATE accounts SET status = %s WHERE id = %s",
(status, account_id)
)
conn.commit()
That code is intentionally boring. Production-safe data access should be boring. The danger with AI assistants is not that they cannot produce this pattern; it is that they may switch to an f-string or string concatenation if they see it nearby in the repository.
Static analysis is necessary, but not enough
Static checks catch form. They do not catch business impact. After CI gates, I run staging replay against production-like data and inspect invariants: which tables changed, which external calls fired, what credentials were used, and whether retries create duplicate effects.
version: "3.9"
services:
app:
image: myapp:staging
environment:
DATABASE_URL: ${DATABASE_URL}
DOPPLER_TOKEN: ${DOPPLER_TOKEN}
command: ["python", "scripts/replay_jobs.py"]
postgres:
image: postgres:16
environment:
POSTGRES_PASSWORD: example
This matters even more for n8n flows and multi-agent workflows. The defect often is not in a single step; it is in the chain of side effects after a retry, timeout, or partial failure. A flow that “works” once in testing may still be unsafe if it can double-write customer data or call the same external API twice.
Use vendor guidance, but keep your SDLC discipline
Anthropic’s documentation for Claude and tool use repeatedly points teams toward constrained actions, testing, and human oversight for operations that affect external systems. See Anthropic Docs, 2024–2025: https://docs.anthropic.com/ . OpenAI’s cookbook also consistently frames code generation as something to wrap with evaluation and verification patterns rather than trust by default: https://cookbook.openai.com/ .
That matches my field experience. AI coding tools do not replace a secure SDLC. They raise the throughput of code changes, which increases the cost of weak review. If your agent writes to Postgres, handles customer data, or triggers money-moving or logistics actions, treat the model like a very fast junior engineer with no native sense of consequence.
A one-week rollout plan
If your process is still informal, you can improve it quickly:
- Mark AI-generated commits, files, or PR sections.
- Make semgrep, bandit, and gitleaks mandatory in CI.
- Require manual review for AI-touched data access and auth logic.
- Replay workflow changes in staging with production-like inputs.
- Turn your last 10 defects into explicit detection rules or review questions.
This will not make AI-generated code perfect. It will make failures easier to predict, detect, and contain before production, which is the standard that matters.
FAQ
Should every AI-generated change be labeled?
Yes, if AI-assisted coding is frequent. Without labeling, you lose the ability to measure defect patterns and improve the controls that matter.
Are unit tests enough?
No. Unit tests are useful for logic regressions, but weak at finding leaked secrets, unsafe SQL patterns, authorization drift, or duplicate side effects in workflows.
Is Claude Code the problem?
No. The issue is not one tool. The issue is using AI-generated changes without controls matched to the risk of the code path being modified.
What matters more first: semgrep or staging replay?
If you can only add one quickly, start with semgrep plus gitleaks because they are fast and cheap. For workflows with external side effects, staging replay should come immediately after.
How do you audit n8n changes?
I focus on credentials, idempotency, retries, and traceability across nodes. With n8n, manual review is often more valuable than pretending everything can be solved with generic automation.
Which stage in your LLM pipeline catches the most issues before production: static analysis, staging replay, runtime sandboxing, or human review on high-risk diffs? I’d genuinely like to compare that with what I’m seeing in DACH client systems.
I run a free 30-min stack audit for DACH founders building AI in regulated markets. DM me on LinkedIn or write to @ger_dennis_ai.
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.
Turn your process into an AI system
Production quality. DACH B2B focus.