agentleFS
valkey-iovalkey-io/valkey-operator/.agents/skills/pre-pr-review/SKILL.md

pre-pr-review

Skill432 starsChanged 13 days agoApache-2.0View on GitHub

Use before opening a valkey-operator PR, to validate the current branch on a fresh kind cluster and review its diff (e.g. "/pre-pr-review", "check my branch before I raise a PR", "kind-validate my change").

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create the cluster: Always a fresh one, with its own kubeconfig.

    line 22
  2. Very specific:

    When a fix forces a rebuild mid-run, tag each new image review-<slug>-r2, -r3 and so on.

    line 56
  3. Very specific:

    When the diff changes what the operator renders into pods or their ConfigMaps (pod template, volumes, scripts, ConfigMap keys), include an …

    line 59
  4. Very specific:

    Report: Run git check-ignore -q .review/<slug>.md.

    line 93

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “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
SKILL.md

Pre-PR review

Validate the contributor's branch on a fresh kind cluster, review its diff, and write a report plus a Testing block for the PR description. Report findings; the contributor decides what to change.

Workflow

  1. Resolve the target. The current branch, as it is on disk. Run git fetch https://github.com/valkey-io/valkey-operator.git main and take git merge-base HEAD FETCH_HEAD as <base>. Fetching by URL gets upstream main whatever the contributor's remotes are called, and avoids diffing against a stale fork main. Stop and tell the contributor if HEAD is on main, or if git rev-list --count <base>..HEAD prints 0 and git status --porcelain prints nothing.

    Save git status --porcelain to /tmp/review-<slug>-status.before and git diff | sha256sum to /tmp/review-<slug>-diff.before. If the status prints anything, carry on and mark the run dirty: the image builds from the working tree, so uncommitted changes are part of the review.

    Derive <slug> from the branch name: lowercase it, replace each run of characters outside a-z0-9 with -, trim to 40 characters, strip leading and trailing -. feat/Zone-Pinning becomes feat-zone-pinning. The cluster is review-<slug>.

  2. Understand the change. Read git diff <base> (commits plus uncommitted changes) and git log <base>..HEAD. git diff leaves out untracked files, which the image still builds from, so also read each file git ls-files --others --exclude-standard lists that belongs to the change, and include them in step 4's review. For each issue referenced in the commit messages (Fixes #n, Closes #n), read it with gh issue view <n> --repo valkey-io/valkey-operator --comments when gh is installed; otherwise ask the contributor for the issue and its repro steps. Done when you can list (a) every behaviour the diff changes, each with a scenario that exercises it, including one that reproduces the issue's original failure, and (b) the cluster shape those scenarios need: node count, zone labels, cert-manager.
  3. Fast checks. Run make lint and make test as separate commands, so a lint failure doesn't skip the tests. Then run hack/check-copyright.sh <base>, CI's check that new Go files carry the current year in their header. The script reads committed files only, so on a dirty run also check the header of each new uncommitted Go file. Record pass or fail, and the failing output, for the report. Continue to step 4 on failure.

    make test runs manifests generate fmt, so it rewrites files the contributor forgot to regenerate or format. Compare git status --porcelain with /tmp/review-<slug>-status.before and git diff | sha256sum with /tmp/review-<slug>-diff.before; the hash catches a rewrite of a file that was already modified, whose status line reads M both times. Run git diff on anything that changed. Report these files that make changed as a "fix first" finding: CI's generated-code check fails on them. Repeat this check after step 6.

  4. Start the static review in the background. On Claude Code, invoke the code-review skill on the diff at medium effort. On other agents, use the agent's own review command, or dispatch a subagent to review git diff <base> for correctness bugs. Give every reviewer the untracked files from step 2 as well as the diff. When the diff or the untracked files from step 2 touch api/, a *_types.go, or config/crd/, also apply every item of the API checklist to those files. The findings feed steps 7 and 9.
  5. Create the cluster. Always a fresh one, with its own kubeconfig. The contributor's ambient kubectl context may point at a real cluster, and make install/deploy/undeploy act on whatever context is current, so the review cluster never touches ~/.kube/config:

    kind delete cluster --name review-<slug>   # clears a leftover from an earlier run
    echo '{"kind": "Cluster", "apiVersion": "kind.x-k8s.io/v1alpha4", "nodes": [{"role": "control-plane"}, {"role": "worker"}, {"role": "worker"}]}' \
      | kind create cluster --name review-<slug> --kubeconfig /tmp/kind-review-<slug>.kubeconfig --config -

    Extend the node list when step 2's cluster shape needs more (zone labels, extra workers). When it needs cert-manager, install the version pinned as certmanagerVersion in test/utils/utils.go:

    export KUBECONFIG=/tmp/kind-review-<slug>.kubeconfig
    kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/<version>/cert-manager.yaml
    kubectl -n cert-manager rollout status deploy --timeout=180s

    The cluster outlives the review.

    From here on, every cluster-touching command, make and kubectl alike, runs with KUBECONFIG=/tmp/kind-review-<slug>.kubeconfig. Shell state may not carry between commands, so set it at the top of each block.

  6. Build and deploy. make deploy rewrites config/manager/kustomization.yaml; the backup and the EXIT trap put back the contributor's version, uncommitted edits included, even when the block fails or is killed. set -e stops the block at the first failure, so a failed build never deploys an image left over from an earlier run.

    set -e
    export KUBECONFIG=/tmp/kind-review-<slug>.kubeconfig
    [ "$(kubectl config current-context)" = kind-review-<slug> ] || exit 1
    cp config/manager/kustomization.yaml /tmp/review-<slug>-kustomization.yaml.bak
    trap 'cp /tmp/review-<slug>-kustomization.yaml.bak config/manager/kustomization.yaml' EXIT
    make docker-build IMG=valkey-operator:review-<slug>
    kind load docker-image valkey-operator:review-<slug> --name review-<slug>
    make install
    make deploy IMG=valkey-operator:review-<slug>
    kubectl -n valkey-operator-system rollout status deploy --timeout=180s

    When a fix forces a rebuild mid-run, tag each new image review-<slug>-r2, -r3 and so on. Reloading the same tag into kind can leave running pods on the old image.

  7. Validate. Exercise each behaviour from step 2 directly: apply CRs, mutate specs, watch conditions and operator logs. At least one scenario must fail without the change. When the static findings arrive, add a scenario for each one the cluster can confirm or refute. Capture every command and its observed output verbatim as you go; the report quotes them. Done when every behaviour from step 2 and every cluster-checkable finding has a scenario with a recorded pass or fail. Delete the CRs you created; keep the cluster.

    When the diff changes what the operator renders into pods or their ConfigMaps (pod template, volumes, scripts, ConfigMap keys), include an upgrade scenario. Build and deploy <base> under its own tag:

    set -e
    export KUBECONFIG=/tmp/kind-review-<slug>.kubeconfig
    [ "$(kubectl config current-context)" = kind-review-<slug> ] || exit 1
    git worktree remove --force /tmp/review-<slug>-base 2>/dev/null || true   # clears a leftover from an aborted run
    git worktree add /tmp/review-<slug>-base <base>
    cd /tmp/review-<slug>-base
    make docker-build IMG=valkey-operator:review-<slug>-base
    kind load docker-image valkey-operator:review-<slug>-base --name review-<slug>
    make install
    make deploy IMG=valkey-operator:review-<slug>-base
    kubectl -n valkey-operator-system rollout status deploy --timeout=180s

    Create a cluster with some data. Then run step 6's block again from the branch, with the newest branch tag. The image reference changes from -base, so the operator rolls onto branch code; check that the Valkey pods roll one at a time with the data kept. Remove the worktree afterwards with git worktree remove --force /tmp/review-<slug>-base; --force is needed because make deploy modified it. This is the only scenario that checks the order of operations on upgrade, such as the ConfigMap updating before the first pod rolls.

    Before marking a static finding refuted, grep test/e2e/ and internal/controller/*_test.go for its scenario and reuse their setup (Secrets, ConfigMaps, cluster shape). Refute only when a working repro shows the behaviour is fine, or the code path is unreachable. A repro that fails for an unrelated reason refutes nothing.

  8. Run the related e2e specs. Grep test/e2e/ for the functions, fields, files and resource names the diff touches, and list the Label(...) values on the matching Describe/Context/It blocks. Pick the narrowest label that covers each match (external-cm, not valkeynode). Each label takes about two minutes. AfterSuite removes the review deployment and the CRDs, so this is the last cluster step:

    set -e
    export KUBECONFIG=/tmp/kind-review-<slug>.kubeconfig
    [ "$(kubectl config current-context)" = kind-review-<slug> ] || exit 1
    cp config/manager/kustomization.yaml /tmp/review-<slug>-kustomization.yaml.bak
    trap 'cp /tmp/review-<slug>-kustomization.yaml.bak config/manager/kustomization.yaml' EXIT
    make undeploy
    KIND_CLUSTER=review-<slug> CERT_MANAGER_INSTALL_SKIP=true \
      E2E_MANAGER_IMAGE=valkey-operator:review-<slug> E2E_SKIP_IMAGE_BUILD=true \
      go test -tags=e2e ./test/e2e/ -v -timeout 40m -ginkgo.label-filter "<label> || <label>"

    E2E_MANAGER_IMAGE reuses the image from step 6 instead of building another; pass the newest tag when step 7 rebuilt (-r2, ...). The 40-minute timeout matches make test-e2e-run; at Go's 10-minute default the process can die before AfterSuite cleans up. BeforeSuite runs make deploy, which rewrites kustomization.yaml; the trap restores it as in step 6. Several labels run for longer than a default tool timeout, so run this block in the background or with a long timeout. Drop CERT_MANAGER_INSTALL_SKIP=true when a selected label needs TLS. Record pass or fail per label.

  9. Report. Run git check-ignore -q .review/<slug>.md; checking the file path works before .review/ exists. If it succeeds, write .review/<slug>.md. Otherwise the branch predates the ignore rule, so write /tmp/review-<slug>.md and say so in the output. Sections, in order:

    1. Verdict: "ready to open" or "fix first", with the reasons
    2. Change summary
    3. Environment: cluster name and config, every image tag built (-base, -r2, ...), <base> and HEAD SHAs, dirty or clean
    4. Fast checks
    5. Validation scenarios: per scenario, purpose, commands, observed output, pass or fail
    6. Related e2e specs: per label, pass or fail
    7. Code review findings
    8. API checklist results, when the diff touches API types. State whether the shape is right for the change, not only whether it works.
    9. Follow-ups

    Then print to the contributor, in this order:

    • A Testing block in a fenced markdown code block, ready to paste under the PR template's ### Testing:

      Validated on kind (`review-<slug>`, image `valkey-operator:review-<slug>`, HEAD `<short-sha>`):
      
      - `make lint`: <pass or fail>
      - `make test`: <pass or fail>
      - <scenario purpose>: <pass or fail>
      - e2e `<label>`: <pass or fail>
    • The report path.
    • The teardown command: kind delete cluster --name review-<slug>.

API checklist

Apply each item to the changed API types and CRDs. The Kubernetes API conventions are the reference.

  • New fields are optional with a documented default, or required with a stated reason.
  • A bool that could grow a third state is an enum.
  • Structured config uses typed fields or a list of named entries, not map[string]string.
  • Enums use +kubebuilder:validation:Enum with CamelCase values.
  • Fields sharing a prefix sit in a nested struct.
  • Status reports state through conditions per docs/status-conditions.md, not ad-hoc bools or message strings.
  • Cross-namespace references carry a stated reason.
  • Spec changes stay compatible with existing CRs; renames and type changes carry a migration note.
  • The change belongs in the API at all, rather than as an operator default.
  • make manifests generate was run, and the CRD diff matches the type diff.

Gotchas

  • make test-e2e chains cleanup-test-e2e, which deletes the kind cluster mid-review; step 8 runs go test directly. The suite brings its own operator: BeforeSuite builds an image (unless E2E_SKIP_IMAGE_BUILD=true), loads it into kind, creates valkey-operator-system (failing if it exists), and runs make deploy; AfterSuite runs make undeploy and make uninstall, removing the review deployment, the CRDs and every CR.
  • Tag images with something other than latest: :latest implies imagePullPolicy: Always, which breaks kind-loaded images.
  • TLS-related changes need cert-manager in the cluster; step 5 installs it. The e2e suite skips its own install when cert-manager is already there.

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.