Skip to content

Harden .claude/agents/committer.md: run pre-commit explicitly instead of trusting installed hooks #14

Description

@DenWin

Problem

The shipped committer agent (.claude/agents/committer.md) treats hook execution as implicit: it stages, commits, and only reacts if a hook fails. On a clone where pre-commit install was never run — bootstrap is explicit by design — git commit executes zero hooks, so the agent truthfully observes "no hook failures" for checks that never ran and reports a clean commit. Companion to #13 (which proposes the general conventions); this is the concrete agent-level fix.

Proposal

Insert a verification step between staging and committing, so the numbered procedure becomes stage → verify → commit:

  1. Verify the staged files against the hooks EXPLICITLY: run pre-commit run --files <the staged paths> and gate on its exit code. Never rely on git commit to trigger installed hooks — on a clone where pre-commit install was never run, git commit executes zero hooks and nothing warns. If a hook fails or modifies files, report the hook output verbatim and stop. Never use --no-verify and never edit files to "fix" a failure; that is the lead agent's call.

Explicit invocation behaves identically on initialized and uninitialized clones, which closes the silent-no-op gap for agent-driven commits entirely. A downstream repo has applied exactly this wording to its committer agent and it works with the existing step 5 (report-and-stop on failure) unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions