Skip to content

Sync reviewer guidance into coding-agent instruction files - #162

Open
ebetancourt wants to merge 1 commit into
prooflinedev:mainfrom
ebetancourt:feat/sync-review-guidance
Open

ebetancourt wants to merge 1 commit into
prooflinedev:mainfrom
ebetancourt:feat/sync-review-guidance

Conversation

@ebetancourt

Copy link
Copy Markdown

Why

A repository's Proofline reviewer guidance is the set of rules its pull requests are checked against. Coding agents read AGENTS.md or CLAUDE.md before they write code, but they never see that guidance. They write code that breaks a rule, open a pull request, and the reviewer flags it. If the guidance is in the agent's instruction file, the agent follows the same rules before the pull request exists.

Who it helps

  • Teams that let coding agents open pull requests: fewer findings for rules the agent could have known about.
  • Reviewers who would otherwise flag the same rule on every agent's change.
  • Repository owners: the guidance lives in Proofline and a CI check keeps the instruction files in step with it.

What it adds

  • proofline/guidance.py:
    • apply_review_guidance(text, guidance) -> str adds, replaces or removes one managed block between <!-- proofline:review-guidance:start --> and <!-- proofline:review-guidance:end -->.
    • write_review_guidance(path, guidance, *, check=False) -> bool applies it to a file and returns whether the file changed. With check=True it writes nothing.
    • python -m proofline.guidance [--check] PATH... fetches the guidance once with get_review_guidance and syncs each file. --check prints a unified diff and exits 1 when a file is stale. The IDs come from --organization-id/--repository-id or PROOFLINE_ORGANIZATION_ID/PROOFLINE_REPOSITORY_ID, as in the README's other examples, and the token from PROOFLINE_TOKEN.
  • tests/test_guidance.py: 21 tests, using the repository's loopback Server for the CLI. No network.
  • A README section, "Reviewer guidance for coding agents": why, who it helps, an example, the CI check, and the Python API.

Decisions

  • Standalone functions, not client methods. scripts/contracts.py ties the clients' public methods to API operations, so a helper on the clients would need a contract exception. If you'd rather have them on ProoflineClient and AsyncProoflineClient, the move is small and I'm happy to make it.
  • No guidance means no block. Unset or blank guidance removes the block rather than leaving an empty one in every agent's context, and a missing file is created only when there is guidance to write.
  • Byte-identical outside the block. A replaced block keeps everything around it exactly as it was. A new block is appended after one blank line, and a removed block takes one adjacent blank line with it, so adding guidance and then removing it restores the original file.
  • Line endings and symlinks. The block uses the line ending of the file's first line, so CRLF files stay CRLF, and guidance with CRLF line endings is normalized to match. Files are read and written as bytes in place, so a CLAUDE.md symlinked to AGENTS.md stays a symlink.
  • Malformed markers are refused. A lone, repeated or out-of-order marker, or guidance that contains a marker, raises ValueError. The CLI reads and applies every file before writing any, so one malformed file changes nothing. It exits 2 with the reason, or with the HTTP status and problem detail when the request is refused.
  • The block says where it comes from. Under a ## Proofline review guidance heading, one sentence tells the agent that Proofline reviews pull requests against this guidance and that it is synced, so changes belong in Proofline rather than in the file.
  • The functions accept the API model. guidance can be the RepositoryGuidance that get_review_guidance returns or a string, so callers don't have to handle UNSET.

How it was verified

  • python3 scripts/check.py passes: generated code matches the contract, scripts/contracts.py (operation coverage and outcome vocabulary), ruff check, ruff format --check, mypy proofline scripts, pytest (255 passed), and the wheel and source-distribution install smoke tests.
  • The new tests cover idempotence, replacement in place, removal (including the blank line), missing files, CRLF, a CLAUDE.md symlink to AGENTS.md, each marker error, check mode, and the CLI: one fetch for several files, the diff and exit code of --check, removal when guidance is unset, no writes when one file is malformed, a refused request, and missing IDs.

Add proofline.guidance: apply_review_guidance and write_review_guidance
keep one managed block of the repository's reviewer guidance in files
such as AGENTS.md and CLAUDE.md, and python -m proofline.guidance
[--check] PATH... fetches the guidance once and syncs each file, or
prints a diff and exits 1 when a file is stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant