Skip to content

Migrate skills to .agents and trim GEMINI.md - #3295

Merged
CydeWeys merged 1 commit into
google:masterfrom
CydeWeys:trim-gemini-md-and-fix-skills
Dec 5, 2026
Merged

CydeWeys merged 1 commit into
google:masterfrom
CydeWeys:trim-gemini-md-and-fix-skills

Conversation

@CydeWeys

@CydeWeys CydeWeys commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

AI coding agents and reviewers working across fork-based workflows currently hit
four recurring sources of friction: repository skills sit in a legacy directory
that standard Git workspaces do not auto-discover, local diff and formatting
checks overwrite remote tracking refs or diff against stale fork bases,
redundant checklists and contradictory rules bloat always-on context toward
per-file truncation limits, and commit messages often bury why a change matters
beneath low-level file mechanics. Consolidating and trimming the repository
engineering guide, relocating skills to the standard discovery directory, making
fork-point detection strictly read-only, and requiring plain-English motivation
at the top of every commit eliminate these failure modes. As a result, agents
discover repository skills automatically without mutating developer Git remotes,
always-on instructions stay comfortably below truncation caps, and reviewers can
grasp the purpose and value of every pull request on first read.

Summary of Changes

  1. GEMINI.md (20,649 B -> 18,118 B, down from 28,125 B pre-Harden Gemini skills and tighten GEMINI.md #3284):
    • Keeps the guide comfortably below the 24,000 B per-file truncation cap
      while preserving all invariants added in Harden Gemini skills and tighten GEMINI.md #3284, Add explicit state-machine rules and checks #3301, and Enforce upstream/master rebase in PR polisher #3312 (including
      Sync & Rebase onto upstream/master).
    • Updates Commit Message Style so commit and PR bodies open with 2–4
      plain-English sentences stating why the change is being made, what
      problem, waste, or risk exists today, and what concrete outcome
      improves—before naming classes, flags, or implementation mechanics
      ("what"/"how").
    • Replaces the rigid push ban with a default push gate (halt at local commit
      unless overridden by a user-level rule or an explicit directive to
      open/update a PR; use --force-with-lease on amended branches; never
      chain remote transfers with git commit).
    • Resolves internal contradictions: recommends a fixed static
      Instant.parse(...) constant in reTransact test helpers (instead of
      clock.now()) and statically imported formatInstant(...) from
      DateTimeUtils.
    • Preserves both Reviewable footer formats (the HTML-comment Reviewable
      block and This change is https://reviewable.io/reviews/...), deduplicates
      the pre-commit pr-polisher checklist into a concise pointer to
      .agents/skills/pr-polisher/SKILL.md, and keeps a single concise
      Continuous Improvement bullet under Common Pitfalls & Efficiency.
  2. Migrate repo skills from .gemini/skills/ to .agents/skills/:
    • Moves pr-polisher (including check_diff_test.py from Add scoped AGENTS.md rules and static guardrails #3311) and
      java-ast-refactoring into .agents/skills/ so agents automatically
      discover them in Git workspaces, updating all path references (including
      SCRIPT_PATH in check_diff.py).
    • Removes duplicated Continuous Improvement sections from both SKILL.md
      files (previously instructing agents to commit skill edits inside
      unrelated PRs), keeping the single concise Continuous Improvement bullet
      in GEMINI.md, and fixes YAML 1.2 frontmatter quoting in
      .agents/skills/pr-polisher/SKILL.md (removing internal VCS wording).
  3. Read-only merge-base & pr-polisher fixes:
    • Removes the git update-ref mutation of refs/remotes/origin/master from
      .agents/skills/pr-polisher/scripts/check_diff.py and replaces hardcoded
      HEAD^ diffs (including check_protostuff_cached_entities()) with a
      read-only get_diff_base() helper selecting the fresher merge-base across
      upstream/master and origin/master (gracefully catching
      CalledProcessError on shallow or unrelated remote refs and falling back
      to refs/heads/master, covered in check_diff_test.py).
    • Updates java-format/google-java-format-git-diff.sh (findForkPoint())
      to pick the fresher merge-base across fully qualified
      refs/remotes/upstream/master and refs/remotes/origin/master read-only
      (falling back cleanly on shallow/unrelated refs via || true and
      propagating errors via forkPoint=$(findForkPoint) || exit 1).
    • Fixes the self-contradictory DateTimeUtils.formatInstant(...) message in
      check_diff.py to recommend statically importing formatInstant(...),
      and aligns the Instant.now() message with GEMINI.md.

Verification

  • python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v: 11/11
    passed.
  • python3 .agents/skills/pr-polisher/scripts/check_diff.py: 0 errors, 0
    warnings (spotlessCheck and javaIncrementalFormatCheck passed).
  • ./gradlew --no-daemon runPresubmits: BUILD SUCCESSFUL.
  • Verified strict YAML frontmatter parsing on all .agents/skills/*/SKILL.md
    files, bash -n java-format/google-java-format-git-diff.sh, and zero
    remaining .gemini/skills references across the repository.

BUG=http://b/588443833


This change is Reviewable

@CydeWeys
CydeWeys requested a review from jicelhay November 24, 2026 21:00
@CydeWeys
CydeWeys enabled auto-merge November 24, 2026 21:00
@CydeWeys
CydeWeys force-pushed the trim-gemini-md-and-fix-skills branch 2 times, most recently from 2022ed7 to 60b7d0f Compare November 26, 2026 00:20
@CydeWeys
CydeWeys requested a review from gbrodman December 1, 2026 22:07

@gbrodman gbrodman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbrodman partially reviewed 8 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on jicelhay).

@gbrodman gbrodman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbrodman partially reviewed 3 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on jicelhay).

AI coding agents and reviewers working across fork-based workflows currently hit
four recurring sources of friction: repository skills sit in a legacy directory
that standard Git workspaces do not auto-discover, local diff and formatting
checks overwrite remote tracking refs or diff against stale fork bases,
redundant checklists and contradictory rules bloat always-on context toward
per-file truncation limits, and commit messages often bury why a change matters
beneath low-level file mechanics. Consolidating and trimming the repository
engineering guide, relocating skills to the standard discovery directory, making
fork-point detection strictly read-only, and requiring plain-English motivation
at the top of every commit eliminate these failure modes. As a result, agents
discover repository skills automatically without mutating developer Git remotes,
always-on instructions stay comfortably below truncation caps, and reviewers can
grasp the purpose and value of every pull request on first read.

1. **`GEMINI.md` (`20,649 B` -> `18,118 B`, down from `28,125 B` pre-google#3284):**
    - Keeps the guide comfortably below the `24,000 B` per-file truncation cap
      while preserving all invariants added in google#3284, google#3301, and google#3312 (including
      `Sync & Rebase onto upstream/master`).
    - Updates `Commit Message Style` so commit and PR bodies open with 2–4
      plain-English sentences stating why the change is being made, what
      problem, waste, or risk exists today, and what concrete outcome
      improves—before naming classes, flags, or implementation mechanics
      ("what"/"how").
    - Replaces the rigid push ban with a default push gate (halt at local commit
      unless overridden by a user-level rule or an explicit directive to
      open/update a PR; use `--force-with-lease` on amended branches; never
      chain remote transfers with `git commit`).
    - Resolves internal contradictions: recommends a fixed static
      `Instant.parse(...)` constant in `reTransact` test helpers (instead of
      `clock.now()`) and statically imported `formatInstant(...)` from
      `DateTimeUtils`.
    - Preserves both Reviewable footer formats (the HTML-comment Reviewable
      block and `This change is https://reviewable.io/reviews/...`), deduplicates
      the pre-commit `pr-polisher` checklist into a concise pointer to
      `.agents/skills/pr-polisher/SKILL.md`, and keeps a single concise
      `Continuous Improvement` bullet under `Common Pitfalls & Efficiency`.
2. **Migrate repo skills from `.gemini/skills/` to `.agents/skills/`:**
    - Moves `pr-polisher` (including `check_diff_test.py` from google#3311) and
      `java-ast-refactoring` into `.agents/skills/` so agents automatically
      discover them in Git workspaces, updating all path references (including
      `SCRIPT_PATH` in `check_diff.py`).
    - Removes duplicated `Continuous Improvement` sections from both `SKILL.md`
      files (previously instructing agents to commit skill edits inside
      unrelated PRs), keeping the single concise `Continuous Improvement` bullet
      in `GEMINI.md`, and fixes YAML 1.2 frontmatter quoting in
      `.agents/skills/pr-polisher/SKILL.md` (removing internal VCS wording).
3. **Read-only merge-base & `pr-polisher` fixes:**
    - Removes the `git update-ref` mutation of `refs/remotes/origin/master` from
      `.agents/skills/pr-polisher/scripts/check_diff.py` and replaces hardcoded
      `HEAD^` diffs (including `check_protostuff_cached_entities()`) with a
      read-only `get_diff_base()` helper selecting the fresher merge-base across
      `upstream/master` and `origin/master` (gracefully catching
      `CalledProcessError` on shallow or unrelated remote refs and falling back
      to `refs/heads/master`, covered in `check_diff_test.py`).
    - Updates `java-format/google-java-format-git-diff.sh` (`findForkPoint()`)
      to pick the fresher merge-base across fully qualified
      `refs/remotes/upstream/master` and `refs/remotes/origin/master` read-only
      (falling back cleanly on shallow/unrelated refs via `|| true` and
      propagating errors via `forkPoint=$(findForkPoint) || exit 1`).
    - Fixes the self-contradictory `DateTimeUtils.formatInstant(...)` message in
      `check_diff.py` to recommend statically importing `formatInstant(...)`,
      and aligns the `Instant.now()` message with `GEMINI.md`.

Verification:
- `python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v`: `11/11`
  passed.
- `python3 .agents/skills/pr-polisher/scripts/check_diff.py`: `0` errors, `0`
  warnings (`spotlessCheck` and `javaIncrementalFormatCheck` passed).
- `./gradlew --no-daemon runPresubmits`: `BUILD SUCCESSFUL`.
- Verified strict YAML frontmatter parsing on all `.agents/skills/*/SKILL.md`
  files, `bash -n java-format/google-java-format-git-diff.sh`, and zero
  remaining `.gemini/skills` references across the repository.

BUG=http://b/588443833

Signed-off-by: Ben McIlwain <mcilwain@google.com>
@CydeWeys
CydeWeys force-pushed the trim-gemini-md-and-fix-skills branch from 3cfb4d9 to 7912b45 Compare December 5, 2026 00:26
@CydeWeys
CydeWeys added this pull request to the merge queue Dec 5, 2026
Merged via the queue into google:master with commit a9902f1 Dec 5, 2026
15 of 16 checks passed
@CydeWeys
CydeWeys deleted the trim-gemini-md-and-fix-skills branch December 5, 2026 04:01
CydeWeys added a commit to CydeWeys/nomulus that referenced this pull request Dec 5, 2026
After migrating repository skills to `.agents/skills/` (google#3295), adding scoped
`AGENTS.md` guides (google#3311), and adding the on-demand `pr-review` skill (google#3313),
a full audit of all agent instructions and skill scripts uncovered remaining
duplication, always-on context bloat, mis-routed/stale rules, and four concrete
guardrail bugs: `check_diff.py` silently missed Valkey Protostuff fields on
`@MappedSuperclass` parents and inline-annotated fields, `core/AGENTS.md`
scoped the Netty `retainedDuplicate()` rule away from `proxy/` (its primary
caller), `run_rewrite.sh` silently exited `0` on Gradle failure without cleanup
traps, and `check_diff_test.py` never ran in presubmits or CI. Centralizing
review rules into `pr-review`, moving `core/`-only rules out of root
`GEMINI.md`, correcting stale Gradle/Spotless instructions, and fixing the
guardrail scripts close these blind spots while cutting always-on `GEMINI.md`
by 22%.

Specifically, this change:
- **Centralizes PR review rules in `.agents/skills/pr-review/SKILL.md`:**
  - `GEMINI.md` (`18,118 B` -> `14,071 B`): replaces duplicated `Processing PR
    Feedback` and `PR Description Sync` bullets with a 1-line pointer to
    `.agents/skills/pr-review/SKILL.md`.
  - `.agents/skills/pr-polisher/SKILL.md`: removes Step 9 (paginated PR review
    comment fetch), renumbers Step 10 -> 9, and adds `pr-review` negative
    routing to frontmatter `description`.
  - `console-webapp/AGENTS.md`: removes `## Review Calibration`, moving
    `Shared State` and `Build & Screenshots` into `pr-review` while keeping
    `Nested @if` as an Angular template authoring rule.
  - `core/AGENTS.md`: trims the review-only parenthetical from `JPQL Timestamp
    Ordering`.
  - `.agents/skills/pr-review/SKILL.md`: adds `### Nomulus Review Calibration`
    under `Conducting PR Reviews`.
- **Re-scopes always-on rules and fixes stale build/formatting docs:**
  - Moves `Netty Retry Buffers` (`ByteBufHolder.retainedDuplicate()`) out of
    `core/AGENTS.md` into `GEMINI.md`'s Netty lifecycle bullet so `proxy/`,
    `networking/`, `prober/`, and `core/` all load it; removes the verbatim
    duplicated `console-webapp` sentence from `GEMINI.md`.
  - Moves `core/`-only idioms (CLI/Beam/`TestRegistryToolComponent`, model
    layering, `@GetterDelegate` sets, partial JSON updates, JAXB optional
    attributes, allocation tokens, Console actions, CSV output, time-projected
    entities, Valkey Protostuff compatibility, and async pipeline boundaries)
    from `GEMINI.md` into `core/AGENTS.md`, fixes exact `monthly_logs.sql` /
    `monthly_logs_test.sql` paths, and condenses `2-PR Schema Split` in
    `GEMINI.md`.
  - Corrects `spotlessApply` (`*.gradle` only) vs. `javaIncrementalFormatApply`
    (Java formatting & import order) and `checkstyleMain`/`checkstyleTest`, and
    replaces backend compile commands that triggered Docker `:core:buildToolImage`
    or `console-webapp` `npmInstallDeps` across `GEMINI.md`, `pr-polisher`, and
    `java-ast-refactoring`.
- **Hardens guardrail scripts and wires unit tests into presubmits:**
  - `.agents/skills/pr-polisher/scripts/check_diff.py` (+ `SKILL.md` &
    `check_diff_test.py`): adds the 4 missing Protostuff `@MappedSuperclass`
    parents (`UpdateAutoTimestampEntity`, `GracePeriodBase`,
    `DomainDsDataBase`, `BaseTransferObject`), strips leading inline
    `@Annotation(...)` tokens instead of skipping annotated field lines, skips
    Java comment lines in anti-pattern checks (while still catching
    `/* package */`), fixes `fqn_pattern` capturing so full FQNs print, scopes
    `check_commit_message()` `[OK]` to local errors, and expands internal-leak
    checks to cover `//depot/configs` and `cl/<digits>` (`15/15` unit tests).
  - `config/presubmits.py`: adds `verify_agent_scripts()` so
    `check_diff_test.py` runs automatically on `./gradlew runPresubmits` and CI.
  - `.agents/skills/java-ast-refactoring/scripts/run_rewrite.sh`: adds
    `set -euo pipefail`, an `EXIT` cleanup trap for temporary files, and
    portable top-level `^name:` YAML extraction via `awk`.

Verification:
- `python3 .agents/skills/pr-polisher/scripts/check_diff_test.py -v`: `15/15`
  passed.
- `python3 .agents/skills/pr-polisher/scripts/check_diff.py`: `0` errors, `0`
  warnings (`spotlessCheck` and `javaIncrementalFormatCheck` passed).
- `./gradlew --no-daemon runPresubmits`: `BUILD SUCCESSFUL` (includes running
  `check_diff_test.py` via `verify_agent_scripts()`).
- Strict `PyYAML` parse OK on all `.agents/skills/*/SKILL.md` files, `bash -n`
  on `run_rewrite.sh`, and `0` lines > 80 chars in `core/AGENTS.md` and
  `console-webapp/AGENTS.md`.

BUG=http://b/593117423

Signed-off-by: Ben McIlwain <mcilwain@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants