Skip to content

feat(hooks): add config protection hook to prevent linter config manipulation #733

@federicodeponte

Description

@federicodeponte

Problem

Agents frequently modify linter/formatter configs (.eslintrc, biome.json, .prettierrc, .ruff.toml, etc.) to make checks pass instead of fixing the actual code. This is a known failure mode documented in the community but not addressed by any existing hook.

Proposed Solution

A PreToolUse hook on Write|Edit that blocks modifications to linter/formatter config files with a steering message:

#!/bin/bash
set -euo pipefail
FILE_PATH=$(jq -r '.tool_input.file_path // .tool_input.file // empty')
[[ -z "$FILE_PATH" ]] && exit 0
BASENAME=$(basename "$FILE_PATH")
case "$BASENAME" in
  .eslintrc*|.prettierrc*|biome.json|.ruff.toml|ruff.toml|\
  .shellcheckrc|.stylelintrc*|.markdownlint*)
    echo "BLOCKED: Do not modify linter/formatter config to pass checks. Fix the code instead." >&2
    exit 2
    ;;
esac
exit 0

This is a common issue across Claude Code setups. We built and tested this hook: buildingopen/blast-radius has the pattern, and it is running in production.

Happy to PR this if there is interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions