Test AI-Generated Code
In this guide, we'll cover how to test AI-generated code against your Kubernetes cluster using mirrord. You'll learn how to run your local process with staging context so you can validate changes in seconds instead of waiting for CI/CD pipelines.
Tip: You can use mirrord to test AI-generated code locally with Kubernetes context, without needing to build or deploy each time. If you're new to mirrord, start with the Quick Start.
Prerequisites
A Kubernetes cluster with your services running (staging or dev)
An AI coding tool (Claude Code, Cursor, Copilot, Codex)
Step 1: Create a mirrord config
Create .mirrord/mirrord.json targeting the service you're working on:
{
"target": {
"namespace": "your-namespace",
"path": {
"deployment": "your-service"
}
},
"feature": {
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "X-Test-Agent: dev"
}
}
}
}
}The http_filter ensures you only intercept traffic with your header, other developers and services using the same deployment are unaffected.
Step 2: Let AI generate code, then validate immediately
Instead of the build, deploy, test cycle, the workflow becomes:
AI generates code changes
Run locally with mirrord (substitute your framework's start command and port):
Send a test request:
See real responses from real services, no mocks, no deploy
If something is wrong, fix it and re-run.
Step 3: Run your test suite through mirrord
For automated validation, you have two options depending on your test setup:
Option A: Run the test runner through mirrord. This works when your tests start the service themselves (common with frameworks like FastAPI's TestClient or supertest):
Option B: Start the service via mirrord, then run tests against localhost. This works when your tests hit an already-running service (curl-based scripts, Playwright, Cypress):
In both cases, your tests and service run locally but with access to real dependencies in the cluster.
Example: validating a new endpoint
An AI agent adds a /discount endpoint to an order service. Without mirrord, you'd need to build, deploy, and test against staging. With mirrord:
The request reaches your local code, but when your code queries the database or calls other services, those calls go to the real staging cluster. You immediately know:
Does the database query work with real schema and data?
Do downstream service calls return what the AI expected?
Do auth tokens and permissions work correctly?
Is the response format compatible with the frontend?
Next steps
Autonomous AI Workflows with mirrord: the full agent loop with E2E guardrails and AGENTS.md setup
How to Set Up AI Tools with mirrord: per-tool config for Cursor, Claude Code, Copilot, and Codex
Using mirrord with AI Agents: auto-generate mirrord configs and AGENTS.md for your repo
Last updated
Was this helpful?

