Skip to content

Claude Code pre-commit hook stamps provenance but doesn't run cargo fmt --check → AI commits pass locally, fail CI Format #438

@avrabe

Description

@avrabe

Friction (hit repeatedly while dogfooding)

AI-agent PRs (e.g. #437) keep failing the Format and Clippy CI jobs on
the first push, even though the change is otherwise correct (Test/Playwright
green). Two compounding reasons:

  1. The Claude Code pre-commit hook only stamps provenance. .claude/settings.json's
    PreToolUse/pre-commit command is rivet stamp all --created-by ai-assisted
    — it does not run cargo fmt --check or clippy. So an agent's commit
    passes the local hook and only discovers fmt/clippy drift after pushing and
    waiting on CI.
  2. The pre-commit framework that does cover this isn't active in fresh
    clones.
    .pre-commit-config.yaml has cargo-fmt (cargo fmt --all -- check) and cargo-clippy (cargo +stable clippy --all-targets -- -D warnings) — exactly the CI gates — but the git hooks are only installed
    after pre-commit install, which an agent/contributor may never run.

Net: the cheapest, most common CI failure (rustfmt) has no fast local guard in
the default agent workflow.

Suggested fix

  • Add a fast cargo fmt --check step to the Claude/agent pre-commit hook
    (it runs in ~1s, and Format is the single most common first-push failure).
    Leave clippy/test out of the per-commit hook (too slow), but a fmt gate alone
    would eliminate most red first-pushes.
  • Optionally document a one-shot pre-commit install --install-hooks (or a
    cargo fmt --check && cargo clippy --all-targets -- -D warnings one-liner) in
    AGENTS.md under a "before you push" heading, since docs/pre-commit.md exists
    but isn't surfaced where agents look.

Note for triagers

cargo clippy ... | grep '^error' is a deceptive local check — CI runs clippy
with -D warnings, so a warning (e.g. doc_lazy_continuation) fails CI while
that grep reports clean. Worth calling out in contributor docs.

Found by an AI agent dogfooding rivet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions