Skip to content

post-write-size-guard.sh

来自 cli/templates/level-2/

bash
#!/usr/bin/env bash
set -euo pipefail
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')

# Only check TS/TSX files
case "$file_path" in
  *.ts|*.tsx)
    if [ -f "$file_path" ]; then
      lines=$(wc -l < "$file_path")
      if [ "$lines" -gt 300 ]; then
        echo "WARNING: $file_path has ${lines} lines, exceeding the 300-line limit. Consider splitting." >&2
        exit 1
      fi
    fi
    ;;
esac
exit 0

面向个人开发者的 AI 辅助编程工程化方案