prometheus-engine
AGENTS.md232 starsChanged 22 days agoApache-2.0View on GitHub
This document defines the repository rules, commit policies, coding conventions, and presubmit workflows for AI coding agents contributing to GoogleCloudPlatform/prometheus-engine. Every commit in a pull request is strictly validated in CI by Sidero Labs Conform via .conform.yaml. Every single commit on the branch (not just the PR title) must pass make conform. CI enforces a clean working tree after running code generation and formatting (CHECK=1 make regen in .github/workflows/presubmit.yml).
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 33,398 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
15 rules. About 0 are common, 5 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
10
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 9
Every commit in a pull request is strictly validated in CI by Sidero Labs Conform via .conform.yaml.
- Very specific: line 23
Start <description> with an imperative verb (e.g., add, fix, bump, update, remove, sort, scope, ignore, wait, revert — never added, fixed, …
- Very specific: line 27
Never end the commit header line with a ..
- Very specific: line 33
Run make conform (or validate against the rules above if Docker is unavailable) before pushing.
- Distinctive: line 37
Keep PRs focused on a single logical change.
- Distinctive: line 38
Keep PR descriptions concise, unslopped, and focused on why the change is needed rather than low-level details of what changed.
- Distinctive: line 46
Never edit generated files solely by hand: If you modify any of the following sources, you must regenerate derivatives:
- Very specific: line 62
Every new code, YAML, Dockerfile, or script file (outside third_party/ and vendor/) must include the standard Google LLC Apache 2.0 license …
- Very specific: line 81
All Go comments (scope: all) must end with a period (.), except comments starting with TODO or Kubernetes code-gen markers starting with +.
- Very specific: line 83
Never rely on Go map iteration order or unsorted Kubernetes list orders when generating Secret data, collector configs, or CRD statuses.
- Distinctive: line 85
Check for nil pointers when iterating over optional CRD/relabel pointer slices.
- Very specific: line 86
When polling Kubernetes API resources in e2e/ or pkg/operator/, only ignore transient apierrors.IsNotFound(err) errors rather than …
- Very specific: line 89
Keep existing pointer helpers (ptr.To(...), proto.Bool(...)) rather than rewriting to new(expr) (modernize.newexpr is intentionally …
- Very specific: line 100
When adding or updating a replace directive (e.g., for github.com/prometheus/prometheus, client_golang, common, or thanos), keep the …
- Distinctive: line 106
Avoid introducing external dependencies if the standard library can achieve the desired functionality, to keep the dependency footprint …
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 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
Agent Contribution Guidelines (prometheus-engine)
This document defines the repository rules, commit policies, coding conventions, and presubmit workflows for AI coding agents contributing to GoogleCloudPlatform/prometheus-engine.
1. Commit Message & PR Hygiene (conform)
Every commit in a pull request is strictly validated in CI by Sidero Labs Conform via .conform.yaml. Every single commit on the branch (not just the PR title) must pass make conform.
Commit Header Format
<type>(<optional-scope>): <description>Strict conform Rules
- Allowed
<type>values:feat,fix,build,chore,ci,docs,perf,refactor,revert,style,test - Allowed
<scope>values (if a scope is provided, it must be one of these exact values; otherwise omit the scope):agents,configs,deps,e2e,export,main,operator,prometheus,frontend,datasource-syncer,config-reloader,rule-evaluator,ops - Imperative mood (
imperative: true): Start<description>with an imperative verb (e.g.,add,fix,bump,update,remove,sort,scope,ignore,wait,revert— neveradded,fixed,adds,fixes,updating). - Lowercase start (
case: lower): The first character of<description>after:must be lowercase (e.g.,feat(ops): allow gmpctl to work without gh CLI, notfeat(ops): Allow ...). - No trailing period (
invalidLastCharacters: .): Never end the commit header line with a.. - Length limit:
- Full header (
<type>(<scope>): <description>): max 120 characters (conventional.descriptionLengthis also set to120to overrideconform's 72-character default so only the full header limit applies).
- Full header (
- US English Spellcheck (
spellcheck.locale: US):conformspellchecks the entire commit header and body using a US English dictionary. Avoid typos or unknown informal abbreviations in prose. - Verify locally:
Run
make conform(or validate against the rules above if Docker is unavailable) before pushing.
PR Scope, Descriptions & Backportability
- Optimize PRs for human reviews. Split bigger changes into smaller PRs and stack or chain them.
- Keep PRs focused on a single logical change. Do not mix unrelated fixes, refactoring, formatting, or major dependency upgrades into bug-fix or security-fix PRs; submit unrelated fixes as separate, small PRs. This allows changes to be cleanly cherry-picked to release branches (
release/0.19,release/0.18, etc.). - Keep PR descriptions concise, unslopped, and focused on why the change is needed rather than low-level details of what changed. Reviewers can see what changed in the diff; focus on intent and only provide a high-level change summary.
2. Code Generation, Formatting & Licenses (make regen)
CI enforces a clean working tree after running code generation and formatting (CHECK=1 make regen in .github/workflows/presubmit.yml).
- Never edit generated files solely by hand. If you modify any of the following sources, you must regenerate derivatives:
- Go API types under
pkg/operator/apis/monitoring/v1/-> regeneratespkg/operator/generated/,charts/operator/crds/,manifests/setup.yaml, anddoc/api.md. - Helm templates/values under
charts/-> regeneratesmanifests/*.yaml,cmd/datasource-syncer/datasource-syncer.yaml, andexamples/inject-gmp-sidecar.sh. - Any
*.mdfile at the root,cmd/**/*.md, orops/gmpctl/*.md-> formatted viamdox fmt --soft-wraps. - Bash scripts (
hack/presubmit.sh,ops/gmpctl/lib.sh) -> formatted viashfmt -l -w.
- Go API types under
Fast local formatting:
./hack/presubmit.sh formatFull regeneration (CRDs, Helm manifests, API docs, formatting, license headers):
make regenLicense Headers: Every new code, YAML, Dockerfile, or script file (outside
third_party/andvendor/) must include the standard Google LLC Apache 2.0 license header. Run:go tool -modfile="tools/go.mod" addlicense -ignore 'third_party/**' -ignore 'vendor/**' .
3. Go Coding & Linting Rules (make lint)
Code is checked with golangci-lint (make lint-go) using .golangci.yml (default: all), and Kubernetes API types under pkg/operator/apis/ are also checked with kube-api-linter (make lint-api) via .golangci-kal.yml (make lint runs both).
- Mandatory Import Aliases (
importas): Unaliased imports of the following packages failgolangci-lint:k8s.io/api/apps/v1-> must be aliased asappsv1k8s.io/api/meta/v1-> must be aliased asmetav1k8s.io/apimachinery/pkg/api/errors-> must be aliased asapierrorsgithub.com/GoogleCloudPlatform/prometheus-engine/pkg/operator/apis/monitoring/v1-> must be aliased asmonitoringv1
- Comments Must End with a Period (
godot): All Go comments (scope: all) must end with a period (.), except comments starting withTODOor Kubernetes code-gen markers starting with+. - Deterministic Reconciler & Collector Output:
Never rely on Go map iteration order or unsorted Kubernetes list orders when generating Secret data, collector configs, or CRD statuses. Always sort slices deterministically (e.g.,
slices.SortFunc) so reconcilers do not trigger spurious resource updates. - Defensive Error & Nil Handling:
- Check for nil pointers when iterating over optional CRD/relabel pointer slices.
- When polling Kubernetes API resources in
e2e/orpkg/operator/, only ignore transientapierrors.IsNotFound(err)errors rather than swallowing all errors (so RBAC or validation errors fail immediately).
- Go Language Idioms & Test Contexts:
- In tests, use
t.Context()rather thancontext.Background()so test contexts are automatically canceled when the test finishes. - Keep existing pointer helpers (
ptr.To(...),proto.Bool(...)) rather than rewriting tonew(expr)(modernize.newexpris intentionally disabled in.golangci.yml).
- In tests, use
4. Go Modules, Dependencies & Dockerfiles
This repository contains multiple Go modules (go.mod, tools/go.mod, ops/gmpctl/go.mod, examples/scripts/go.mod, examples/instrumentation/go-synthetic/go.mod).
- Go Version &
GOTOOLCHAIN=localParity: ComponentDockerfiles (cmd/*/Dockerfile,examples/instrumentation/go-synthetic/Dockerfile) build withGOTOOLCHAIN=local. Never bump thegodirective ingo.modortools/go.modto a version newer than thegolang:<version>builder image in theDockerfiles (or vice versa). replaceDirectives & Pins ingo.mod: When adding or updating areplacedirective (e.g., forgithub.com/prometheus/prometheus,client_golang,common, orthanos), keep therequireandreplaceversions consistent and document the reason for the pin in a comment directly above thereplaceentry.- Dockerfile Efficiency & BuildKit Caching:
- Scope
COPYdirectives incmd/<component>/Dockerfileto only the required paths (go.mod,go.sum,pkg/,internal/,cmd/<component>/) rather than copying the entire repository or all ofcmd/. - Preserve the BuildKit build-cache mount (
--mount=type=cache,target=/gocache/build) and keep heavy local data/binary directories (ops/gmpctl/data,ops/.bin) excluded in.dockerignore. Note that BuildKit cache mounts apply to the entireRUNinstruction they are defined on, including all parts of a chained command. - Keep the Go module cache in an image layer, not in a cache mount: every Go
Dockerfilestarts with the same preamble (COPY go.mod go.sum ./,COPY hack/retry.sh,COPY vendor* vendor,ENV GOMODCACHE/GOCACHE/GOTOOLCHAIN,RUN … hack/retry.sh go mod download) so BuildKit shares one module layer across all images, and thego buildstep runs withGOPROXY=off. Keep that preamble byte-identical across Dockerfiles, and copycharts/,tools/and sources only after it. BuildKit may garbage-collect cache mounts betweendocker buildinvocations (observed on GitHub runners), whereas an evicted layer is rebuilt with retries. Build tools such asyqare installed as native host binaries (CGO_ENABLED=0 go -C tools install …) before any targetGOOS/GOARCHis set, so multi-arch builds do not cross-compile them. Wrap any new network download in aDockerfileor CI script withhack/retry.sh.
- Scope
- Dependency Footprint:
- Avoid introducing external dependencies if the standard library can achieve the desired functionality, to keep the dependency footprint minimal.
5. Task-Specific Workflows & Commands
Refer to the repository's task guides under .gemini/skills/ for detailed execution steps:
- Linting, Formatting & Conform:
.gemini/skills/lint-and-format.mdmake lint— Rungolangci-lint.make conform— Validate commit messages against.conform.yaml../hack/presubmit.sh format— Tidy allgo.mods, rungo fmt,mdox fmt, andshfmt.
- Code & Manifest Regeneration:
.gemini/skills/code-generation.mdmake regen— Regenerate CRDs, Helm manifests, API docs, and license headers.CHECK=1 make regen— Verify no uncommitted diffs or missing license headers remain.
- Unit Testing:
.gemini/skills/unit-tests.mdNO_DOCKER=1 make test— Run unit tests natively on the host (fast loop).go test ./pkg/<path>/... -run <TestName>— Run targeted unit tests.
- End-to-End (Kind) Testing:
.gemini/skills/e2e-tests.mdmake e2e— Build images and run the Kind e2e test suite.TEST_RUN=<TestName> make e2e-only— Re-run specific e2e tests without rebuilding images.
- Building Binaries & Images:
.gemini/skills/build-deploy.mdNO_DOCKER=1 make bin— Compile all component binaries locally to./build/bin/.
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.

