agentleFS
Google CloudKnown publisherGoogleCloudPlatform/prometheus-engine/AGENTS.md

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
  1. Very specific:

    Every commit in a pull request is strictly validated in CI by Sidero Labs Conform via .conform.yaml.

    line 9
  2. Very specific:

    Start <description> with an imperative verb (e.g., add, fix, bump, update, remove, sort, scope, ignore, wait, revert — never added, fixed, …

    line 23
  3. Very specific:

    Never end the commit header line with a ..

    line 27
  4. Very specific:

    Run make conform (or validate against the rules above if Docker is unavailable) before pushing.

    line 33
  5. Distinctive:

    Keep PRs focused on a single logical change.

    line 37
  6. Distinctive:

    Keep PR descriptions concise, unslopped, and focused on why the change is needed rather than low-level details of what changed.

    line 38
  7. Distinctive:

    Never edit generated files solely by hand: If you modify any of the following sources, you must regenerate derivatives:

    line 46
  8. Very specific:

    Every new code, YAML, Dockerfile, or script file (outside third_party/ and vendor/) must include the standard Google LLC Apache 2.0 license …

    line 62
  9. Very specific:

    All Go comments (scope: all) must end with a period (.), except comments starting with TODO or Kubernetes code-gen markers starting with +.

    line 81
  10. Very specific:

    Never rely on Go map iteration order or unsorted Kubernetes list orders when generating Secret data, collector configs, or CRD statuses.

    line 83
  11. Distinctive:

    Check for nil pointers when iterating over optional CRD/relabel pointer slices.

    line 85
  12. Very specific:

    When polling Kubernetes API resources in e2e/ or pkg/operator/, only ignore transient apierrors.IsNotFound(err) errors rather than …

    line 86
  13. Very specific:

    Keep existing pointer helpers (ptr.To(...), proto.Bool(...)) rather than rewriting to new(expr) (modernize.newexpr is intentionally …

    line 89
  14. Very specific:

    When adding or updating a replace directive (e.g., for github.com/prometheus/prometheus, client_golang, common, or thanos), keep the …

    line 100
  15. Distinctive:

    Avoid introducing external dependencies if the standard library can achieve the desired functionality, to keep the dependency footprint …

    line 106

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

  1. Allowed <type> values: feat, fix, build, chore, ci, docs, perf, refactor, revert, style, test
  2. 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
  3. Imperative mood (imperative: true): Start <description> with an imperative verb (e.g., add, fix, bump, update, remove, sort, scope, ignore, wait, revert — never added, fixed, adds, fixes, updating).
  4. Lowercase start (case: lower): The first character of <description> after : must be lowercase (e.g., feat(ops): allow gmpctl to work without gh CLI, not feat(ops): Allow ...).
  5. No trailing period (invalidLastCharacters: .): Never end the commit header line with a ..
  6. Length limit:
    • Full header (<type>(<scope>): <description>): max 120 characters (conventional.descriptionLength is also set to 120 to override conform's 72-character default so only the full header limit applies).
  7. US English Spellcheck (spellcheck.locale: US): conform spellchecks the entire commit header and body using a US English dictionary. Avoid typos or unknown informal abbreviations in prose.
  8. 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/ -> regenerates pkg/operator/generated/, charts/operator/crds/, manifests/setup.yaml, and doc/api.md.
    • Helm templates/values under charts/ -> regenerates manifests/*.yaml, cmd/datasource-syncer/datasource-syncer.yaml, and examples/inject-gmp-sidecar.sh.
    • Any *.md file at the root, cmd/**/*.md, or ops/gmpctl/*.md -> formatted via mdox fmt --soft-wraps.
    • Bash scripts (hack/presubmit.sh, ops/gmpctl/lib.sh) -> formatted via shfmt -l -w.
  • Fast local formatting:

    ./hack/presubmit.sh format
  • Full regeneration (CRDs, Helm manifests, API docs, formatting, license headers):

    make regen
  • License Headers: Every new code, YAML, Dockerfile, or script file (outside third_party/ and vendor/) 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).

  1. Mandatory Import Aliases (importas): Unaliased imports of the following packages fail golangci-lint:
    • k8s.io/api/apps/v1 -> must be aliased as appsv1
    • k8s.io/api/meta/v1 -> must be aliased as metav1
    • k8s.io/apimachinery/pkg/api/errors -> must be aliased as apierrors
    • github.com/GoogleCloudPlatform/prometheus-engine/pkg/operator/apis/monitoring/v1 -> must be aliased as monitoringv1
  2. Comments Must End with a Period (godot): All Go comments (scope: all) must end with a period (.), except comments starting with TODO or Kubernetes code-gen markers starting with +.
  3. 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.
  4. Defensive Error & Nil Handling:
    • Check for nil pointers when iterating over optional CRD/relabel pointer slices.
    • When polling Kubernetes API resources in e2e/ or pkg/operator/, only ignore transient apierrors.IsNotFound(err) errors rather than swallowing all errors (so RBAC or validation errors fail immediately).
  5. Go Language Idioms & Test Contexts:
    • In tests, use t.Context() rather than context.Background() so test contexts are automatically canceled when the test finishes.
    • Keep existing pointer helpers (ptr.To(...), proto.Bool(...)) rather than rewriting to new(expr) (modernize.newexpr is intentionally disabled in .golangci.yml).

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).

  1. Go Version & GOTOOLCHAIN=local Parity: Component Dockerfiles (cmd/*/Dockerfile, examples/instrumentation/go-synthetic/Dockerfile) build with GOTOOLCHAIN=local. Never bump the go directive in go.mod or tools/go.mod to a version newer than the golang:<version> builder image in the Dockerfiles (or vice versa).
  2. replace Directives & Pins in go.mod: When adding or updating a replace directive (e.g., for github.com/prometheus/prometheus, client_golang, common, or thanos), keep the require and replace versions consistent and document the reason for the pin in a comment directly above the replace entry.
  3. Dockerfile Efficiency & BuildKit Caching:
    • Scope COPY directives in cmd/<component>/Dockerfile to only the required paths (go.mod, go.sum, pkg/, internal/, cmd/<component>/) rather than copying the entire repository or all of cmd/.
    • 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 entire RUN instruction 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 Dockerfile starts 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 the go build step runs with GOPROXY=off. Keep that preamble byte-identical across Dockerfiles, and copy charts/, tools/ and sources only after it. BuildKit may garbage-collect cache mounts between docker build invocations (observed on GitHub runners), whereas an evicted layer is rebuilt with retries. Build tools such as yq are installed as native host binaries (CGO_ENABLED=0 go -C tools install …) before any target GOOS/GOARCH is set, so multi-arch builds do not cross-compile them. Wrap any new network download in a Dockerfile or CI script with hack/retry.sh.
  4. 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.md
    • make lint — Run golangci-lint.
    • make conform — Validate commit messages against .conform.yaml.
    • ./hack/presubmit.sh format — Tidy all go.mods, run go fmt, mdox fmt, and shfmt.
  • Code & Manifest Regeneration: .gemini/skills/code-generation.md
    • make 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.md
    • NO_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.md
    • make 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.md
    • NO_DOCKER=1 make bin — Compile all component binaries locally to ./build/bin/.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.