Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .claude/hooks/stop-file-length.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -eu

MAX_LINES=400

repo_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
if [ -z "$repo_root" ]; then
exit 0
fi
cd "$repo_root"

skip_prefixes='^(artifacts/|benchmarks/CsvBenchmarks/(bin|obj)/|project/(Dataplat\.Dbatools\.Csv|dbatools|dbatools\.Tests)/(bin|obj)/|var/(misc|third-party-licenses)/|\.claude/)'
binary_re='\.(7z|dll|exe|gif|gz|ico|jpe?g|nupkg|pdb|pdf|png|snupkg|ttf|vsix|woff2?|zip)$'

violations=""

while IFS= read -r path; do
[ -n "$path" ] || continue
norm=${path//\\//}

if [[ "$norm" =~ $skip_prefixes ]]; then continue; fi
if [[ "$norm" =~ $binary_re ]]; then continue; fi
[ -f "$norm" ] || continue

if grep -qIl '' "$norm" 2>/dev/null; then
lines=$(wc -l < "$norm" | tr -d ' ')
if [ "$lines" -gt "$MAX_LINES" ]; then
violations="${violations} ${lines} lines: ${norm}"$'\n'
fi
fi
done < <(git ls-files --cached --others --exclude-standard)

if [ -n "$violations" ]; then
{
echo "Files exceed ${MAX_LINES}-line limit. Split structurally before finishing:"
echo ""
printf "%s" "$violations"
} >&2
exit 2
fi

exit 0
16 changes: 16 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PROJECT_DIR:-.}\"/.claude/hooks/stop-file-length.sh",
"timeout": 15,
"statusMessage": "Checking file lengths (400-line limit)..."
}
]
}
]
}
}
42 changes: 42 additions & 0 deletions .codex/hooks/stop-file-length.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -eu

MAX_LINES=400

repo_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
if [ -z "$repo_root" ]; then
exit 0
fi
cd "$repo_root"

skip_prefixes='^(artifacts/|benchmarks/CsvBenchmarks/(bin|obj)/|project/(Dataplat\.Dbatools\.Csv|dbatools|dbatools\.Tests)/(bin|obj)/|var/(misc|third-party-licenses)/|\.claude/)'
binary_re='\.(7z|dll|exe|gif|gz|ico|jpe?g|nupkg|pdb|pdf|png|snupkg|ttf|vsix|woff2?|zip)$'

violations=""

while IFS= read -r path; do
[ -n "$path" ] || continue
norm=${path//\\//}

if [[ "$norm" =~ $skip_prefixes ]]; then continue; fi
if [[ "$norm" =~ $binary_re ]]; then continue; fi
[ -f "$norm" ] || continue

if grep -qIl '' "$norm" 2>/dev/null; then
lines=$(wc -l < "$norm" | tr -d ' ')
if [ "$lines" -gt "$MAX_LINES" ]; then
violations="${violations} ${lines} lines: ${norm}"$'\n'
fi
fi
done < <(git ls-files --cached --others --exclude-standard)

if [ -n "$violations" ]; then
{
echo "Files exceed ${MAX_LINES}-line limit. Split structurally before finishing:"
echo ""
printf "%s" "$violations"
} >&2
exit 2
fi

exit 0
16 changes: 16 additions & 0 deletions .codex/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"${CODEX_PROJECT_DIR:-.}\"/.codex/hooks/stop-file-length.sh",
"timeout": 15,
"statusMessage": "Checking file lengths (400-line limit)..."
}
]
}
]
}
}
Loading
Loading