Home / Stories / Naming conventions
Story · Repository hygiene Live

From app.yaml to a name that says what is inside.

Every repository grows a directory where one file is called app.yaml, another svc.yaml and a third autoscale.yaml. Nobody can tell what they hold without opening them. Once a week the assistant reads each file and works out what it really contains. Then it proposes one rename draft merge request (MR) per directory. The MR also fixes every reference to the old names.

Starts fromYAML files whose names do not follow <kind>_<identifier>.yaml.
Looks atEvery YAML file in your GitOps repositories (repositories that hold your infrastructure as files). It reads the kinds and metadata.names inside each file. It also reads the kustomization.yaml files (Kustomize files that list resources) that reference them.
You getA draft MR that renames a whole directory in one style. It rewrites the kustomization entries in the same diff.
01 · The weekly walk

Every YAML file, every Monday morning.

The naming review runs once a week. For each configured repository it lists every YAML file. Then it parses what is actually inside each file. It reads the kind, the name and the namespace of each document.

In apps/shop/orders-api/ it finds three files. Their names say nothing about their content.

02 · Why names matter here

Names are how related files find each other.

The convention is <kind>_<identifier>[-qualifier].yaml, for example deployment_orders-api.yaml. It is not just tidiness. The repository scanner groups files that share an identifier, so it analyses a Deployment and its autoscaler in the same context. A fix can then change both.

autoscale.yaml shares nothing with app.yaml, so the scanner looks at them apart.

03 · Suggest the names

An AI model proposes, as a structured list.

The AI model (LLM) sees the parsed summary of every file in the directory. It returns a list of from → to pairs. Each pair has a confidence. The assistant drops low-confidence suggestions.

It also flags files in a flat root that belong in a subdirectory. It flags resources of one application that have inconsistent names. The assistant applies none of these flags yet. Every rename suggestion must pass rule-based checks (checks in code, with no AI model).

04 · Grounded in the file, not its neighbours

Every part of the new name must come from the file itself.

The file itself must explain each token of a proposed name. A token can be a word from its current name, a Kubernetes kind, or a word from a metadata.name inside it. The assistant rejects a token borrowed from a neighbouring file.

The kind prefix must also match the file's actual kind. A CloudNativePG Cluster is not a statefulset_, however familiar that word is.

05 · What is left alone

Some renames are not worth making, or not safe to make.

  • The assistant never squeezes a file that holds several resources into a single-kind name.
  • When two files would get the same new name, the assistant drops both renames. A human picks.
  • The assistant finds vendored bundles (upstream install manifests) by their content and skips them.
  • The assistant leaves directories without a kustomization.yaml alone. Flux (the tool that applies git to the cluster) reads every file there anyway, so a rename is pure churn.
  • A skip annotation on the file opts it out for good.
06 · One directory, one MR

Renames land together, or the directory gets worse.

Merging renames one file at a time leaves a directory half in the old style and half in the new. So the assistant groups suggestions in the same directory that make the same kind of change into a single proposal. The directory is uniform the moment the MR merges.

07 · Rewrite every reference

A rename that breaks kustomize build is not a rename.

The assistant rewrites every kustomization.yaml that names the old file in the same diff. Afterwards it parses the result again across every reference field that kustomize knows (resources, patches, generators and more). This proves that the old name is gone.

Sometimes a reference has a shape that the rewriter cannot edit safely, such as a flow-style list or a generator's files: entry. Then the assistant holds the proposal as NEEDS_REVIEW with high risk. It names the exact reference that you must rewire by hand.

08 · The proposal

Three renames, one kustomization patch, zero content changes.

The MR moves files and edits references. It does nothing else. After you merge it, Flux applies exactly the same objects as before. The full MR is below.

naming review · apps/shop/orders-api/weekly
  • kustomization.yaml Kustomization · 3 resources
  • app.yaml Deployment orders-api
  • svc.yaml Service orders-api
  • autoscale.yaml HorizontalPodAutoscaler orders-api
  • servicemonitor_orders-api.yaml already follows the convention
3 of 5 files: name does not reveal kind or identifier
app.yamlgroup: app
svc.yamlgroup: svc
autoscale.yamlgroup: autoscale
today: three separate batches for the repository scanner
deployment_orders-api+ service_ + hpa_
One batchidentifier: orders-api
after: related resources are analysed together
model output · structured renames
{ "renames": [
  { "from": "apps/shop/orders-api/app.yaml",
    "to":   "apps/shop/orders-api/deployment_orders-api.yaml" },
  { "from": "…/svc.yaml",       "to": "…/service_orders-api.yaml" },
  { "from": "…/autoscale.yaml", "to": "…/hpa_orders-api.yaml" }
], "confidence": 0.9 }
suggestion only · deterministic checks decide what ships
grounding check · tokens of each new name
  • deployment_orders-api "deployment" = kind in file · "orders-api" = metadata.name
  • hpa_orders-api "hpa" = HorizontalPodAutoscaler · name matches
  • helmrelease_vault_external-secrets "vault" only appears in a neighbouring SecretStore · rejected
  • statefulset_orders-db file's kind is Cluster (CloudNativePG) · prefix mismatch · rejected
a name is only accepted if the file itself explains every word of it
filters · elsewhere in the same repository
14 suggestions in · 9 kept
  • platform/redis/redis.yaml 4 documents · not renamed to a single kind
  • mysql-prod.yaml + mysql.yaml both → deployment_mysql.yaml · collision · both dropped
  • crds/operator-install.yaml vendored upstream bundle · skipped
  • sandbox/*.yaml no kustomization.yaml · Flux reads all files · churn only
  • payments/legacy.yaml skip annotation · operator opted out
grouping · apps/shop/orders-api/
  • app.yaml → deployment_orders-api.yaml
  • svc.yaml → service_orders-api.yaml
  • autoscale.yaml → hpa_orders-api.yaml
apps/shop/orders-api/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
-  - app.yaml
-  - svc.yaml
-  - autoscale.yaml
+  - deployment_orders-api.yaml
+  - service_orders-api.yaml
+  - hpa_orders-api.yaml
   - servicemonitor_orders-api.yaml
re-parsed after rewrite: 0 references to old names in any kustomize field
Elsewhere: held for review
configMapGenerator.files: [nginx.conf, settings.yaml] is flow-style. The assistant cannot rewrite the old name safely, so that rename ships as NEEDS_REVIEW, risk high. It names the line to fix by hand.
Draft · Rename 3 files in apps/shop/orders-api/ to kind_identifier
rename app.yaml       → deployment_orders-api.yaml
rename svc.yaml       → service_orders-api.yaml
rename autoscale.yaml → hpa_orders-api.yaml
edit   kustomization.yaml  +3 −3
category:architecturesource:naming_scan:acme-appsrisk:lowxrev::LGTM
↓ the full merge request is below

The merge request you get.

Illustrative. File names, the repository and the MR number are fictional. The shape of the proposal is the real one.

Draft

Rename 3 files in apps/shop/orders-api/ to <kind>_<identifier>

from gitops-ai/naming-orders-api-7a2e into main · 4 files · 3 renamed · +3 −3
category:architecturesource:naming_scan:acme-appsrisk:lowxrev::LGTM
OverviewChangesValidation
Summary

Three files in apps/shop/orders-api/ do not follow the repository's <kind>_<identifier>.yaml convention. This MR renames them together so the directory is consistent. It also updates the kustomization that lists them.

Current nameContainsNew name
app.yamlDeployment orders-apideployment_orders-api.yaml
svc.yamlService orders-apiservice_orders-api.yaml
autoscale.yamlHorizontalPodAutoscaler orders-apihpa_orders-api.yaml
Why

With a shared identifier, later scans analyse the Deployment, Service and autoscaler together. A reader can also tell what each file holds from the directory listing.

What does not change

File contents. The rendered objects are identical before and after this MR.

renamed:  apps/shop/orders-api/app.yaml → apps/shop/orders-api/deployment_orders-api.yaml
renamed:  apps/shop/orders-api/svc.yaml → apps/shop/orders-api/service_orders-api.yaml
renamed:  apps/shop/orders-api/autoscale.yaml → apps/shop/orders-api/hpa_orders-api.yaml

apps/shop/orders-api/kustomization.yaml
 resources:
-  - app.yaml
-  - svc.yaml
-  - autoscale.yaml
+  - deployment_orders-api.yaml
+  - service_orders-api.yaml
+  - hpa_orders-api.yaml
   - servicemonitor_orders-api.yaml
Checked before the assistant opened this MR
  • Every word of each new name comes from the file itself (kind or metadata.name). No token comes from another file.
  • Each kind prefix matches the kind of the single resource in the file.
  • No two renames target the same new path.
  • Every kustomization field that can reference a file was re-parsed after the rewrite: no reference to an old name remains.
After merge, expect
  • Flux reconciles the shop kustomization with no object created, changed or deleted.
  • kustomize build apps/shop/orders-api gives the same output as before.
R
independent reviewer second opinion, no pipeline context

Pure renames plus a matching kustomization edit. Checked the directory for other references to the old names (none). LGTM.

What keeps it honest.

The AI model suggests names. Rule-based checks decide which renames the assistant may send out.

Grounded in the fileEvery token of a new name must come from the file's current name, its kinds or its resource names. The assistant rejects words from neighbouring files.
Kind prefix must be trueThe prefix must match the file's actual kind, including custom resources. The assistant refuses a familiar but wrong kind.
No dangling referencesThe assistant rewrites kustomization entries in the same diff. It checks them again across every reference field. If the rewriter cannot edit a reference safely, the assistant holds the MR for review and names the exact line.
Collisions need a humanWhen two files would get the same name, the assistant drops both renames. It does not guess which one wins.
Whole directories at onceRenames in one directory with one convention change ship as one MR, so a directory is never half-converted.
No churn for its own sakeThe assistant leaves these alone: multi-resource files, vendored bundles, directories that Flux reads wholesale, and files that you annotate as skipped.

Where this stands.

Live
  • Weekly naming review across all configured repositories
  • Rename MRs with kustomization references rewritten in the same diff
  • Grounding, kind-prefix, collision, multi-resource and vendored-bundle guards
  • Directory-level grouping and per-file skip annotations
In development
  • Renames that keep a kustomization entry's position and comment block in place, instead of remove-and-append
Roadmap
  • Your own naming convention as a per-repository setting, instead of the built-in <kind>_<identifier> table
← Previous storyRepository scanner