Skip to content

feat(ai): a generated AGENTS.md routes to the shared guidelines #5536

Open

Description

@dan-petty

Problem or Motivation

The guidelines in docs/guidelines/ (SRE, production readiness, Kubernetes, agentic jobs) apply to each managed project. An agent in another repository does not find them: devops ai agents adds a "Where to look" row only for a local file that exists (CONST_AGENTS_MD_ROUTES in src/devops_cli/config/constants.py). A copy of each guideline in each repository would drift.

Proposed Solution & Architectural Design

  1. Add CONST_DOCS_SITE_URL with the value of site_url of zensical.toml, and CONST_GUIDELINES_INDEX = docs/guidelines/index.md, the section page that lists each guideline.
  2. AGENTS.md.j2 gets one fixed row: "apply a shared guideline". The row has 1 link: the local path of the index when it exists in the project (devops-cli), else <site_url>docs/guidelines/. The row names no topic and no file, so a new guideline changes no AGENTS.md, and a hand copy of the row in an existing AGENTS.md cannot drift.
  3. A repository with an AGENTS.md keeps its file (devops ai agents does not overwrite it without --force). The production readiness guideline gets a row "AGENTS.md routes to the shared guidelines", which the readiness report (feat(roadmap): report production readiness in the project review #5537) measures and which prints the row to add.
  4. The row must keep the scaffold under CONST_AGENTS_MD_MAX_CHARS (4,500). docs(ai): trim the rules of the devops ai agents template #5430 measured 4,206 characters for the template and trims it; this item changes the same template, so the later of the two rebases on the other.
  5. Update the knowledge base page of the instructions scaffolding.

Related: #5430 (the same template). The guideline index comes from the amendment of PR #5492.

Target Subsystem

AI & Agentic Review Pipeline

Existing Tool Considered

  • GitHub default community health files (a public .github repository) share only fixed files, such as CONTRIBUTING.md and SECURITY.md. They do not share other documents.
  • A link to the published page needs no tool.

Cost to build: about 25 lines with tests, about 50k tokens, about 2 hours.

Acceptance Criteria

  • A test: generate_agents_md for a project with no docs/guidelines/index.md gives the row with the site URL of the index.
  • A test: for a project that has the index, the row gives its relative path.
  • A test: CONST_DOCS_SITE_URL equals site_url of zensical.toml.
  • tests/invariants/test_agents_md.py passes, with the size test on the scaffold that has every routed document.

Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches surfaced only rulesync, a generator that copies one set of rules into each repository's AGENTS.md; it cannot emit one fixed row that links the published guidelines index, so no tool covers the need.

Covers:

  • Generates AGENTS.md and other agent rule files from one source
  • Writes rule files for several agent tools
  • Keeps rule content identical across repositories

Lacks:

  • No single fixed row linking a published guidelines index
  • No choice between a local index path and the docs site URL
  • Copies guideline text into each repository, so copies drift

Proposed design

Problem statement

An agent in another managed repository does not find the guidelines in docs/guidelines/ of devops-cli. devops ai agents adds a "Where to look" row only for a local file that exists (CONST_AGENTS_MD_ROUTES), so no row points at the shared guidelines, and a copy of each guideline in each repository would drift. This item adds one fixed row to the generated AGENTS.md that links the published guidelines index (the local index when the target holds it, else the docs site), and one constant that holds the site URL the row needs.

Acceptance criteria

Requirement: The shared guideline row for a project with no index

A generated AGENTS.md MUST route the task "apply a shared guideline" to the published guidelines index when the target holds no docs/guidelines/index.md.

Scenario: A target with no guideline index

  • WHEN A test calls generate_agents_md(parse_project_metadata(tmp_path)) for a temporary project that has no docs/guidelines/index.md.
  • THEN The "Where to look" table holds one row whose task is "apply a shared guideline" and whose link is <CONST_DOCS_SITE_URL>docs/guidelines/.

Requirement: The shared guideline row for a project with the index

A generated AGENTS.md MUST route that task to the local docs/guidelines/index.md (CONST_GUIDELINES_INDEX) when the target holds the file.

Scenario: A target with the guideline index

  • WHEN A test calls generate_agents_md(parse_project_metadata(tmp_path)) for a temporary project that holds docs/guidelines/index.md.
  • THEN The row for the task links docs/guidelines/index.md, and the link resolves on disk.

Requirement: A new guideline leaves AGENTS.md unchanged

The generated row MUST NOT name a guideline topic or a guideline file.

Scenario: A guideline is added

  • WHEN A test generates the AGENTS.md of a temporary project, adds docs/guidelines/a-new-guideline.md, and generates it again.
  • THEN The two generated texts are equal.

Requirement: The docs site URL constant

CONST_DOCS_SITE_URL MUST hold the base URL of the published docs site, so that <CONST_DOCS_SITE_URL>docs/guidelines/ is the published guideline index.

Scenario: The constant matches the site settings

  • WHEN A person runs uv run devops gh pages verify in the repository that holds docs/guidelines/index.md.
  • THEN The command passes and reports that the site_url of zensical.toml equals CONST_DOCS_SITE_URL.

Requirement: The invariants of the generated AGENTS.md

The change MUST keep tests/invariants/test_agents_md.py passing, with the fixed row counted in the routing table and the scaffold that holds every routed document at or below CONST_AGENTS_MD_MAX_CHARS.

Scenario: The invariants of the generated file

  • WHEN A person runs uv run pytest tests/invariants/test_agents_md.py.
  • THEN The file passes: the generated table holds the fixed row, and the scaffold with every routed document is at most 4,500 characters.

Requirement: The knowledge base page names the row and the constant

The change MUST update the knowledge base page of the instruction scaffolding with the fixed row and the site URL constant.

Scenario: The instruction scaffolding page

  • WHEN A test reads src/devops_cli/ai/knowledge_base/devops_cli/tasks/agent_instructions_scaffolding.md.
  • THEN The page names the "apply a shared guideline" row and CONST_DOCS_SITE_URL.

Existing Tool Considered

The alternatives check of 2026-11-17 gives the verdict none; the closest open, maintained tool it considered is dyoshikawa/rulesync (MIT, last activity 2026-11-17), and the Lacks: list of that check's block in the issue body states what the tool lacks. The change builds one template row and one constant. Written cost, from the issue body: about 25 lines with tests, about 50k tokens, about 2 hours.

Key questions

  • How does generate_agents_md build the route table of an AGENTS.md today, and what caps the file size?: CONST_AGENTS_MD_ROUTES at src/devops_cli/config/constants.py:212 holds each routed path with the task it owns, in table order. parse_project_metadata at src/devops_cli/ai/instruction_generator.py:174 keeps only the paths that exist in the target, in ProjectMetadata.routed_documents (src/devops_cli/ai/instruction_generator.py:97), and generate_agents_md at src/devops_cli/ai/instruction_generator.py:246 renders one row for each of them; it receives the metadata only, not the target path. CONST_AGENTS_MD_MAX_CHARS at src/devops_cli/config/constants.py:209 caps the file at 4,500 characters, and tests/invariants/test_agents_md.py:174 holds the size test. [sources: src/devops_cli/config/constants.py:209, src/devops_cli/config/constants.py:212, src/devops_cli/ai/instruction_generator.py:97, src/devops_cli/ai/instruction_generator.py:174, src/devops_cli/ai/instruction_generator.py:246, tests/invariants/test_agents_md.py:174]
  • Where does the generator decide the link of the shared-guideline row?: parse_project_metadata is the only function that knows the target path, so it records whether CONST_GUIDELINES_INDEX (docs/guidelines/index.md) exists in a new ProjectMetadata field, and generate_agents_md passes the chosen link to AGENTS.md.j2 as one template variable: docs/guidelines/index.md when the target holds it, else <CONST_DOCS_SITE_URL>docs/guidelines/. The row text stays fixed in the template and names no guideline topic and no guideline file. (best practice) [sources: src/devops_cli/ai/instruction_generator.py:97, src/devops_cli/ai/instruction_generator.py:174, src/devops_cli/ai/instruction_generator.py:217, src/devops_cli/ai/instruction_generator.py:246, src/devops_cli/templates/AGENTS.md.j2:34]
    • Chosen: Record the index in parse_project_metadata and pass the link to the template. generate_agents_md receives no path, and parse_project_metadata already tests each routed path against the resolved target (src/devops_cli/ai/instruction_generator.py:217); the template then renders one fixed row for every project.
    • Rejected: Add the row to CONST_AGENTS_MD_ROUTES. That table writes a row only for a path that exists, so a project without the index gets no row at all (src/devops_cli/ai/instruction_generator.py:217).
    • Rejected: Write the absolute URL as a literal row in AGENTS.md.j2. devops-cli's own copy of the row would then point at the site, not at its local index, and no variable could change it.
  • Where does the published docs site URL come from, and what proves it matches zensical.toml?: CONST_DOCS_SITE_URL in src/devops_cli/config/constants.py holds the site_url of zensical.toml (https://dan-petty.github.io/devops-cli/, zensical.toml:13), because devops ai agents runs against another repository that has no zensical.toml. devops gh pages verify already reads zensical.toml and reports site_url (src/devops_cli/github/pages.py:78), so it gains one comparison: in the repository that holds docs/guidelines/index.md (the one that publishes the guidelines) it passes only when that site_url equals CONST_DOCS_SITE_URL, and a managed project's own site is not compared with it. The live check uv run devops gh pages verify then proves the two agree, and the same pull request amends the github-pages requirement (openspec/specs/github-pages/spec.md:35). (best practice) [sources: src/devops_cli/config/constants.py:261, zensical.toml:13, src/devops_cli/github/pages.py:78, openspec/specs/github-pages/spec.md:35, docs/guidelines/index.md]
    • Chosen: A constant, compared by devops gh pages verify in the repository that holds the guideline index. The command already reads zensical.toml and prints site_url (src/devops_cli/github/pages.py:78), and only the repository that publishes the guidelines mirrors that URL.
    • Rejected: Read site_url from zensical.toml when the command runs. A managed project holds no zensical.toml, so the command would have no URL for it.
    • Rejected: A test that parses zensical.toml. The project refuses a new test that reads a committed config file (docs/TESTING.md:62, tests/gate/tree_checks/config_values.py:80), so the agreement goes to the command that already reads the file.
  • Does docs/guidelines/index.md exist, and does it list each guideline?: Yes. docs/guidelines/index.md:5 lists each of the four guidelines (agentic jobs, Kubernetes, production readiness, SRE), and tests/invariants/test_guidelines.py fails when a guideline of the folder has no line in the index. The page defines a guideline as a rule that applies with no change to each managed project and states that the docs site publishes it. [sources: docs/guidelines/index.md:3, docs/guidelines/index.md:5, tests/invariants/test_guidelines.py, CONTEXT.md]
  • Does devops ai agents overwrite an AGENTS.md that a repository already holds?: No. src/devops_cli/commands/ai.py:986 refuses to overwrite an existing AGENTS.md without --force, so a repository that holds its own file keeps it; --force replaces it with the generic router. [sources: src/devops_cli/commands/ai.py:986, CHANGELOG.md:4975]
  • Does the new row wait for docs(ai): trim the rules of the devops ai agents template #5430, which trims the same template?: No. CONST_AGENTS_MD_MAX_CHARS caps the file at 4,500 characters and tests/invariants/test_agents_md.py:174 fails when the scaffold grows past it, so the size test is the gate. docs(ai): trim the rules of the devops ai agents template #5430 and this item change the same template, so the later pull request rebases on the other. (best practice) [sources: src/devops_cli/config/constants.py:209, tests/invariants/test_agents_md.py:174]
    • Chosen: Land in either order and rebase the later pull request. The size test decides whether the row fits, and the cap is already at 4,500 characters.
    • Rejected: Wait for docs(ai): trim the rules of the devops ai agents template #5430 to merge first. It delays the row for a merge order that a rebase settles, and the size test already guards the cap.
  • Is the row in the production readiness guideline part of this item?: No. The guideline already holds the row: OWN-7 at docs/guidelines/production-readiness.md:39 says AGENTS.md routes the agents to the shared guidelines, with a link to the guideline index in its "Where to look" table, and that table is its measure. Nothing remains to add to the guideline here; the report of feat(roadmap): report production readiness in the project review #5537 that reads the row is that item's work, so the deferral is dropped. (best practice) [sources: docs/guidelines/production-readiness.md:39]
    • Chosen: Keep the guideline row out of this item because it already exists. OWN-7 already states the row and its measure, so a new issue would carry no work.
    • Rejected: Defer the guideline row to a new issue that waits on feat(roadmap): report production readiness in the project review #5537. The row exists, so the deferred issue would duplicate OWN-7.
  • Is the knowledge base page of the instruction scaffolding generated or hand-written?: Hand-written. The page is src/devops_cli/ai/knowledge_base/devops_cli/tasks/agent_instructions_scaffolding.md, and no generator writes it: devops docs generate writes only docs/commands/*.md and docs/CLI_REFERENCE.md (.tuicrignore:6). The change edits the page; it does not regenerate it. [sources: src/devops_cli/ai/knowledge_base/devops_cli/tasks/agent_instructions_scaffolding.md:5]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/ai
    status/new
    value/medium
    effort/low
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches found only rule-file generators that build per-repo AGENTS.md copies and a closed beta sync service that writes files into each repo; none points an agent at a published guidelines index, so the template row and URL constant are the work.

    Tool: none found

    Lacks:

    • No tool emits an AGENTS.md row linking a published guidelines index
    • Sync tools write per-repo copies, the drift the issue rules out
    • GitHub community health files share only fixed file names
    • Hosted sync needs an account, API key and private files, not a public page
    Searches (10)

    Tools considered:

    Searches run:

    • AGENTS.md open standard agent instructions file spec, results: 5
    • share AGENTS.md guidelines across repositories tool sync, results: 5
    • rulesync CLI sync AI agent rules AGENTS.md github, results: 5
    • agents.md open format ai coding agents instructions, results: 5
    • llms.txt standard documentation for LLMs, results: 5
    • "AGENTS.md" repository github, results: 5
    • generate AGENTS.md template from docs site URL python, results: 5
    • single source of truth documentation across multiple repositories include remote markdown, results: 5
    • AGENTS.md guidelines index published docs link, results: 5
    • rulesync, results: 5

    Sources:

    A person decides what this check of 2026-11-17 means for the item.

  5. added
    status/ready
    and removed
    status/new
    on Nov 18, 2026
  6. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

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

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

    effort/lowpriority/p2-mediumscope/aisource/agentstatus/readytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions