Files
portal/.claude/settings.json
T
Дмитрий 99a242c9ed feat(hook): remind db/CHANGELOG_schema.md on db/schema.sql edits (PostToolUse)
PostToolUse hook на Edit|Write matcher — emits stdout reminder если file path
matches regex `(^|/)db/schema\.sql$` (Windows backslashes normalized к `/`).

Runtime enforcement существующего правила CLAUDE.md §5 п.8:
"Не править db/schema.sql без записи в db/CHANGELOG_schema.md."

Self-review (§8) ловит это поздно (после ≥3 групп правок); hook — сразу,
в transcript stdout vs stderr (visible alongside markdownlint output).

Параллельный entry в hooks.PostToolUse array — Claude Code processes oба
markdownlint (для .md без CLAUDE.md) + schema reminder (для db/schema.sql)
независимо на каждом Edit|Write.

Edge case: Bash-обход (echo ... >> db/schema.sql) не покрывается —
known limitation, документировано в spec §4.6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 07:52:10 +03:00

73 lines
2.5 KiB
JSON

{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm install:*)",
"Bash(npm run lint:md:*)",
"Bash(npm run spell:*)",
"Bash(npm run links:*)",
"Bash(npm run lint:css:*)",
"Bash(npm run a11y:*)",
"Bash(npm run check:docs:*)",
"Bash(npm run lint:md:fix:*)",
"Bash(npm run sast:*)",
"Bash(git status)",
"Bash(git diff)",
"Bash(git log:*)",
"Bash(git add:*)",
"Bash(node --version)",
"Bash(npm --version)",
"Bash(npx --version)",
"Bash(./bin/gitleaks:*)",
"Bash(./bin/lychee:*)",
"PowerShell(Get-ChildItem:*)",
"PowerShell(Test-Path:*)",
"PowerShell(Expand-Archive:*)",
"Read(**)",
"Glob(**)",
"Grep(**)"
],
"deny": [
"Bash(rm -rf:*)",
"Bash(git push --force:*)",
"Bash(git reset --hard:*)",
"Bash(npm publish:*)",
"PowerShell(Remove-Item:*-Recurse*)",
"PowerShell(Set-ExecutionPolicy:* -Scope LocalMachine*)"
]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "node -e \"const f=process.env.CLAUDE_FILE_PATH||''; const pd=process.env.CLAUDE_PROJECT_DIR||''; const path=require('path'); if (f && pd && path.resolve(f) === path.resolve(pd, 'CLAUDE.md')) { process.stderr.write('\\n[hook] WARNING: Direct edit of root CLAUDE.md detected. Per CLAUDE.md §5 п.10, prefer /claude-md-management:revise-claude-md or /claude-md-management:claude-md-improver. If invoked via that skill, this warning is informational.\\n'); }\""
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "node -e \"const f=process.env.CLAUDE_FILE_PATH||''; if(/\\\\.md$/i.test(f) && !/CLAUDE\\\\.md$/i.test(f)) { require('child_process').spawnSync('npx',['-y','markdownlint-cli2','--fix',f],{stdio:'inherit',shell:true}); }\""
}
]
},
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "node -e \"const f=process.env.CLAUDE_FILE_PATH||''; const n=f.replace(/\\\\\\\\/g,'/'); if (/(^|\\\\/)db\\\\/schema\\\\.sql$/i.test(n)) { process.stdout.write('\\n[hook] REMINDER: You modified db/schema.sql. Per CLAUDE.md §5 п.8, add a corresponding entry to db/CHANGELOG_schema.md before committing.\\n'); }\""
}
]
}
]
}
}