skills/mirrord-db-branching/SKILL.md
Helps users configure mirrord.json for database branching, enabling isolated database copies for safe development and testing. Use when the user wants to set up MySQL or PostgreSQL branching, configure copy modes, IAM authentication, or manage database branches.
npx skillsauth add metalbear-co/skills mirrord-db-branchingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate and validate mirrord.json configurations for database branching:
IMPORTANT: Follow these security rules for all operations in this skill.
"type": "env").GOOGLE_APPLICATION_CREDENTIALS environment variable or credentials_path over inline credential values. Never embed IAM credentials directly in configuration files.For complete documentation, see:
Step 0: Load References
Read the reference files from this skill's references/ directory:
references/db-branches-schema.json - Authoritative JSON Schema for db_branches configurationreferences/troubleshooting.md - Common issues and solutionsThe schema is derived from the official mirrord schema at: https://raw.githubusercontent.com/metalbear-co/mirrord/main/mirrord-schema.json
If using absolute paths, search for the schema using patterns like **/mirrord-db-branching/references/*.
Step 1: Verify Prerequisites
For MySQL:
operator.mysqlBranching: trueFor PostgreSQL:
operator.pgBranching: trueStep 2: Identify Connection Environment Variable The application must use an environment variable for the database connection string. mirrord will override this variable with the branch connection URL.
Step 3: Validate Configuration After generating any config, ALWAYS run:
mirrord verify-config /path/to/config.json
{
"db_branches": [
{
"id": "unique-branch-identifier",
"type": "mysql",
"version": "8.0",
"name": "database-name",
"ttl_secs": 60,
"creation_timeout_secs": 20,
"connection": {
"url": {
"type": "env",
"variable": "DB_CONNECTION_URL"
}
},
"copy": {
"mode": "empty"
}
}
]
}
| Type | Value | Notes |
|------|-------|-------|
| MySQL | "mysql" | Requires operator.mysqlBranching: true |
| PostgreSQL | "pg" | Requires operator.pgBranching: true, supports IAM auth |
| MongoDB | "mongodb" | Uses collections instead of tables |
| Redis | "redis" | Can run locally or remotely |
| Field | Required | Description |
|-------|----------|-------------|
| type | Yes | Database engine: "mysql", "pg", or "mongodb" |
| connection | Yes | Connection source configuration |
| connection.url.type | Yes | Must be "env" or "env_from" |
| connection.url.variable | Yes | Environment variable storing the connection string |
| id | No | Branch identifier for reuse; same ID reconnects to existing branch |
| name | No | Database name when not accessible from connection |
| version | No | Engine version (e.g., "8.0" for MySQL, "16" for PostgreSQL) |
| ttl_secs | No | Branch lifetime in seconds (max 900 / 15 minutes, default 300 / 5 minutes) |
| creation_timeout_secs | No | Setup timeout (default 60 seconds) |
| copy.mode | No | Cloning strategy (default "empty") |
| iam_auth | No | Cloud IAM authentication (PostgreSQL only) |
| Field | Required | Description |
|-------|----------|-------------|
| type | Yes | Must be "redis" |
| location | No | "local" or "remote" (default: "remote") |
| connection | No | Redis connection config (URL or host/port/password) |
| id | No | Branch identifier for reuse |
| local | No | Local Redis runtime config (when location is "local") |
Creates an empty database with no schema or data. Use when your application handles migrations on startup.
{
"copy": {
"mode": "empty"
}
}
Replicates table structures without data. Good for testing schema modifications.
{
"copy": {
"mode": "schema"
}
}
Copies schema and all data. Use only for small databases as this increases creation time significantly.
{
"copy": {
"mode": "all"
}
}
Copy schema plus filtered rows from specific tables. Cannot be combined with "mode": "all".
{
"copy": {
"mode": "schema",
"tables": {
"users": {"filter": "name = 'alice' OR name = 'bob'"},
"orders": {"filter": "created_at > 1759948761"}
}
}
}
MongoDB uses collections instead of tables:
{
"copy": {
"mode": "all",
"collections": {
"users": {"filter": "{\"name\": {\"$in\": [\"alice\", \"bob\"]}}"},
"orders": {"filter": "{\"created_at\": {\"$gt\": 1759948761}}"}
}
}
}
Redis branches can run locally or use the remote instance.
{
"db_branches": [
{
"type": "redis",
"location": "local",
"connection": {
"url": {
"type": "env",
"variable": "REDIS_URL"
}
},
"local": {
"runtime": "container",
"container_runtime": "docker",
"port": 6379,
"version": "7-alpine"
}
}
]
}
{
"db_branches": [
{
"type": "redis",
"location": "local",
"connection": {
"host": {
"type": "env",
"variable": "REDIS_HOST"
},
"port": 6379,
"password": {
"type": "env",
"variable": "REDIS_PASSWORD"
}
}
}
]
}
Uses credentials from the target pod's environment:
{
"iam_auth": {
"type": "aws_rds"
}
}
Default variables checked: AWS_REGION, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
Important: Requires TLS - ensure connection URL includes sslmode=require
{
"iam_auth": {
"type": "gcp_cloud_sql"
}
}
Uses GOOGLE_APPLICATION_CREDENTIALS by default. Can override with:
credentials_path - Custom file path (preferred)Security: Avoid using inline
credentials_jsonin configuration files. UseGOOGLE_APPLICATION_CREDENTIALSenvironment variable orcredentials_pathto reference credentials stored securely outside the config.
mirrord db-branches [-n namespace] status [branch-names...]
mirrord db-branches --all-namespaces status
mirrord db-branches [-n namespace] destroy branch-name
mirrord db-branches [-n namespace] destroy --all
mirrord db-branches --all-namespaces destroy --all
| Issue | Solution |
|-------|----------|
| Connection timeouts | Branch databases disable SSL by default; verify client isn't forcing SSL |
| GCP Cloud SQL fails | Ensure connection URL includes sslmode=require |
| Branch creation slow | Using "mode": "all" on large database; switch to "schema" or "empty" |
| Branch not reused | Ensure id field is set and matches; check TTL hasn't expired |
| Wrong database connected | Verify connection.url.variable matches your app's actual env var |
If the request is under-specified, ask for ONE detail:
Otherwise, provide safe defaults and note assumptions.
User: "I want to test migrations on my MySQL database without affecting production"
{
"db_branches": [
{
"id": "migration-test",
"type": "mysql",
"version": "8.0",
"name": "myapp_production",
"ttl_secs": 300,
"connection": {
"url": {
"type": "env",
"variable": "DATABASE_URL"
}
},
"copy": {
"mode": "schema"
}
}
]
}
User: "Set up a Postgres branch using AWS IAM authentication"
{
"db_branches": [
{
"type": "pg",
"version": "16",
"name": "app_db",
"connection": {
"url": {
"type": "env",
"variable": "PG_CONNECTION_STRING"
}
},
"copy": {
"mode": "empty"
},
"iam_auth": {
"type": "aws_rds"
}
}
]
}
User: "I need a branch with only test users from the users table"
{
"db_branches": [
{
"id": "test-data-branch",
"type": "pg",
"version": "15",
"name": "production_db",
"connection": {
"url": {
"type": "env",
"variable": "DATABASE_URL"
}
},
"copy": {
"mode": "schema",
"tables": {
"users": {"filter": "email LIKE '%@test.com'"}
}
}
}
]
}
User: "Set up a MongoDB branch that copies specific users"
{
"db_branches": [
{
"type": "mongodb",
"version": "7.0",
"name": "app_database",
"connection": {
"url": {
"type": "env",
"variable": "MONGODB_URI"
}
},
"copy": {
"mode": "all",
"collections": {
"users": {"filter": "{\"role\": \"admin\"}"}
}
}
}
]
}
User: "I want a local Redis instance for my development session"
{
"db_branches": [
{
"type": "redis",
"id": "dev-redis",
"location": "local",
"connection": {
"url": {
"type": "env",
"variable": "REDIS_URL"
}
},
"local": {
"runtime": "container",
"container_runtime": "docker",
"version": "7-alpine"
}
}
]
}
"mysql" or "pg")"empty" copy mode to avoid long creation timestesting
Helps users generate, edit, and validate mirrord.json configuration files for mirrord (MetalBear). Use when the user wants to connect their local process to a Kubernetes environment, configure features (env/fs/network), or needs feedback on an existing mirrord.json. Always ensures output JSON is valid and schema-conformant.
tools
Helps DevOps engineers configure mirrord Operator's Kafka queue splitting feature end-to-end. Generates MirrordKafkaClientConfig and MirrordKafkaTopicsConsumer Kubernetes CRD YAMLs, the matching mirrord.json split_queues section, and Helm value guidance. Use this skill whenever the user mentions Kafka splitting with mirrord, MirrordKafkaClientConfig, MirrordKafkaTopicsConsumer, Kafka queue splitting, Kafka topic splitting, configuring mirrord with Kafka, setting up Kafka for mirrord operator, or troubleshooting Kafka splitting sessions. Also trigger when users mention split_queues with queue_type Kafka, or ask about connecting mirrord to a Kafka cluster. This is a Team/Enterprise feature of mirrord.
devops
Guide users from zero to their first working mirrord session. Use when a user is new to mirrord, wants to install it, or needs help running their first session connecting to a Kubernetes cluster.
devops
Help users install and configure the mirrord operator for team environments. Use when users ask about operator setup, Helm installation, licensing, or multi-user mirrord deployments.