claude-memory/graph/configurations/cargo-check-post-edit-hook-for-rust-files-in-claude-code-a2d02a.md

1.3 KiB

id type title tags importance confidence created updated
a2d02aea-07fd-4528-8158-f2f42a23a2dd configuration Cargo check post-edit hook for Rust files in Claude Code
sba-scouting
rust
claude-code
hooks
linting
cargo
configuration
developer-experience
0.65 0.8 2026-03-02T00:33:26.804471+00:00 2026-03-02T00:33:26.804471+00:00

Cargo Check Post-Edit Hook Configuration

File

rust/.claude/settings.json

Purpose

Runs cargo check --message-format=short automatically after any Edit or Write to .rs files during a Claude Code session. Provides fast feedback without waiting for a manual build.

Why cargo check (not clippy)

  • cargo clippy is too slow for every single edit (takes several seconds)
  • cargo check is faster — catches type errors and borrow checker issues quickly
  • Clippy should be run manually at logical checkpoints:
    • Before commits
    • After finishing a feature
    • After batch edits to multiple files

Settings JSON Structure

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": { "tool_name": ["Edit", "Write"], "file_paths": [".*\\.rs$"] },
        "hooks": [
          { "type": "command", "command": "cargo check --message-format=short" }
        ]
      }
    ]
  }
}

Documentation

Also documented in rust/CLAUDE.md for future session context.