agentleFS
Aidas-devAidas-dev/k8s-agent-skills/skills/atlas/SKILL.md

atlas

Skill4 starsChanged 5 months agoMITView on GitHub

Use when working with Atlas Operator on Kubernetes — creating or troubleshooting AtlasSchema or AtlasMigration resources; configuring DevDB, migration policies, credential patterns, or schema diff/lint rules.

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use openai-docs, ship and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenAISkill

    openai-docs

    Use when the user asks how to build with OpenAI products or APIs, asks about Codex itself or choosing Codex surfaces, needs up-to-date official documentation with citations, help choosing the latest model for a use case, or model upgrade and prompt-upgrade guidance; use OpenAI docs MCP tools for non-Codex docs questions, use the Codex manual helper first for broad Codex self-knowledge, and restrict fallback browsing to official OpenAI domains.

    Also in 3 projects that use this

  • AWSSkill

    ship

    Finalize dev work on an issue branch — update docs, push, and open a PR.

    Also in 3 projects that use this

  • VercelSkill

    setup

    Set up Vercel CLI and project configuration. Use when the user says "set up Vercel", "configure Vercel", "link to Vercel", or "vercel init".

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use credentials struct when the URL is constructed from multiple Secret keys:

    line 144

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Atlas Operator

Overview

Database schema management on Kubernetes via db.atlasgo.io/v1alpha1. Two approaches: AtlasSchema (declarative — define desired schema, operator diffs and applies) and AtlasMigration (versioned — ordered SQL scripts). Deployed via OCI Helm chart: ghcr.io/ariga/charts/atlas-operator (0.8.4 at time of writing).

Five CRDs are installed by that chart, not two: AtlasSchema, AtlasMigration, AtlasDriftCheck (scheduled drift detection for a target), plus AtlasSecurityScan / AtlasSecurityReport (CVE scanning; needs an Atlas Pro token).

Prefer the installed CRD over the docs for field names. The operator's own README (https://raw.githubusercontent.com/ariga/atlas-operator/master/README.md) is current and authoritative for semantics; several atlasgo.io operator doc URLs 404. To enumerate fields on any cluster:

kubectl get crd atlasschemas.db.atlasgo.io -o json \
  | python3 -c "import json,sys; d=json.load(sys.stdin); p=d['spec']['versions'][0]['schema']['openAPIV3Schema']['properties']['spec']['properties']; print(' '.join(sorted(p.keys())))"

CRD Reference

CRDApproachUse When
AtlasSchemaDeclarativeSchema should match a desired state (operator auto-diffs)
AtlasMigrationVersionedNeed sequential migration files, rollback support, audit trail

AtlasSchema (Declarative)

spec accepts: url, urlFrom, credentials, schema, schemas, policy, exclude, devURL, devURLFrom, devDB, prewarmDevDB, config, configFrom, envName, vars, txMode, cloud, backoffLimit.

schema accepts exactly three shapes: hcl, sql (inline) and configMapKeyRef (a key in a ConfigMap in the same namespace). A file in git is best expressed through kustomize's configMapGenerator, so the HCL stays reviewable:

# kustomization.yaml
configMapGenerator:
  - name: app-schema
    files:
      - schema.hcl
apiVersion: db.atlasgo.io/v1alpha1
kind: AtlasSchema
metadata:
  name: app-schema
  namespace: app
spec:
  urlFrom:
    secretKeyRef:
      name: db-creds
      key: uri              # CNPG-generated app secret works directly
  schema:
    configMapKeyRef:
      name: app-schema
      key: schema.hcl
  policy:
    lint:
      destructive:
        error: true
    diff:
      skip:
        - drop_column
  prewarmDevDB: true
// schema.hcl — Atlas HCL, not Terraform
schema "public" {}

table "products" {
  schema = schema.public
  column "sku" { type = text }
  column "specs" {
    type    = jsonb
    default = sql("'{}'::jsonb")
  }
  primary_key "products_pkey" { columns = [column.sku] }
  index "products_category_idx" { columns = [column.category] }
}

Do not issue DDL from the application once an AtlasSchema owns a database: two writers for one shape. A Rust/Python service should only read rows and seed data; a test asserting the binary contains no CREATE TABLE is a cheap way to keep that true.

AtlasMigration (Versioned)

apiVersion: db.atlasgo.io/v1alpha1
kind: AtlasMigration
metadata:
  name: app-migrations
spec:
  urlFrom:
    secretKeyRef:
      name: db-creds
      key: url

  dir:
    configMapRef:
      name: migration-files   # ConfigMap with SQL migration scripts

  execOrder: linear           # linear | linear-skip | non-linear
  baseline: "000000"          # Start from this version (skip earlier)

  policy:
    lint:
      destructive:
        error: true

  prewarmDevDB: true
  # allowCustomConfig is a chart value, not a CR field — drop it from the resource.

Migration files in ConfigMap must be lexicographically ordered:

apiVersion: v1
kind: ConfigMap
metadata:
  name: migration-files
data:
  000001_init.sql: |
    CREATE TABLE users (...);
  000002_add_posts.sql: |
    CREATE TABLE posts (...);
  000003_add_indexes.sql: |
    CREATE INDEX idx_users_email ON users(email);

Credential Patterns

PatternExample
Connection URL in SecreturlFrom.secretKeyRef.key: url
Credentials structcredentials.host, .user, .passwordFrom, .database, .port
Extra connection parameterscredentials.parameters: { sslmode: require }

Use credentials struct when the URL is constructed from multiple Secret keys:

spec:
  credentials:
    host: myhost.example.com
    user: app
    passwordFrom:
      secretKeyRef:
        name: db-creds
        key: password
    database: mydb
    port: 5432

Policy Configuration

PolicyFieldEffect
lint.destructive.errortrue/falseBlock (true) or warn (false) on destructive changes
diff.skipmap, e.g. drop_column: trueOperations to skip in diff (safe for roll-forward). A map of operation to boolean, not a list — the 15 keys are add_column, add_foreign_key, add_index, add_schema, add_table, drop_column, drop_foreign_key, drop_index, drop_schema, drop_table, modify_column, modify_foreign_key, modify_index, modify_schema, modify_table
diff.concurrent_index.create / .droptrue/falseWhether index changes are planned CONCURRENTLY
exclude["pattern_*"]Glob patterns to exclude from management (top-level spec.exclude, not under policy)

Migration Directory Sources

SourceLocationUse Case
dir.configMapRefConfigMap in same namespaceSimple, no external deps
dir.local.pathMounted volume pathSidecar / init container pattern
dir.remoteAtlas Cloud URLTeam-managed schema registry
Inline (spec.schema.sql)Embedded in CRQuick prototyping

DevDB

Ephemeral database used to compute diff between desired and current schema. If devURL not set, operator spins a temporary container. Set explicitly to reuse or for air-gapped:

spec:
  devURL: postgres://user:pass@dev-db-host:5432/template?sslmode=disable

Or via Secret: devURLFrom.secretKeyRef. devDB is the structured form of the same thing.

AtlasDriftCheck

spec accepts targetRef, interval, onDrift, exclude, timeout, suspend. It reports when the live schema stops matching the declared one without applying anything — useful on a database you do not want rewritten on every reconcile, and as the alerting half of the pair when AtlasSchema is the fixing half.

Adopting Atlas on an existing database

An AtlasSchema whose HCL matches the current tables is a no-op: the operator diffs, finds nothing, and stays Ready. Adopting is therefore safe to do in one commit — point it at the live secret and the declared schema — but write the HCL from the live shape (kubectl exec … psql -c '\d+ table') rather than from memory, or the first reconcile will rewrite it.

Reconcile reasons (what Ready=False actually means)

In a successful reconcile the condition is Ready=True, reason=Applied. Anything else is Ready=False and the reason names the failing stage:

ReasonMeaning
ReconcilingDiff in flight against the live database
ReadSchemaCould not read the desired schema (ConfigMap key, Secret, credentials)
GettingDevDBCould not obtain the dev database used to normalise the schema
VerifyingFirstRunFirst run of an operator against this DB planned destructive changes
LintPolicyErrorThe plan violated policy.lint — the fix is the plan, not the field
ApplyingSchemaApplying the planned statements to the database failed

AtlasMigration has its own set (ReadingMigrationData, Migrating, ProtectedFlowError, ApprovalPending with a status.approvalUrl, DriftDetected).

Dev database pod metadata

Both CRs accept labels/annotations for the generated dev database Deployment, which is how you place it (nodeSelector/tolerations go through devDB.spec):

spec:
  devDB:
    metadata:
      labels: { team: platform }
      annotations: { example.com/purpose: schema-analysis }

Metadata and a custom devDB.spec apply only when the Deployment is created; an existing one is not updated.

Operator chart values worth knowing

  • prewarmDevDB (default true) — keep dev database Deployments around between reconciles.
  • watchSecrets — watch referenced Secrets so rotating one re-triggers a reconcile; needs cluster-wide list/watch on Secrets. Off means Secrets are read on each reconcile with get only.
  • allowCustomConfig — enables spec.config/configFrom (custom atlas.hcl); also unlocks arbitrary command execution via the external data source.
  • extraEnvs — e.g. MSSQL_ACCEPT_EULA/MSSQL_PID for the SQL Server driver, ATLAS_TOKEN for triggers/functions/SQL Server/ClickHouse/Redshift.
  • SKIP_VERCHECK=true in the operator's env disables periodic version/advisory checks.

Common Mistakes

  • allowCustomConfig is a chart value, not a CR field — the 0.8.4 CRD has no such key. It gates whether spec.config / configFrom (custom atlas.hcl) and spec.envName are accepted, and it also unlocks the external data source (arbitrary command execution) and the raw sql data source, so it is off by default for a reason.
  • diff.skip given as a list — it is a map keyed by operation; a list is rejected by the CRD.
  • spec.vars vs variables — the CRD field is vars; the upstream README's config example spells it variables. Check the installed CRD before copying either.
  • No lint policy — destructive changes silently applied; set lint.destructive.error: true on anything with real data, and skip drop_column if a dropped column must never happen by accident.
  • Two writers — an app that also runs CREATE TABLE will fight the operator; keep DDL out of the service.
  • Wrong execOrder (AtlasMigration) — non-linear skips version ordering; use linear for strict order.
  • Missing baseline (AtlasMigration) — the operator tries to run every migration including already-applied ones; set baseline to skip them.
  • dir sources (AtlasMigration): configMapRef, local.path, remote; not the same schema.configMapKeyRef shape used by AtlasSchema.
  • DevDB connection issues — the operator needs a dev database to build the desired state; prewarmDevDB: true keeps that container around between reconciles.

Supported Databases

MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, ClickHouse, CockroachDB, TiDB, YugabyteDB.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.