agents.md icon indicating copy to clipboard operation
agents.md copied to clipboard

Discussion: standard section for generated-code safety checks

Open dgenio opened this issue 6 months ago • 3 comments

Context

AGENTS.md gives repositories a place to tell coding agents how to work safely and effectively in a codebase.

As coding agents become more autonomous, many repositories will need to specify not only style and workflow rules, but also the checks that generated code must pass before a human reviews it.

Problem

Agent-authored changes can fail in predictable ways:

  • tests not run;
  • generated files committed accidentally;
  • secrets or local paths leaked;
  • package artifacts include unintended files;
  • dependency changes are made without justification;
  • security scanners are skipped;
  • docs/examples drift from code;
  • risky commands are run without permission.

Different repositories can describe these expectations manually, but a common recommended section would make AGENTS.md more useful across tools and projects.

Proposal

Would it make sense to document an optional section for generated-code safety checks?

For example:

## Generated-code safety checks

Before submitting changes, agents should:

- run the project test command: `<command>`;
- run lint/type checks: `<command>`;
- inspect generated/package artifacts: `<command>`;
- check for secrets or local-only paths: `<command>`;
- avoid committing files matching: `<patterns>`;
- summarize dependency changes and why they are needed;
- state which checks could not be run.

The section would remain optional and project-specific. The value would be giving maintainers a predictable place to encode safety expectations.

Use cases

  • More reliable agent-generated PRs.
  • Easier human review.
  • Better behavior across multiple coding agents.
  • Standard place to document project-specific safety gates.
  • Reduced accidental commits of generated artifacts, local files, or secrets.

Non-goals

  • Defining one universal safety policy.
  • Requiring every repository to use the section.
  • Replacing CI.
  • Preventing maintainers from using their own structure.

Open questions

  • Is this too prescriptive for the current scope of AGENTS.md?
  • Should this live in the main example, advanced guidance, or a recipe?
  • Should there be separate sections for "must run", "should run", and "state if unable to run"?
  • Are there existing conventions this should align with?

dgenio avatar May 19 '26 04:05 dgenio

+1 on an optional standardized section for generated-code safety checks.

Placement: I would keep this out of the minimal starter template and add it to advanced guidance (or a recipe page) so small repos are not overwhelmed. The main example could link to the recipe.

Structure: Three sub-bullets might help maintainers without being prescriptive:

  1. Must run before opening a PR — project test command, lint/typecheck.
  2. Must inspect — generated artifacts, dependency diff summary, secret/path scan.
  3. If unable to run — explicit statement of which checks were skipped and why.

Wording sketch (still project-specific placeholders):

## Generated-code safety checks (optional)

Before opening a PR, run:

- Tests: `<command>`
- Lint / types: `<command>`

Before requesting review, inspect:

- Generated or packaged artifacts: `<command or path>`
- Dependency changes: summarize what changed and why
- Secrets and local-only paths: `<command>`

If a check cannot be run in this environment, say which checks were skipped.

Non-goals alignment: This stays documentation-only and does not replace CI. It gives agents a predictable place to echo what CI will eventually enforce, which should make human review faster.

Open question: Should compatibility listings (agents/tools) reference whether they surface this section to users? That could be a separate compatibility-table column later, not part of the first spec change.

Happy to help draft the recipe page or an example snippet if useful.

piyushbag avatar Jun 11 '26 02:06 piyushbag

Proposal: Standard ## Verification Section

I have been working with this pattern in production for several months (see production-agent-workflow template) and wrote up a full spec proposal. Sharing it here for discussion.


Summary

An optional, standardized ## Verification section that gives repository maintainers a predictable place to declare the ordered sequence of checks agents must execute before pushing code.

Why

Agents that generate code without running verification produce PRs that fail CI on first push. Repositories already encode these expectations informally (scattered across READMEs, CI configs, contributor guides). A standard section eliminates ambiguity: maintainers declare what must pass, agents execute it, humans review code that already works.

Proposed Structure

The section uses a fixed heading (## Verification) with an ordered list of named steps, each containing a fenced bash code block:

## Verification

Run these checks in order before pushing. If any step fails, fix and re-run.

1. Formatting

   ```bash
   npm run format:check
  1. Lint

    npm run lint
    
  2. Type check

    npm run typecheck
    
  3. Tests

    npm test
    

### Key Design Decisions

- **Fixed heading name** (`## Verification`) for reliable machine parsing across tools
- **Ordered list** communicates dependency chain (cheap checks first, expensive checks last)
- **Fail-fast semantics** - if any step exits non-zero, subsequent steps do not run; agent fixes and re-runs
- **Platform variants** via bracket qualifiers: `2. Compilation [android]` / `2. Compilation [ios]`
- **Manual checks** in a `### Before requesting review` subsection for items requiring inspection rather than shell commands
- **Nested AGENTS.md** - nearest Verification section takes precedence (replace, not merge)
- **Skip reporting** - agent must state which steps were skipped and why if unable to execute

### Addresses the open questions from this issue

- **"Is this too prescriptive?"** - The section is optional. Repos that do not include it behave exactly as today.
- **"Should there be separate tiers?"** - Yes: ordered command steps (must run), `### Before requesting review` (must inspect), and the skip-reporting requirement (if unable to run).
- **"Are there existing conventions to align with?"** - The production-agent-workflow template has been using this pattern since June 2026. The proposal elevates it into the spec.

### Full Proposal

I have a complete spec document with reference implementations (Kotlin/Android, Node.js), platform variant syntax, nested directory behavior, and compatibility notes. Happy to open a PR with the full text if there is interest in moving this forward.

Reference implementation: https://github.com/dakotafabro/production-agent-workflow/blob/main/conventions/pre-push-checklist.md

dakotafabro avatar Jul 02 '26 20:07 dakotafabro

In contribkit I ended up separating a command being recorded from a command actually being run.\n\nA section should expose both states, including the exit code and any skip reason. A PR body can contain

[email protected] test vitest run --exclude test/cli-smoke.test.ts

RUN v4.1.11 /Users/macos/Desktop/Github

Test Files 10 passed (10) Tests 101 passed (101) Start at 17:29:11 Duration 691ms (transform 807ms, setup 0ms, import 2.40s, tests 737ms, environment 1ms) while no test ran; treating the text as evidence makes the section look complete precisely when it is not.

daichunghy avatar Aug 24 '26 10:08 daichunghy