{"id":84,"date":"2026-10-24T09:00:00","date_gmt":"2026-10-24T07:00:00","guid":{"rendered":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/"},"modified":"2026-10-16T14:00:12","modified_gmt":"2026-10-16T12:00:12","slug":"a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump","status":"publish","type":"post","link":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/","title":{"rendered":"A Claude Code hook that blocks DB writes without a fresh dump"},"content":{"rendered":"<p>When I moved hoja.in from TYPO3 7.6 to 14.3, Claude Code did a lot of the legwork for me: reading the old database, writing the import script, running the TYPO3 console. That is comfortable until you remember one simple fact. Everything the agent does in files, git can undo. Everything it does in the database, git cannot.<\/p>\n<p>A sentence in a prompt like &#8220;please make a backup first&#8221; is a wish. The model follows it most of the time. &#8220;Most of the time&#8221; is not what I want between me and a broken database. So the rule lives in a hook, and the hook is code that runs every time, no matter what the model thinks.<\/p>\n<h2>What a PreToolUse hook is<\/h2>\n<p>Claude Code can run your own command before a tool call is executed. For the event <code>PreToolUse<\/code> with the matcher <code>Bash<\/code>, your script gets the planned shell command as JSON on stdin, before anything runs. It contains, among others, <code>tool_name<\/code>, <code>tool_input.command<\/code> and <code>cwd<\/code>. Your script then has two ways to answer:<\/p>\n<ul>\n<li><strong>Exit code 2<\/strong> blocks the call. Whatever you print to stderr is given back to Claude as the reason.<\/li>\n<li><strong>Exit code 0 with JSON<\/strong> on stdout gives a finer decision: <code>hookSpecificOutput.permissionDecision<\/code> can be <code>allow<\/code>, <code>deny<\/code> or <code>ask<\/code> (the docs list <code>defer<\/code> too), with a <code>permissionDecisionReason<\/code>.<\/li>\n<\/ul>\n<p>The second form is what I use, because <code>ask<\/code> is very useful: some commands are not wrong, they just need a human to say yes.<\/p>\n<h2>The rules I wanted<\/h2>\n<p>The hook belongs to a small Claude Code plugin I wrote for TYPO3 project upgrades. Its rules are deliberately few:<\/p>\n<ol>\n<li><strong>Deny<\/strong> TYPO3 commands that write the database (<code>extension:setup<\/code>, <code>upgrade:run<\/code>, <code>upgrade:mark:undone<\/code>, <code>database:updateschema<\/code>), also when they come through <code>ddev exec<\/code>, unless a dump younger than 24 hours exists in <code>.project-migration\/backups\/<\/code> or <code>.ddev\/db_snapshots\/<\/code>.<\/li>\n<li><strong>Ask<\/strong> for anything that removes or replaces data: destructive schema changes, <code>ddev import-db<\/code>, <code>ddev delete<\/code>, <code>DROP DATABASE<\/code>, <code>DROP TABLE<\/code>, <code>TRUNCATE<\/code>.<\/li>\n<li><strong>Deny<\/strong> two shortcuts that hide failures: <code>git commit --no-verify<\/code> and Composer&#8217;s <code>--ignore-platform-req<\/code> options.<\/li>\n<\/ol>\n<p>Everything else passes. The hook should not make the agent useless, only stop the few commands that cannot be undone.<\/p>\n<h2>The script<\/h2>\n<p>Here is the core of it, shortened to the dump check. It needs <code>jq<\/code>.<\/p>\n<pre><code class=\"language-bash\">#!\/usr\/bin\/env bash\n# .claude\/hooks\/guard-db.sh - PreToolUse hook for Bash\nset -euo pipefail\n\npayload=\"$(cat)\"\ncmd=\"$(printf '%s' \"$payload\" | jq -r '.tool_input.command \/\/ empty')\"\ncwd=\"$(printf '%s' \"$payload\" | jq -r '.cwd \/\/ empty')\"\n[[ -z \"$cmd\" ]] &amp;&amp; exit 0\n[[ -n \"$cwd\" &amp;&amp; -d \"$cwd\" ]] &amp;&amp; cd \"$cwd\"\n\ndecide() {\n  jq -n --arg d \"$1\" --arg r \"$2\" '{\n    hookSpecificOutput: {\n      hookEventName: \"PreToolUse\",\n      permissionDecision: $d,\n      permissionDecisionReason: $r\n    }\n  }'\n  exit 0\n}\nhas() { printf '%s' \"$cmd\" | grep -Eiq -- \"$1\"; }\n\n# Replacing or dropping data: always the human's call\nif has 'ddev[[:space:]]+(import-db|delete)' \n   || has 'drop[[:space:]]+(database|schema|table)|truncate[[:space:]]'; then\n  decide ask \"This replaces or removes database content. Confirm only on a copy with a current dump.\"\nfi\n\n# Writing the database: only with a dump from the last 24 hours\nif has '(typo3|t3.sh)[[:space:]]+[^|;&amp;]*(extension:setup|upgrade:run|upgrade:mark:undone|database:updateschema)'; then\n  recent=\"$(find .project-migration\/backups .ddev\/db_snapshots -maxdepth 1 -mmin -1440 \n    ( -name '*.sql' -o -name '*.sql.gz' -o -name '*.gz' -o -name '*.zst' ) 2&gt;\/dev\/null | head -1 || true)\"\n  if [[ -z \"$recent\" ]]; then\n    decide deny \"No database dump from the last 24 h. Run 'ddev export-db --file=.project-migration\/backups\/pre-step.sql.gz' or 'ddev snapshot --name=pre-step' first, then try again.\"\n  fi\nfi\n\nexit 0<\/code><\/pre>\n<p>The deny reason matters more than it looks. Claude reads it and acts on it. With a concrete command in the reason, the agent usually takes the dump and retries on its own, which is exactly the flow I want: no human needed for the safe path, and the unsafe path does not exist.<\/p>\n<h2>Registering it<\/h2>\n<p>In the plugin, the hook sits in <code>hooks\/hooks.json<\/code> and points to the script with <code>${CLAUDE_PLUGIN_ROOT}<\/code>. For a single project without a plugin, put the same block in <code>.claude\/settings.json<\/code>, which you can commit so everybody on the project gets it:<\/p>\n<pre><code class=\"language-json\">{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"\"$CLAUDE_PROJECT_DIR\"\/.claude\/hooks\/guard-db.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}<\/code><\/pre>\n<p>Do not forget <code>chmod +x<\/code> on the script. Inside Claude Code, the <code>\/hooks<\/code> command shows which hooks are active and where they come from, which is the fastest way to see if your file was picked up at all.<\/p>\n<h2>Testing the hook without the agent<\/h2>\n<p>A hook is just a script that reads JSON. So I test it like a script, with fake payloads, and I do not need a model for that:<\/p>\n<pre><code class=\"language-bash\">work=\"$(mktemp -d)\"\nprobe() {\n  local out\n  out=\"$(jq -n --arg c \"$1\" --arg d \"$work\" '{cwd: $d, tool_input: {command: $c}}' \n    | .claude\/hooks\/guard-db.sh)\"\n  [[ -z \"$out\" ]] &amp;&amp; { echo allow; return; }\n  jq -r '.hookSpecificOutput.permissionDecision' &lt;&lt;&lt;\"$out\"\n}\n\nprobe 'ddev exec vendor\/bin\/typo3 upgrade:run'          # deny\nprobe 'ddev import-db --file=prod.sql.gz'               # ask\nprobe 'vendor\/bin\/typo3 cache:flush'                    # allow\n\nmkdir -p \"$work\/.project-migration\/backups\"\ntouch \"$work\/.project-migration\/backups\/pre-v14.sql.gz\"\nprobe 'ddev exec vendor\/bin\/typo3 upgrade:run'          # now allow\n\ntouch -t 202001010000 \"$work\/.project-migration\/backups\/pre-v14.sql.gz\"\nprobe 'ddev exec vendor\/bin\/typo3 extension:setup'      # deny again: dump too old<\/code><\/pre>\n<p>One small detail that bit me while writing this: when the hook allows, it prints nothing, and <code>jq<\/code> on empty input prints nothing either. So the probe checks for empty output itself and says <code>allow<\/code>. The plugin&#8217;s self test runs exactly this kind of list, including negative cases like <code>git commit -m \"fix -n handling\"<\/code>, which must not be mistaken for <code>--no-verify<\/code>.<\/p>\n<h2>What it did not cover<\/h2>\n<p>I want to be honest here, because this is the real lesson. On hoja.in the biggest database write was not a TYPO3 command at all. It was my import script, started with <code>ddev exec php .project-migration\/import\/import-legacy.php<\/code>, which truncates <code>pages<\/code>, <code>tt_content<\/code> and <code>sys_file_reference<\/code> before importing. The hook does not match that command. The dumps before each import (<code>pre-v14-import.sql.gz<\/code>, <code>pre-reimport.sql.gz<\/code> and friends in the backups folder) exist because a dump before every import was a written step of the plan, not because the hook forced it.<\/p>\n<p>Also, the hook checks that a recent file exists. It does not check that the file is a valid dump of the right database. A determined agent could satisfy it with an empty file. I accept that, because the goal is to stop accidents, not to fight an attacker. If your threat model is different, check the size and run a <code>zcat | head<\/code> on it.<\/p>\n<p>My takeaway: write down which commands in <em>your<\/em> project change data, including your own scripts, and put them in the pattern. A hook only guards what it knows.<\/p>\n<p>Cheers, and take that dump!<\/p>\n<h2>Further reading<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.claude.com\/en\/docs\/claude-code\/hooks\">Claude Code hooks reference<\/a><\/li>\n<li><a href=\"https:\/\/docs.claude.com\/en\/docs\/claude-code\/hooks-guide\">Get started with Claude Code hooks<\/a><\/li>\n<li><a href=\"https:\/\/ddev.readthedocs.io\/en\/stable\/users\/usage\/database-management\/\">DDEV database management<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>During my TYPO3 migration the agent could run commands that change the database. A PreToolUse hook makes it take a dump first. The script, the registration and how I test it.<\/p>\n","protected":false},"author":1,"featured_media":85,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[34,37,35,27,43],"class_list":["post-84","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-engineering","tag-ai-agents","tag-automation","tag-claude-code","tag-ddev","tag-security"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Claude Code hook: no DB writes without a fresh dump<\/title>\n<meta name=\"description\" content=\"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Claude Code hook: no DB writes without a fresh dump\" \/>\n<meta property=\"og:description\" content=\"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/\" \/>\n<meta property=\"og:site_name\" content=\"Hoja Mustaffa Abdul Latheef \u00e2\u20ac\u201c Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hojaonline7\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-24T07:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Hoja Mustaffa Abdul Latheef\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hojaonline\" \/>\n<meta name=\"twitter:site\" content=\"@hojaonline\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hoja Mustaffa Abdul Latheef\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/\"},\"author\":{\"name\":\"Hoja Mustaffa Abdul Latheef\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\"},\"headline\":\"A Claude Code hook that blocks DB writes without a fresh dump\",\"datePublished\":\"2026-10-24T07:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/\"},\"wordCount\":748,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/hoja.in\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg\",\"keywords\":[\"AI agents\",\"Automation\",\"Claude Code\",\"DDEV\",\"Security\"],\"articleSection\":[\"AI engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/\",\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/\",\"name\":\"Claude Code hook: no DB writes without a fresh dump\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/hoja.in\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg\",\"datePublished\":\"2026-10-24T07:00:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\"},\"description\":\"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#primaryimage\",\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg\",\"contentUrl\":\"https:\\\/\\\/hoja.in\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg\",\"width\":1200,\"height\":630,\"caption\":\"No dump, no database write\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hoja.in\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Claude Code hook that blocks DB writes without a fresh dump\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/\",\"name\":\"Hoja Mustaffa Abdul Latheef \u00e2\u20ac\u201c Blog\",\"description\":\"Notes from daily work with TYPO3, PHP and AI-assisted engineering\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hoja.in\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\",\"name\":\"Hoja Mustaffa Abdul Latheef\",\"description\":\"Senior TYPO3 Developer at jweiland.net, TYPO3 CMS Certified Developer. I write about TYPO3 upgrades, extension development, PHP and AI-assisted engineering with Claude Code.\",\"sameAs\":[\"https:\\\/\\\/hoja.in\\\/\"],\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/author\\\/hoja\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Claude Code hook: no DB writes without a fresh dump","description":"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/","og_locale":"en_US","og_type":"article","og_title":"Claude Code hook: no DB writes without a fresh dump","og_description":"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.","og_url":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/","og_site_name":"Hoja Mustaffa Abdul Latheef \u00e2\u20ac\u201c Blog","article_publisher":"https:\/\/www.facebook.com\/hojaonline7","article_published_time":"2026-10-24T07:00:00+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg","type":"image\/jpeg"}],"author":"Hoja Mustaffa Abdul Latheef","twitter_card":"summary_large_image","twitter_creator":"@hojaonline","twitter_site":"@hojaonline","twitter_misc":{"Written by":"Hoja Mustaffa Abdul Latheef","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#article","isPartOf":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/"},"author":{"name":"Hoja Mustaffa Abdul Latheef","@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b"},"headline":"A Claude Code hook that blocks DB writes without a fresh dump","datePublished":"2026-10-24T07:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/"},"wordCount":748,"commentCount":0,"image":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#primaryimage"},"thumbnailUrl":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg","keywords":["AI agents","Automation","Claude Code","DDEV","Security"],"articleSection":["AI engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/","url":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/","name":"Claude Code hook: no DB writes without a fresh dump","isPartOf":{"@id":"https:\/\/hoja.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#primaryimage"},"image":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#primaryimage"},"thumbnailUrl":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg","datePublished":"2026-10-24T07:00:00+00:00","author":{"@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b"},"description":"A Claude Code PreToolUse hook that denies TYPO3 commands which write the database unless a dump younger than 24 hours exists. Script, settings and tests.","breadcrumb":{"@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#primaryimage","url":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg","contentUrl":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump.jpg","width":1200,"height":630,"caption":"No dump, no database write"},{"@type":"BreadcrumbList","@id":"https:\/\/hoja.in\/blog\/a-claude-code-hook-that-blocks-db-writes-without-a-fresh-dump\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hoja.in\/blog\/"},{"@type":"ListItem","position":2,"name":"A Claude Code hook that blocks DB writes without a fresh dump"}]},{"@type":"WebSite","@id":"https:\/\/hoja.in\/blog\/#website","url":"https:\/\/hoja.in\/blog\/","name":"Hoja Mustaffa Abdul Latheef \u00e2\u20ac\u201c Blog","description":"Notes from daily work with TYPO3, PHP and AI-assisted engineering","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hoja.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b","name":"Hoja Mustaffa Abdul Latheef","description":"Senior TYPO3 Developer at jweiland.net, TYPO3 CMS Certified Developer. I write about TYPO3 upgrades, extension development, PHP and AI-assisted engineering with Claude Code.","sameAs":["https:\/\/hoja.in\/"],"url":"https:\/\/hoja.in\/blog\/author\/hoja\/"}]}},"_links":{"self":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":1,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions\/165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/media\/85"}],"wp:attachment":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}