prometheus-engine
AGENTS.md232 starsChanged 57 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). * License Headers: Every new code, YAML, Dockerfile, or script file…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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
14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
11
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 34
Run make conform (or validate against the rules above if Docker is unavailable) before pushing.
- Very specific: line 37
Keep PRs focused on a single logical change.
- Distinctive: line 45
Never edit generated files solely by hand: If you modify any of the following sources, you must regenerate derivatives:
- Very specific: line 61
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 80
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 82
Never rely on Go map iteration order or unsorted Kubernetes list orders when generating Secret data, collector configs, or CRD statuses.
- Distinctive: line 84
Check for nil pointers when iterating over optional CRD/relabel pointer slices.
- Very specific: line 85
When polling Kubernetes API resources in e2e/ or pkg/operator/, only ignore transient apierrors.IsNotFound(err) errors rather than …
- Very specific: line 88
Keep existing pointer helpers (ptr.To(...), proto.Bool(...)) rather than rewriting to new(expr) (modernize.newexpr is intentionally …
- Very specific: line 99
When adding or updating a replace directive (e.g., for github.com/prometheus/prometheus, client_golang, common, or thanos), keep the …
- Distinctive: line 104
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 16,595 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 limits:
- Full header (
<type>(<scope>): <description>): max 89 characters. <description>part alone: max 80 characters.
- 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 & Backportability
- Keep PRs focused on a single logical change. Do not mix unrelated refactoring, formatting, or major dependency upgrades into bug-fix or security-fix PRs so changes can be cleanly cherry-picked to release branches (
release/0.19,release/0.18, etc.).
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/*.yamlandcmd/datasource-syncer/datasource-syncer.yaml. - 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) using .golangci.yml (default: all).
- 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 BuildKit cache mounts (
--mount=type=cache,target=/go/pkg/modand--mount=type=cache,target=/root/.cache/go-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.
- 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.

