Skip to content

feat(agents): generate a GEMINI.md pointer stub #1845

Closed

Description

@dan-petty

Friction

This is step 3 of 8 of the OpenSpec adoption decided in issue #1753 and docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md. The adoption exists so that project planning is consistent across agent workflows: Claude Code, Gemini CLI and Copilot read one set of planning conventions. Today only two of the three get a pointer to AGENTS.md.

  • devops ai agents generates AGENTS.md, a CLAUDE.md stub for Claude Code and a .github/copilot-instructions.md stub for Copilot (DEFAULT_AGENT_FILES in src/devops_cli/ai/instruction_generator.py).
  • Gemini CLI loads GEMINI.md by default and reads AGENTS.md only when context.fileName is configured, so a Gemini CLI session started in a fresh clone does not see the rules in AGENTS.md, including the change-folder rules the later steps add.
  • generate_instruction_content picks the stub by a string test (target_file == CONST_CLAUDE_MD_FILENAME, then "copilot" in target_file), and generate_pointer_stub adds the @AGENTS.md import line only when filename == CONST_CLAUDE_MD_FILENAME. A third tool through those branches adds a third special case in two places.

Evidence

The ADR's Design (Agent files and openspec/config.yaml) records the Gemini CLI behavior from its documentation. The existing byte-for-byte guard is test_instruction_stubs_byte_equal_to_generator in tests/test_agents_md_claims.py, and test_generate_pointer_stub in tests/test_instruction_generator.py covers the stub's content. The AGENTS.md character budget is 40,000 and this step ends at 39,979 with the ADR's wording.

Feasibility to confirm in the change's proposal: that Gemini CLI expands an @AGENTS.md import line in GEMINI.md (read its documentation and record the version), as the ADR assumes.

Existing tool considered

The existing generator and its stub template are extended; no new generator is built. Gemini CLI's own context.fileName setting is the alternative, rejected because it is per-user configuration, not something a fresh clone carries.

The change

  • src/devops_cli/ai/instruction_generator.py: a CONST_GEMINI_MD_FILENAME = "GEMINI.md" beside CONST_CLAUDE_MD_FILENAME, a DEFAULT_AGENT_FILES entry "Pointer stub redirecting Gemini CLI to AGENTS.md", and the stub choice in generate_instruction_content and generate_pointer_stub driven by a table keyed on the filename (title, tool name, canonical relative path, whether it carries the @AGENTS.md import line) instead of another branch.
  • The generated GEMINI.md at the repository root, in the shape of CLAUDE.md (the @AGENTS.md import line, the pointer note and the pre-1.0 alpha notice), written by devops ai agents and not by hand.
  • AGENTS.md: the canonical-source note names GEMINI.md beside CLAUDE.md and .github/copilot-instructions.md. The file ends this step at 39,979 of its 40,000 characters.
  • The documentation inventory in src/devops_cli/config/constants.py lists GEMINI.md in class generated, like CLAUDE.md, so devops docs check and the inventory test pass.
  • devops docs generate --sync-readme for the generated references the change touches.

What it deletes

The two string-test branches in generate_instruction_content and the filename == CONST_CLAUDE_MD_FILENAME special case in generate_pointer_stub, replaced by the table.

Tests

  • tests/test_agents_md_claims.py: test_instruction_stubs_byte_equal_to_generator covers GEMINI.md byte for byte.
  • tests/test_instruction_generator.py: test_generate_pointer_stub covers the Gemini stub (title, tool name, @AGENTS.md, link to ./AGENTS.md, the alpha notice for this project and its absence for another), and scaffold_agent_instructions with no files argument writes GEMINI.md and skips an existing one without --force.
  • The documentation inventory test classifies GEMINI.md.

Dependencies

Depends on the item titled "feat(openspec): scaffold OpenSpec and gate its change folders in devops ci". The stub itself does not need the scaffold, but the AGENTS.md edits of the sequence are measured one on top of the other, so this item follows it.

Planning record: this item is planned under the current rules (a task file).

Acceptance criteria

  • uv run devops ai agents in this repository writes GEMINI.md, and the committed file is identical to the generator's output.
  • GEMINI.md points to AGENTS.md and carries the @AGENTS.md import line.
  • Choosing a stub no longer branches on the file name in two places.
  • AGENTS.md's canonical-source note names GEMINI.md, and the file stays within its 40,000-character cap (39,979 with the ADR's wording).
  • devops docs check and devops ci pass.

Proposed design

Problem statement

The devops-cli project needs to generate a GEMINI.md pointer stub to ensure that the Gemini CLI agent can properly read AGENTS.md rules. Currently, only two of the three supported agents (Claude Code and Copilot) receive a pointer to AGENTS.md, while Gemini CLI does not, causing inconsistencies in project planning conventions.

Acceptance criteria

  • Criterion 1: uv run devops ai agents in this repository writes GEMINI.md, and the committed file is identical to the generator's output.
    Verification: Run uv run devops ai agents and verify that GEMINI.md is generated with content matching the expected stub format.
  • Criterion 2: GEMINI.md points to AGENTS.md and carries the @AGENTS.md import line.
    Verification: Check that the generated GEMINI.md file contains an @AGENTS.md import line pointing to the canonical AGENTS.md file.
  • Criterion 3: Choosing a stub no longer branches on the file name in two places.
    Verification: Verify that the logic for selecting which stub to generate has been refactored to use a lookup table instead of string tests.
  • Criterion 4: AGENTS.md's canonical-source note names GEMINI.md, and the file stays within its 40,000-character cap (39,979 with the ADR's wording).
    Verification: Confirm that AGENTS.md includes a reference to GEMINI.md in its canonical source section and verify that it does not exceed the character limit.
  • Criterion 5: devops docs check and devops ci pass.
    Verification: Run devops docs check and devops ci commands to ensure they complete successfully without errors.

Key questions

  • What is the current mechanism for generating stub files?: The existing generator in src/devops_cli/ai/instruction_generator.py uses string tests (target_file == CONST_CLAUDE_MD_FILENAME, then "copilot" in target_file) to choose which stub to generate, and generate_pointer_stub adds the @AGENTS.md import line only when filename == CONST_CLAUDE_MD_FILENAME. A third tool through those branches adds a third special case in two places. [sources: src/devops_cli/ai/instruction_generator.py]
  • How will the new GEMINI.md stub be implemented?: A CONST_GEMINI_MD_FILENAME = "GEMINI.md" will be added beside CONST_CLAUDE_MD_FILENAME, a DEFAULT_AGENT_FILES entry for a pointer stub redirecting Gemini CLI to AGENTS.md, and the stub choice in generate_instruction_content and generate_pointer_stub driven by a table keyed on the filename instead of string tests. (proposed) [sources: src/devops_cli/ai/instruction_generator.py]
  • What are the requirements for AGENTS.md's character budget?: The AGENTS.md character budget is 40,000 and this step ends at 39,979 with the ADR's wording. [sources: src/devops_cli/ai/instruction_generator.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1753

Activity

  1. added
    source/agent
    type/feature
    on Oct 22, 2026
  2. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/feature. The candidate introduces a new feature to generate a GEMINI.md pointer stub, which aligns with the 'feat' prefix in its title.
    • Priority: P2-Medium. This is part of a multi-step adoption of OpenSpec and enhances consistency across agent workflows, but is not critical or urgent.
    • Value: Medium. Improves consistency and usability for developers working with different AI agents but does not introduce core functionality or fix an immediate issue.
    • Effort: Medium. Requires modifications to the instruction generator, addition of new constants, and updates to tests, but builds upon existing code and tools.
  3. added this to the v0.2.39 milestone on Oct 22, 2026
  4. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at ae8c2d9 (see proposed design in issue body).

  5. added a commit that references this issue on Oct 22, 2026
    f3b1748
  6. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1915, merged into release/v0.2.39 as f3b1748.

    Cause
    Gemini CLI loads GEMINI.md by default. It reads AGENTS.md only through its context.fileName setting. A session in a fresh clone did not see the rules of AGENTS.md. The command devops ai agents also read a second copy of the file table, _AGENT_FILES, so a change to DEFAULT_AGENT_FILES alone would not have written GEMINI.md.

    Change
    The generator writes a GEMINI.md pointer stub. The stub holds the import line @./AGENTS.md. This is the form that the Gemini CLI documentation shows at v0.65.0. The documentation states the syntax as @file.md and shows only forms that start with ./, ../ or /. The source of that tag also accepts the bare form, so both work. The CLAUDE.md stub keeps @AGENTS.md, the form of the Claude Code documentation. One table, POINTER_STUBS, holds the title, the tool name, the link and the import line of each stub. It replaces two string tests on the file name. The command now reads DEFAULT_AGENT_FILES, and the change deletes the second copy. The inventory, the notes in AGENTS.md, the knowledge base pages, ADR 0010 and the generated documentation name the third stub. The ADR 0010 quote of the import line for GEMINI.md changes to the documented form. The task file docs/agent/tasks/task-1845-gemini-md-pointer-stub.md and the fragment changelog.d/1845.md are included.

    Existing tool considered
    The devops ai agents generator already writes the other two stubs. A committed .gemini/settings.json with context.fileName is the other option. It works only in a trusted…

    22 file(s) changed.

    How it was verified

    Check runs at fc921e5:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Fail-to-Pass Check: pass
    • Fail-to-Pass Self-Check: pass
    • Analyze (python): pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Dependency Freshness: skipping
    • Service Image: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-1845-gemini-md-pointer-stub.md:

    • uv run devops ai agents in this repository writes GEMINI.md. The committed file equals the output of the generator: test_instruction_stubs_byte_equal_to_generator and test_ai_agents_command_scaffolds_instructions.
    • GEMINI.md points to AGENTS.md and holds the @./AGENTS.md import line, and CLAUDE.md keeps @AGENTS.md: test_generate_pointer_stub and test_instruction_content_for_each_pointer_stub_comes_from_its_table_row.
    • The choice of a stub no longer branches on the file name in two places. One table decides the title, the tool, the link and the import line. A leading ./ still selects the stub: test_instruction_content_for_a_stub_path_ignores_a_leading_dot_slash.
    • devops ai agents --file GEMINI.md writes the stub alone and makes no model call: test_ai_agents_file_option_writes_only_the_gemini_stub_without_a_model_call.
    • A scaffold with no file list writes GEMINI.md. It skips an existing one without --force: test_scaffold_agent_instructions and test_scaffold_agent_instructions_skips_an_existing_gemini_stub_without_force. The devcontainer init and post-create tests also check that GEMINI.md is written.
    • The canonical-source note of AGENTS.md, and of the generated AGENTS.md, links every stub of POINTER_STUBS. AGENTS.md stays under its cap: test_the_canonical_source_note_links_every_pointer_stub and test_agents_md_stays_within_character_budget.
    • The inventory lists GEMINI.md as generated, and devops docs check passes: test_the_generated_class_is_what_the_generator_writes.
    • Seven changes to the code each make a named test fail, and a restore of the code makes it pass again. The changes remove the import line of the Gemini row, give the Gemini row the bare form @AGENTS.md, drop the Gemini entry of DEFAULT_AGENT_FILES, drop the ./ handling, drop Gemini from the file table of commands/ai.py, drop GEMINI.md from the inventory and drop the GEMINI.md link from the canonical-source notes.
    • changelog.d/1845.md records the change. CHANGELOG.md and docs/ROADMAP.md stay as they are.
    • Pending a person: in a fresh clone, start Gemini CLI v0.65.0 or later with your own account and run /memory show. Check that the text of AGENTS.md is in the context. If it is not, file a defect that names the version.
    • Pending a person: repeat the /memory show check in a folder that Gemini CLI does not trust. Report whether the project GEMINI.md loads there. The source check covered the settings file and not this case.
    • Pending a person: say whether a committed .gemini/settings.json with context.fileName should replace this stub. The section "Evidence" shows that it works only in a trusted workspace.
  7. added a commit that references this issue on Oct 23, 2026
    f209f6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions