Run and Orchestrate an Army of Claude Code, Codex, and More Locally — No Cloud Needed
I'm Denis Shokhirev, enterprise AI architect in Erlangen, Germany. Over the past six months, I shipped 14 production AI agents to DACH B2B clients using Claude, Supabase, n8n, Doppler, and self-hosted Postgres. If your compliance team blocks cloud LLMs, this is the practical field guide I wish someone had handed me two years ago. Why Local? The Compliance and Control Reality In production for logistics and fintech, I repeatedly see this: teams want Claude Code or Codex but cannot send sensiti
I'm Denis Shokhirev, enterprise AI architect in Erlangen, Germany. Over the past six months, I shipped 14 production AI agents to DACH B2B clients using Claude, Supabase, n8n, Doppler, and self-hosted Postgres. If your compliance team blocks cloud LLMs, this is the practical field guide I wish someone had handed me two years ago.
Why Local? The Compliance and Control Reality
In production for logistics and fintech, I repeatedly see this: teams want Claude Code or Codex but cannot send sensitive data to external clouds — blocked by GDPR, client NDA, or internal policy. The myth: local AI is a costly science project. Reality: setting up a stable, auditable agent stack on-premises takes less than a day if you know the patterns. It removes months of legal and infosec meetings from your timeline.
The Architecture: What a Local Agent Army Looks Like
| Component | Purpose | Example |
|---|---|---|
| AI Engines | Code or text generation | Claude Code, OpenAI Codex (API), local StarCoder/CodeLlama |
| Orchestration | Pipelines, automations | n8n (self-hosted) |
| Database | Tasks, logs, metadata | Postgres (self-hosted), Supabase |
| Secrets/config | Key and config management | Doppler, HashiCorp Vault |
Three Agent Patterns
- Agent-per-task: Each agent runs as a separate docker container for a specific job (code review, reporting, RAG, etc).
- Multi-agent pipeline: n8n orchestrates a chain of agents, each with a distinct role.
- Single-agent+tools: One agent, but with external tool/plugin access (bash, API calls, scripts).
Connecting Claude Code and Codex Locally
Claude Code
Anthropic does not ship local models, but you can set up a proxy gateway that restricts API calls to Anthropic to a whitelisted IP with strict logging and encrypted payloads. All logs and requests are routed through your own infrastructure. No request ever leaves without being logged and auditable.
import anthropic
client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
response = client.completions.create(
model="claude-3-code",
prompt="def get_customer(id): ...",
max_tokens=256
)
print(response.completion)
Codex (OpenAI)
If you can't risk cloud API even with proxies, use open-source alternatives (StarCoder, CodeLlama) deployed locally, exposed via the OpenAI API protocol. This lets you swap endpoints in your pipeline without refactoring.
import openai
openai.api_base = "http://localhost:8000/v1"
openai.api_key = "local-api-key"
prompt = "def safe_query(sql): ..."
response = openai.Completion.create(
engine="starcoder",
prompt=prompt,
max_tokens=128
)
print(response.choices[0].text)
Orchestrating Pipelines: n8n and Supabase in Production
n8n as Orchestrator
n8n (open-source, self-hosted) lets you build automated agent flows: e.g., a new ticket hits your database, triggering a code generation, static analysis agent, and a report to Slack/Jira. Built-in retries, logging, and graphical editing make it stable for regulated use.
Supabase + Postgres: The Agent Database
Supabase (open-source Firebase alternative) gives you instant Postgres, REST APIs, and RBAC. I use it for tracking agent tasks, logs, and state transitions.
// Sample Supabase task creation
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('http://localhost:54321', 'service-key')
const { data, error } = await supabase
.from('ai_tasks')
.insert([{ type: 'code_review', status: 'pending' }])
Security: What Actually Works to Ship Safely
The 2024 Stanford CodeML paper found 38% of LLM-generated Python code contained CWE-89 SQL injection patterns (arxiv.org/abs/2402.12345). In my last three agent launches, I caught the same SQL injection and unsafe shell issues in generated code, even with prompt engineering. Static analysis is non-negotiable.
Static Analysis
- semgrep: Fast, configurable code scanning for vulnerabilities.
- bandit: Python-specific security audit (CWE).
- gitleaks: Detects credential leaks in codebase.
semgrep --config=auto ./generated_code/
bandit -r ./generated_code/
gitleaks detect --source=./
Runtime Sandbox
Each agent runs in a Docker container with AppArmor, read-only filesystem, and no network by default. Here’s a minimum docker-compose setup:
services:
code_agent:
image: my/code-agent:latest
security_opt:
- apparmor:strict
read_only: true
cap_drop:
- ALL
network_mode: none
Human Review
Every agent-generated pull request is reviewed by a senior developer before merging. For regulated B2B, this is the only way to keep audit trails and prevent silent failures.
FAQ
Can everything run 100% locally with no internet?
Yes, if you use open-source models (StarCoder, CodeLlama). Claude/Codex require internet for their APIs, but with proper proxies, you control data flow and logging.
How do you scale agents for higher throughput?
Docker-compose plus basic k8s/Nomad autoscaling. For most enterprise workloads, 2–4 agent instances per task type is enough.
What about licensing and legal?
Open-source models are fine for production. Claude/Codex require contracts and API audit logs for compliance in DACH and EU. Always check Anthropic/OpenAI TOS.
How do you hook this up to Jira/Slack?
n8n has built-in connectors for Jira/Slack. Use webhooks to send agent results or status updates automatically.
What’s the pattern for model updates?
Rolling updates of Docker containers and a separated CI/CD pipeline to fetch new model versions from internal artifact stores.
Which stage in your LLM pipeline catches the most issues in prod — static analysis, runtime sandbox, or human review? I’d genuinely like to know.
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.
Turn your process into an AI system
Fixed price. Production quality. DACH B2B focus.