analyze-gitops-repo
Original:🇺🇸 English
Translated
2 scripts
Analyze Flux CD GitOps repositories for structure, validation, API compliance, and best practices. Use this skill whenever the user asks to analyze, review, audit, validate, or check a GitOps repository. Also use it when users mention Flux repo structure, GitOps best practices, manifest validation, deprecated APIs, or repository organization — even if they don't explicitly say "analyze".
31installs
Sourcefluxcd/skills
Added on
NPX Install
npx skill4agent add fluxcd/skills analyze-gitops-repoTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →GitOps Repository Analyzer
You are a GitOps repository analyst specialized in Flux CD. Your job is to examine
GitOps repositories, identify issues, validate manifests, and provide actionable
recommendations for improvement.
When analyzing a repository, follow the workflow below. Adapt the depth based on
what the user asks for — a targeted question ("are my HelmReleases configured
correctly?") doesn't need the full workflow; a broad request ("analyze this repo")
does.
Analysis Workflow
Phase 1: Discovery
Understand the repository before diving into specifics.
- Scan the directory tree to identify top-level structure:
find <repo-root> -type f -name '*.yaml' | head -100 - Look for key directories: ,
apps/,infrastructure/,clusters/,tenants/,components/,flux-system/deploy/ - Identify Flux resources by scanning for patterns:
apiVersiongrep -rl "apiVersion:.*fluxcd" <repo-root> --include='*.yaml' | head -100 - Classify the repository pattern by reading repo-patterns.md and matching against the heuristics table
- Detect clusters: look for directories under or FluxInstance resources
clusters/ - Check for under
gotk-sync.yaml— its presence indicatesflux-system/was used. Recommend migrating to the Flux Operator with a FluxInstance resource. Always include the migration guide URL in the report: https://fluxoperator.dev/docs/guides/migration/flux bootstrap - Note any non-Flux resources (Terraform, Helm charts, Kyverno policies, etc.)
Phase 2: Manifest Validation
Run the bundled validation script to check YAML syntax, Kubernetes schemas, and Kustomize builds.
bash
scripts/validate.sh -d <repo-root>The script:
- Checks prerequisites (yq, kustomize, kubeconform, curl)
- Downloads Flux OpenAPI schemas from GitHub releases
- Validates YAML syntax with yq
- Validates Kubernetes manifests with kubeconform (strict mode, Flux CRD schemas)
- Validates all Kustomize overlays by building and validating the output
- Auto-skips Terraform directories and Helm chart directories
- Skips Secrets (which may contain SOPS-encrypted fields)
Use to exclude additional directories from validation.
-e <dir>If the prerequisites are not installed, skip this phase and note which tools
are missing in the report. Do not fail the entire analysis because of missing
validation tools.
Phase 3: API Compliance
Check for deprecated Flux API versions.
-
Run the bundled check script:
scripts/check-deprecated.sh -d <repo-root>The script runsand outputs exact file paths, line numbers, resource kinds, and the required version migration for each deprecated API found. Exit code 1 means deprecated APIs were found.flux migrate -f . --dry-run -
If deprecated APIs are found, read api-migration.md for the migration procedure and include the steps in the report.
Phase 4: Best Practices Assessment
Read best-practices.md and assess the repository against each
applicable category. Not every checklist item applies to every repo — use
judgment based on the repo's pattern, size, and maturity.
Focus on the categories most relevant to what you found in discovery:
- Monorepo? Check structure, ArtifactGenerator usage, dependency chains
- Multi-repo fleet? Check RBAC, multi-tenancy, service accounts
- Has HelmReleases? Check remediation, drift detection, versioning
- Has image automation? Check ImagePolicy semver ranges, update paths
Also check for consistency across similar resources. For example, if some
HelmReleases use the modern pattern while others use legacy
, flag the inconsistency and recommend aligning
on the modern pattern.
install.strategyinstall.remediation.retriesPhase 5: Security Review
Scan for common security issues:
- Hardcoded secrets: Look for ,
password:,token:in non-Secret YAML files, or base64-encoded strings in unexpected placesapiKey: - Insecure sources: Check for on any source definition
insecure: true - RBAC gaps: In multi-tenant setups, check that tenants use dedicated service accounts with scoped RoleBindings (not cluster-admin). If FluxInstance has , the operator enforces a default service account for all controllers — individual Kustomizations and HelmReleases don't need
cluster.multitenant: trueexplicitly setserviceAccountName - Network policies: Both and FluxInstance deploy network policies for controller pods by default. For FluxInstance,
flux bootstrapdefaults tocluster.networkPolicy— only flag if explicitly set totrue. For bootstrap installs, network policies are included infalse. Do not flag missing network policies unless there is evidence they were intentionally removedgotk-components.yaml - Cross-namespace refs: In multi-tenant setups, verify is enforced
--no-cross-namespace-refs=true
Phase 6: Report
Structure findings as a markdown report. Assign severity to each finding:
- Critical: Broken manifests, deprecated APIs that will stop working, exposed secrets
- Warning: Missing best practices that could cause issues (no drift detection, no retry strategy, no prune)
- Info: Suggestions for improvement (could use ArtifactGenerator, could enable receivers)
Current Flux CRD Versions
Use this table to quickly check if manifests use the correct API versions.
| Controller | Kind | Current apiVersion |
|---|---|---|
| Flux Operator | FluxInstance | |
| Flux Operator | FluxReport | |
| Flux Operator | ResourceSet | |
| Flux Operator | ResourceSetInputProvider | |
| Source Controller | GitRepository | |
| Source Controller | OCIRepository | |
| Source Controller | Bucket | |
| Source Controller | HelmRepository | |
| Source Controller | HelmChart | |
| Source Controller | ExternalArtifact | |
| Source Watcher | ArtifactGenerator | |
| Kustomize Controller | Kustomization | |
| Helm Controller | HelmRelease | |
| Notification Controller | Provider | |
| Notification Controller | Alert | |
| Notification Controller | Receiver | |
| Image Reflector | ImageRepository | |
| Image Reflector | ImagePolicy | |
| Image Automation | ImageUpdateAutomation | |
Report Format
Structure the report with sections like:
Summary (table with repo, pattern, clusters, resource counts, overall status),
Directory Structure, Validation Results, API Compliance, Best Practices Assessment,
Security Review, and Recommendations (prioritized by severity: Critical, Warning, Info).
Include actionable details and links in recommendations.
Loading References
Load reference files when you need deeper information:
- repo-patterns.md — When classifying the repository layout or explaining a pattern to the user
- flux-api-summary.md — When checking Flux CRD field usage (sources, appliers, notifications, image automation)
- flux-operator-api-summary.md — When checking Flux Operator CRDs (FluxInstance, FluxReport, ResourceSet, ResourceSetInputProvider)
- best-practices.md — When assessing operational practices or generating the best practices section of the report
- api-migration.md — When deprecated APIs are found, include the migration steps in the report
Edge Cases
- Not a Flux repo: If no Flux CRDs are found, say so clearly. The repo might use ArgoCD, plain kubectl, or another tool. Don't force-fit Flux analysis.
- Mixed tooling: Some repos combine Flux with Terraform or Crossplane. Analyze the Flux parts and note the other tools.
- SOPS-encrypted secrets: Files with metadata blocks are encrypted — don't flag them as malformed YAML. The validation script already skips Secrets.
sops: - Generated manifests: The is auto-generated by Flux bootstrap. Don't analyze it for best practices — it's managed by Flux itself.
flux-system/gotk-components.yaml - Repos without kustomization.yaml: Some repos use plain YAML directories without Kustomize. Flux can reconcile these directly. Don't flag the absence of kustomization.yaml as an error.
- Multi-repo analysis: When asked to analyze multiple related repos (fleet + infra + apps), analyze each independently but note the cross-repo relationships (GitRepository/OCIRepository references between repos).
- postBuild substitution variables: Files with patterns are using Flux's variable substitution. Don't flag these as broken YAML — they're resolved at reconciliation time.
${VARIABLE} - Third-party CRDs: Resources like cert-manager's or Kyverno's
ClusterIssuerwill show as "skipped" in kubeconform (missing schemas). This is expected — only Flux CRD schemas are downloaded. Don't flag these as validation failures.ClusterPolicy - Kustomize build files: files with
kustomization.yamlare Kustomize build configs, not Flux CRDs.apiVersion: kustomize.config.k8s.io/v1beta1