flux2
AGENTS.md8.5k starsChanged 5 years agoApache-2.0View on GitHub
Guidance for AI coding assistants working in fluxcd/flux2. Read this file before making changes. These rules come from fluxcd/flux2/CONTRIBUTING.md and apply to every Flux repository. The -s flag adds the human's Signed-off-by from their git config — do not remove it. - Commit message format: Subject in imperative mood ("Add feature X" instead of "Adding feature X"), capitalized, no trailing period, ≤50 characters. Body wrapped at 72 columns, explaining what and why. No @mentions or #123 issue references in the…
- Installs packages
Trending
Less talk lately.about the whole repository
Who's talking about fluxcd/flux2
- fluxcd-community/helm-charts“Implement the patches for Flux All-In-One installation”GitHub · Apr 3, 2024 · 28 reactions
- fluxcd/helm-controller“Support Kustomize `labels` property”GitHub · Oct 13, 2023 · 25 reactions
- cncf/foundation“License exception for Terraform Provider SDK”GitHub · Aug 14, 2023 · 17 reactions
- fluxcd/kustomize-controller“[RFC] Server-side reconciliation for the v1beta2 API”GitHub · Sep 11, 2021 · 15 reactions
- argoproj/argo-rollouts“kstatus compatibility”GitHub · Mar 26, 2026 · 14 reactions
The biggest 5 of 48 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 48
Talked about on GitHub, Stack Overflow, Bluesky and Hacker News (48 times).
On GitHub · 38
- Apr 3, 2024Implement the patches for Flux All-In-One installation — fluxcd-community/helm-charts28 reactions · 5 comments
- Oct 13, 2023Support Kustomize `labels` property — fluxcd/helm-controller25 reactions · 2 comments
- Aug 14, 2023License exception for Terraform Provider SDK — cncf/foundation17 reactions · 5 comments
- Sep 11, 2021[RFC] Server-side reconciliation for the v1beta2 API — fluxcd/kustomize-controller15 reactions · 9 comments
- Mar 26, 2026kstatus compatibility — argoproj/argo-rollouts14 reactions · 1 comment
33 more on GitHub
- Dec 6, 2021What if './infrastructure' needs to be different for different clusters? — fluxcd/flux2-kustomize-helm-example12 reactions · 4 comments
- Mar 22, 2022Support `nodeSelector` for scheduling — fluxcd/terraform-provider-flux11 reactions · 1 comment
- May 25, 2026docs: document literal field on valuesFrom — fluxcd/helm-controller9 reactions · 2 comments
- Jun 17, 2021Error in logs with Flux for docker images repositories from AWS Public ECR endpoint — fluxcd/flux9 reactions · 28 comments
- Apr 22, 2022Add GitHub dispatch provider — fluxcd/notification-controller8 reactions
- Jan 9, 2022Revoke kubectl managed fields ownership — fluxcd/kustomize-controller8 reactions · 6 comments
- May 25, 2026chartutil: add Literal mode to ValuesReference (helm --set-literal semantics) — fluxcd/pkg7 reactions · 8 comments
- Oct 22, 2021Workaround kustomize bug in pulsar cluster init — apache/pulsar-helm-chart7 reactions · 1 comment
- Sep 8, 2025Introduce ArtifactGenerator API — fluxcd/source-watcher6 reactions
- Apr 27, 2022[RFC 0002] Flux OCI support for Helm — fluxcd/source-controller5 reactions · 10 comments
- Oct 30, 2026fluxcd: 2.9.6 -> 2.10.0, update maintainers, rec to finalAttrs, fix update script — NixOS/nixpkgs4 reactions · 7 comments
- Feb 27, 2026Add SSH signature verification for git commits — fluxcd/pkg4 reactions · 13 comments
- May 7, 2025Add `DisableChartDigestTracking` feature gate — fluxcd/helm-controller4 reactions
- May 11, 2021Upgrade controller to Kustomize v4 — fluxcd/kustomize-controller4 reactions · 19 comments
- May 6, 2021Contributing guidelines — notaryproject/notation4 reactions · 3 comments
- Jul 1, 2026operator: fix electing versions beyond supported — controlplaneio-fluxcd/flux-operator3 reactions
- Jun 7, 2026Add DependencyReference enhancements to 2.9 roadmap — fluxcd/website3 reactions · 1 comment
- Apr 29, 2026fluxcd: 2.8.5 -> 2.8.6 — NixOS/nixpkgs3 reactions · 8 comments
- Feb 27, 2026fluxcd: 2.7.5 -> 2.8.1 — NixOS/nixpkgs3 reactions · 2 comments
- Jul 15, 2025[RFC-0010] Azure OIDC integration updates for Azure DevOps and Azure EventHub — fluxcd/notification-controller3 reactions · 11 comments
- May 29, 2025fluxcd: 2.5.1 -> 2.6.2 — NixOS/nixpkgs3 reactions · 3 comments
- Sep 17, 2023Add cmd for importing Kubernetes CRD schemas — stefanprodan/timoni3 reactions
- Aug 24, 2022Enable contextual login in OCI HelmRepository — fluxcd/source-controller3 reactions · 6 comments
- Dec 15, 2021Statically build source-controller — fluxcd/source-controller3 reactions · 11 comments
- Oct 14, 2021SOPS: Decrypt dotenv files used in kustomize secret generator — fluxcd/kustomize-controller3 reactions · 2 comments
- Mar 29, 2026kustomize: fix `kustomization.yaml` path on Windows — fluxcd/pkg2 reactions · 1 comment
- Dec 29, 2025web: Implement action bar in the resource dashboard — controlplaneio-fluxcd/flux-operator2 reactions · 1 comment
- Sep 2, 2025[RFC-0010] Complete implementation — fluxcd/website2 reactions
- Jul 2, 2025[RFC-0010] Introduce workload identity auth for remote clusters — fluxcd/kustomize-controller2 reactions
- Apr 29, 2025[RFC-0010] Implement managed identity support for Azure Event Hub provider — fluxcd/notification-controller2 reactions · 3 comments
- Oct 1, 2024fluxcd: 2.3.0 -> 2.4.0 — NixOS/nixpkgs2 reactions · 5 comments
- Apr 6, 2024Document how to use numbers and booleans in post build substitutions — fluxcd/kustomize-controller2 reactions · 9 comments
- Feb 19, 2024🤖 Update module github.com/fluxcd/flux2/v2 to v2.2.3 — stackitcloud/gardener-extension-shoot-flux2 reactions
On Stack Overflow · 5
- Dec 8, 2022How to list all images from an account in GitHub Container Registry?9 votes
- Nov 6, 2025what is gotk notation/symbol means in the fluxcd2 votes
- May 23, 2022FluxCD notification error sending to Microsoft Teams1 vote
- Dec 29, 2023is there kustomize version used by flux kustomization0 votes
- Nov 16, 2022Enabling cross-namespace references on flux and Azure AKS / gitops0 votes
On Bluesky · 4
- Nov 2, 2026flux2 by @fluxcd (⭐️ 8490) Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. #go — @golangoss.bsky.social1 likes and repost
- Jul 21, 2026flux2 by @fluxcd (⭐️ 8285) Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. #go — @golangoss.bsky.social1 likes and repost
- Jun 18, 2026flux2 by @fluxcd (⭐️ 8198) Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. #go — @golangoss.bsky.social1 likes and repost
- Jun 16, 2026flux2 by @fluxcd (⭐️ 8192) Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit. #go — @golangoss.bsky.social1 likes and repost
On Hacker News · 1
- Apr 21, 2021Flux2: Continuous Delivery for Kubernetes2 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
16 rules. About 1 is common, 1 is distinctive, and 14 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 17
Rebase, don't merge: Never merge main into the feature branch.
- Very specific: line 20
Copyright: All new .go files must begin with the header from cmd/flux/main.go (Apache 2.0).
- Distinctive: line 25
Before submitting code, review your changes for the following:
- Common: line 27
No secrets in logs or output: Never surface auth tokens, passwords, deploy keys, or credential URLs in error messages, log lines, or CLI …
- Very specific: line 30
No command injection: Do not shell out via os/exec for git, helm, or kustomize operations.
- Very specific: line 33
Resource cleanup: Ensure temporary files and directories (manifest staging, downloaded tarballs) are cleaned up on all code paths (success …
- Very specific: line 34
No panics: Never use panic in runtime code paths.
- Very specific: line 36
Minimal surface: Keep new exported APIs in pkg/ to the minimum needed.
- Very specific: line 85
When modifying manifests/, always run make build and verify the generated output before committing.
- Very specific: line 89
All targets in the root Makefile.
- Very specific: line 101
Run a single test: make test TEST_ARGS='-run TestCreate -v'.
- Very specific: line 105
Check go.mod and the Makefile for current dependency and tool versions.
- Very specific: line 121
Command pattern: follow the existing group-parent + per-resource-child cobra structure.
- Very specific: line 124
SSA apply: always use internal/utils.Apply() (two-phase: CRDs/Namespaces first, then rest).
- Very specific: line 127
Flags: use internal/flags/ custom pflag.Value types for enum flags (providers, algorithms, sources).
- Very specific: line 139
Run a single unit test: make test TEST_ARGS='-run TestInstall -v'.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guidance for AI coding assistants working in fluxcd/flux2. Read this file before making changes.
Contribution workflow for AI agents
These rules come from fluxcd/flux2/CONTRIBUTING.md and apply to every Flux repository.
- Do not add
Signed-off-byorCo-authored-bytrailers with your agent name. Only a human can legally certify the DCO. - Disclose AI assistance with an
Assisted-bytrailer naming your agent and model:
Thegit commit -s -m "Add support for X" --trailer "Assisted-by: <agent-name>/<model-id>"-sflag adds the human'sSigned-off-byfrom their git config — do not remove it. - Commit message format: Subject in imperative mood ("Add feature X" instead of "Adding feature X"), capitalized, no trailing period, ≤50 characters. Body wrapped at 72 columns, explaining what and why. No
@mentionsor#123issue references in the commit — put those in the PR description. - Trim verbiage: in PR descriptions, commit messages, and code comments. No marketing prose, no restating the diff, no emojis.
- Rebase, don't merge: Never merge
maininto the feature branch; rebase onto the latestmainand push with--force-with-lease. Squash before merge when asked. - Pre-PR gate:
make tidy fmt vet && make testmust pass and the working tree must be clean. - Flux is GA: Backward compatibility is mandatory. Breaking changes to CLI flags, output format, or behavior will be rejected. Design additive changes.
- Copyright: All new
.gofiles must begin with the header fromcmd/flux/main.go(Apache 2.0). Update the year to the current year when copying. - Tests: New features, improvements and fixes must have test coverage. Add unit tests in
cmd/flux/*_test.gotagged//go:build unit. Follow the existingcmdTestCase+ golden file patterns. Run tests locally before pushing.
Code quality
Before submitting code, review your changes for the following:
- No secrets in logs or output. Never surface auth tokens, passwords, deploy keys, or credential URLs in error messages, log lines, or CLI output. Bootstrap and source-secret commands handle sensitive material — take extra care.
- No unchecked I/O. Close HTTP response bodies, file handles, and tar readers in
deferstatements. Check and propagate errors from I/O operations. - No path traversal. Validate and sanitize file paths extracted from archives or user input. Never
filepath.Joinwith untrusted components without validation. - No command injection. Do not shell out via
os/execfor git, helm, or kustomize operations. Use the Go libraries already in use (fluxcd/pkg/git,fluxcd/pkg/kustomize,fluxcd/pkg/ssa). - No hardcoded defaults for security settings. TLS verification must remain enabled by default. Git auth settings come from user-provided secrets.
- Error handling. Wrap errors with
%wfor chain inspection. Do not swallow errors silently. CLI errors must be actionable — tell the user what went wrong and how to fix it without leaking internal state. - Resource cleanup. Ensure temporary files and directories (manifest staging, downloaded tarballs) are cleaned up on all code paths (success and error). Use
deferandt.TempDir()in tests. - No panics. Never use
panicin runtime code paths. Return errors and let the CLI handle them gracefully. - Output discipline. Machine-readable data (tables, YAML, JSON) goes to stdout via
rootCmd.OutOrStdout(). Human-readable status messages go to stderr via thestderrLogger. - Minimal surface. Keep new exported APIs in
pkg/to the minimum needed. Every export is a backward-compatibility commitment.
Project overview
flux2 is the Flux CLI (flux command) and distribution repository. It is not a controller — it consumes CRD APIs from six independent controller repos (source-controller, kustomize-controller, helm-controller, notification-controller, image-reflector-controller, image-automation-controller). It serves two purposes:
- CLI tool — a Cobra-based binary that installs Flux onto Kubernetes clusters, bootstraps GitOps pipelines, and manages all Flux CRD objects (create, get, export, reconcile, suspend, resume, delete, diff, build, etc.).
- Distribution hub — it bundles the Kustomize manifests for all Flux controllers and releases them as
manifests.tar.gzon GitHub. Those manifests are also compiled into the binary itself via//go:embed.
Repository layout
cmd/flux/— all CLI source. Singlemainpackage with one file per command or resource type.main.godefines the root cobra command with global flags.manifests.embed.goembeds the generated controller manifests via//go:embed.internal/build/—flux build kustomizationlogic (kustomize-based diff/build, SOPS secret masking).internal/flags/— custompflag.Valuetypes providing enum validation (e.g.LogLevel,ECDSACurve,RSAKeyBits,PublicKeyAlgorithm,DecryptionProvider).internal/tree/— tree-printing helper forflux tree kustomization.internal/utils/— shared helpers:KubeClient,KubeConfig,NewScheme(registers all controller API groups),Apply(SSA-based two-phase apply),ExecKubectlCommand,ValidateComponents.pkg/bootstrap/— bootstrap orchestration:Run(),PlainGitBootstrapper,ProviderBootstrapper.provider/has the git provider factory (GitHub, GitLab, Gitea, Bitbucket).pkg/log/—Loggerinterface (Actionf,Generatef,Waitingf,Successf,Warningf,Failuref).pkg/manifestgen/— manifest generation for install, sync, kustomization, and source secrets.pkg/printers/— specialized printersTablePrinterandDyffPrinter.pkg/status/—StatusCheckerusingfluxcd/cli-utilskstatus polling.pkg/uninstall/—flux uninstalllogic.manifests/— Kustomize bases per controller, RBAC, network policies, CRD references, andscripts/bundle.shwhich runskustomize buildto generatecmd/flux/manifests/.tests/integration/— cloud e2e tests (Azure/GCP) with their owngo.modand Terraform infrastructure.rfcs/— Request for Comments documents for major design proposals and changes.
CLI architecture
Commands are Cobra-based, organized as parent + per-resource children:
- Group files (
create.go,get.go,reconcile.go, etc.) register the parent subcommand. - Per-resource files (
create_kustomization.go,get_helmrelease.go, etc.) register children.
Core interfaces in cmd/flux/ enable generic command implementations:
adapter/copyable/listAdapter— wrap controller API types for generic CRUD.reconcilable— annotate-and-poll pattern for triggering reconciliation.summarisable— generic table output forgetcommands.
Each resource type (e.g. kustomizationAdapter in kustomization.go) wraps the controller API type and implements these interfaces. Follow this pattern when adding new resource support.
Commands interact with the Kubernetes API via internal/utils.KubeClient() → client.WithWatch. internal/utils.NewScheme() registers all six controller API groups plus core k8s types. internal/utils.Apply() implements SSA-based two-phase apply (CRDs/Namespaces first, then remaining objects).
Manifest pipeline
manifests/bases/<controller>/contains a Kustomize base per controller referencing the controller's GitHub release for CRDs and deployment manifests.manifests/install/kustomization.yamlassembles all bases plus RBAC and policies.manifests/scripts/bundle.shrunskustomize buildon each base, writing output tocmd/flux/manifests/(not checked in — generated).- The Makefile
$(EMBEDDED_MANIFESTS_TARGET)runsbundle.shand creates a sentinel filecmd/flux/.manifests.done. cmd/flux/manifests.embed.gouses//go:embed manifests/*.yamlto compile everything into the binary.
When modifying manifests/, always run make build and verify the generated output before committing. Never hand-edit files under cmd/flux/manifests/.
Build, test, lint
All targets in the root Makefile. Go version tracks go.mod.
make tidy— tidy the root module andtests/integration/.make fmt/make vet— run in the root module.make build— buildsbin/flux(CGO disabled, version injected via ldflags). Depends on embedded manifests being generated.make build-dev— builds withDEV_VERSION.make install/make install-dev—go installor copy to/usr/local/bin.make test— unit tests with envtest: runstidy fmt vet install-envtest, thengo test ./... -coverprofile cover.out --tags=unit $(TEST_ARGS).make e2e— e2e tests against a live cluster:go test ./cmd/flux/... --tags=e2e -v -failfast.make test-with-kind— sets up a kind cluster, runs e2e, tears it down.make install-envtest— downloadssetup-envtestand fetches k8s binaries intotestbin/.
Run a single test: make test TEST_ARGS='-run TestCreate -v'.
Codegen and generated files
Check go.mod and the Makefile for current dependency and tool versions. The main codegen pipeline is the manifest bundle:
./manifests/scripts/bundle.shGenerated files (never hand-edit):
cmd/flux/manifests/*.yaml— generated bybundle.shfrommanifests/sources.cmd/flux/.manifests.done— sentinel file tracking bundle state.
Bump fluxcd/pkg/* and controller api modules as a set. Run make tidy after any bump.
Conventions
- Standard
gofmt. All exported names need doc comments. - Command pattern: follow the existing group-parent + per-resource-child cobra structure. New resources need an adapter type implementing
adapter,copyable, and the relevant command interfaces (reconcilable,summarisable, etc.). - Output: stderr for human status messages via
stderrLogger(Unicode symbols:►action,✔success,✗failure,◎waiting,⚠️warning,✚generate). Stdout for machine-readable data (tables, YAML, JSON) viarootCmd.OutOrStdout(). - Global flags: kubeconfig flags come from
k8s.io/cli-runtime/pkg/genericclioptions.ConfigFlags. Client tuning comes fromfluxcd/pkg/runtime/client.Options.FLUX_SYSTEM_NAMESPACEenv var overrides the default namespace. - SSA apply: always use
internal/utils.Apply()(two-phase: CRDs/Namespaces first, then rest). Do not apply manifests directly via the k8s client. - Reconcile triggering: patch
meta.ReconcileRequestAnnotationwith a timestamp, then poll withkstatus.Compute()until ready. Seereconcile.go. - Error handling: return errors from
RunE. Use*RequestErrorwith exit codes for actionable CLI errors. Exit code 1 = warning, anything else = failure. - Flags: use
internal/flags/custompflag.Valuetypes for enum flags (providers, algorithms, sources). Add new enum types there.
Testing
Three test suites with build tags:
- Unit (
//go:build unit): lives incmd/flux/*_test.go. Usescontroller-runtime/envtestfor an in-process fake k8s API. CRDs are loaded fromcmd/flux/manifests/(embedded manifests). Pattern:cmdTestCase{args: "...", assert: assertGoldenFile("testdata/...")}. TheexecuteCommand()helper captures stdout. - E2e (
//go:build e2e): lives incmd/flux/*_test.go. Requires a live cluster viaTEST_KUBECONFIG.TestMainrunsflux installfor setup and teardown. - Integration (
//go:build integration): lives intests/integration/with its owngo.mod. Uses Terraform-provisioned cloud clusters.
Golden files live in cmd/flux/testdata/. Update them with go test ./cmd/flux/... --tags=unit -update.
Run a single unit test: make test TEST_ARGS='-run TestInstall -v'.
Gotchas and non-obvious rules
- The
cmd/flux/manifests/directory is generated, not checked in. It is created bymanifests/scripts/bundle.shand embedded into the binary.make buildandmake testboth trigger the bundle if the sentinel file is stale. kustomizemust be onPATHforbundle.shto work. If you see "command not found" errors during build, install kustomize.internal/utils.NewScheme()registers all six controller API groups. Adding support for a new CRD type means updating the scheme registration there.- The
VERSIONconstant is injected via-ldflagsat build time. In dev builds it defaults to0.0.0-dev.0. The embedded manifest version check (isEmbeddedVersion) determines whetherflux installuses compiled-in manifests or downloads from GitHub. resetCmdArgs()in tests is critical — Cobra persists flag state between test runs. Every test case must reset to avoid pollution.executeCommand()captures stdout only. Stderr output (fromstderrLogger) is not captured in test assertions. If your command's output goes to the wrong stream, tests will silently pass with empty golden files.- The
adapter/listAdapterinterfaces use type assertions internally. If you add a new resource type and forget to implement an interface method, you'll get a runtime panic in the generic command handler, not a compile error. Add interface compliance checks (var _ reconcilable = ...). - Bootstrap commands create real Git commits and push to real repos. E2e tests for bootstrap need careful cleanup. Do not add bootstrap e2e tests without a corresponding teardown.
pkg/packages are importable by external consumers (e.g. Terraform provider, other tools). Treat their exported surface as public API.
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
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.

