<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vildanden</title>
    <description>The latest articles on DEV Community by Vildanden (@vildandenai).</description>
    <link>https://dev.to/vildandenai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4128566%2Faf126918-50e5-4f9d-9586-c96c758ecb77.png</url>
      <title>DEV Community: Vildanden</title>
      <link>https://dev.to/vildandenai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vildandenai"/>
    <language>en</language>
    <item>
      <title>Draft a conventional commit in Claude Code with a /commit slash command</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Thu, 19 Nov 2026 00:53:18 +0000</pubDate>
      <link>https://dev.to/vildandenai/draft-a-conventional-commit-in-claude-code-with-a-commit-slash-command-25ff</link>
      <guid>https://dev.to/vildandenai/draft-a-conventional-commit-in-claude-code-with-a-commit-slash-command-25ff</guid>
      <description>&lt;p&gt;If you keep pasting &lt;code&gt;git status&lt;/code&gt;, the staged diff, and "write a conventional commit, then wait" into Claude Code, turn that prompt into a slash command. The file name becomes the command; &lt;code&gt;$ARGUMENTS&lt;/code&gt; lets you add extra instructions each time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The command
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;.claude/commands/commit.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
description: "Draft a conventional commit for staged changes"
argument-hint: "[stage | extra instructions]"
---

Write a conventional commit for the currently staged changes only.

1. Run &lt;span class="sb"&gt;`git diff --cached`&lt;/span&gt; and &lt;span class="sb"&gt;`git status -sb`&lt;/span&gt;. If nothing is staged, stop and say so. Do not stage files yourself unless I passed &lt;span class="sb"&gt;`stage`&lt;/span&gt; as an argument.
2. Propose a single commit message: &lt;span class="sb"&gt;`type(scope): summary`&lt;/span&gt; plus an optional body.
3. Use one of feat, fix, docs, refactor, test, chore, perf, or ci.
4. Do not add &lt;span class="sb"&gt;`Co-Authored-By`&lt;/span&gt; or other AI attribution unless I ask.
5. If I passed arguments (&lt;span class="sb"&gt;`$ARGUMENTS`&lt;/span&gt;), treat them as extra instructions (for example &lt;span class="sb"&gt;`stage`&lt;/span&gt; or a scope hint).
6. Show the message and wait for me to confirm before running &lt;span class="sb"&gt;`git commit`&lt;/span&gt;. Never push.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use it as &lt;code&gt;/commit&lt;/code&gt; or &lt;code&gt;/commit stage&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this beats a pasted prompt
&lt;/h2&gt;

&lt;p&gt;Slash commands are markdown files in &lt;code&gt;.claude/commands&lt;/code&gt;. Claude Code injects the file as the prompt and replaces &lt;code&gt;$ARGUMENTS&lt;/code&gt; with whatever you type after the command. Keeping "wait for confirm" and "never push" in the command reduces unattended commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pair this with an "ask" permission rule for &lt;code&gt;git commit&lt;/code&gt; if you also want a permissions bump.&lt;/li&gt;
&lt;li&gt;Commit the command file so every teammate gets the same workflow.&lt;/li&gt;
&lt;li&gt;Need several values? Use &lt;code&gt;$1&lt;/code&gt; and &lt;code&gt;$2&lt;/code&gt; positional placeholders instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>git</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop yourself from pasting a private key into Claude Code with a UserPromptSubmit hook</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Wed, 18 Nov 2026 00:54:45 +0000</pubDate>
      <link>https://dev.to/vildandenai/stop-yourself-from-pasting-a-private-key-into-claude-code-with-a-userpromptsubmit-hook-105f</link>
      <guid>https://dev.to/vildandenai/stop-yourself-from-pasting-a-private-key-into-claude-code-with-a-userpromptsubmit-hook-105f</guid>
      <description>&lt;p&gt;Deny rules and write guards protect files on disk. They do nothing if you paste a private key, seed phrase, or API token into the prompt itself. A &lt;code&gt;UserPromptSubmit&lt;/code&gt; hook can catch that shape before the model ever sees it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hook
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;.claude/hooks/block-secret-prompts.sh&lt;/code&gt; and make it executable (&lt;code&gt;chmod +x&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Reads the hook event as JSON on stdin; exit code 2 blocks the prompt.&lt;/span&gt;
&lt;span class="nv"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -r &lt;span class="s1"&gt;'.prompt // .user_prompt // .content // empty'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$text"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -Eq &lt;span class="s1"&gt;'-----BEGIN .*PRIVATE KEY-----'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Blocked: that prompt looks like it contains a PEM private key. Use a redacted fixture or a secret manager instead."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$text"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -Eiq &lt;span class="s1"&gt;'\b(seed phrase|mnemonic|private key)\b.{0,80}\b(is|here|below|follows|:)\b|\b(api[_-]?key|access[_-]?token|secret[_-]?key)\s*[:=]\s*\S{16,}'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Blocked: that prompt looks like it may contain a credential or wallet secret. Redact it before retrying."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register it in &lt;code&gt;.claude/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"UserPromptSubmit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;".claude/hooks/block-secret-prompts.sh"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What happens
&lt;/h2&gt;

&lt;p&gt;When the hook exits with code 2, Claude Code should reject the prompt and show the stderr message. The model never receives the pasted material, so it cannot repeat or store it in the transcript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is a pattern match, not a vault. It will miss unusual encodings, and it may flag a sentence that only &lt;em&gt;talks&lt;/em&gt; about a private key. Tune the patterns for your team.&lt;/li&gt;
&lt;li&gt;Pair it with Read deny rules and a PreToolUse write guard so secrets stay out of files as well as prompts.&lt;/li&gt;
&lt;li&gt;Test with a fake &lt;code&gt;-----BEGIN EXAMPLE PRIVATE KEY-----&lt;/code&gt; block or a dummy &lt;code&gt;API_KEY=aaaaaaaaaaaaaaaa&lt;/code&gt;, never a real secret.&lt;/li&gt;
&lt;li&gt;Commit the hook so every teammate gets the same guardrail.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>security</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop Claude Code from running curl | bash with a PreToolUse hook</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Tue, 17 Nov 2026 00:52:40 +0000</pubDate>
      <link>https://dev.to/vildandenai/stop-claude-code-from-running-curl-bash-with-a-pretooluse-hook-1jfl</link>
      <guid>https://dev.to/vildandenai/stop-claude-code-from-running-curl-bash-with-a-pretooluse-hook-1jfl</guid>
      <description>&lt;p&gt;Permission rules and secret-path guards still leave a hole: a Bash tool call can download a script and pipe it into a shell. A small PreToolUse hook stops that pattern before the command runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hook
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;.claude/hooks/block-curl-pipe.sh&lt;/code&gt; and make it executable (&lt;code&gt;chmod +x&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Reads the tool call as JSON on stdin; exit code 2 blocks it.&lt;/span&gt;
&lt;span class="nv"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -r &lt;span class="s1"&gt;'.tool_input.command // ""'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$cmd"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -Ei &lt;span class="s1"&gt;'curl.+\|[[:space:]]*(sudo[[:space:]]+)?(ba)?sh|wget.+\|[[:space:]]*(sudo[[:space:]]+)?(ba)?sh|curl.+\|[[:space:]]*python'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Blocked: that command looks like a remote script piped into a shell. Download the file, read it, then run it yourself if you still want it."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register it in &lt;code&gt;.claude/settings.json&lt;/code&gt; so it only runs on shell calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;".claude/hooks/block-curl-pipe.sh"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What happens
&lt;/h2&gt;

&lt;p&gt;When Claude tries a matching Bash command, the hook exits with code 2. The command never runs, and the stderr message goes back to Claude so it can explain the block instead of retrying a slightly reworded pipe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is a pattern match, not a full shell parser. Cover the common &lt;code&gt;curl | bash&lt;/code&gt;, &lt;code&gt;wget | sh&lt;/code&gt;, and &lt;code&gt;sudo&lt;/code&gt; variants, then add any house style you actually use.&lt;/li&gt;
&lt;li&gt;Pair it with the existing PreToolUse guards for &lt;code&gt;rm -rf&lt;/code&gt;, force-push, and secret-file writes.&lt;/li&gt;
&lt;li&gt;Commit the hook so every teammate gets the same guardrail.&lt;/li&gt;
&lt;li&gt;Test with a harmless &lt;code&gt;curl https://example.com | bash&lt;/code&gt; in a throwaway session, not a real bootstrap script you still need.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>security</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop Claude Code from overwriting your .env with a PreToolUse write guard</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Mon, 16 Nov 2026 00:55:40 +0000</pubDate>
      <link>https://dev.to/vildandenai/stop-claude-code-from-overwriting-your-env-with-a-pretooluse-write-guard-2n21</link>
      <guid>https://dev.to/vildandenai/stop-claude-code-from-overwriting-your-env-with-a-pretooluse-write-guard-2n21</guid>
      <description>&lt;p&gt;Permission deny rules can stop Claude Code from &lt;em&gt;reading&lt;/em&gt; &lt;code&gt;.env&lt;/code&gt; and key files. That still leaves a hole: a Write or Edit call can create or overwrite those paths. A small PreToolUse hook closes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hook
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;.claude/hooks/block-secret-writes.sh&lt;/code&gt; and make it executable (&lt;code&gt;chmod +x&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Reads the tool call as JSON on stdin; exit code 2 blocks it.&lt;/span&gt;
&lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -r &lt;span class="s1"&gt;'.tool_input.file_path // .tool_input.path // ""'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$path"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -Ei &lt;span class="s1"&gt;'\.env([.-]|$)|\.(pem|key|p12|pfx)$|private.?key|id_rsa|wallet|mnemonic|credentials?'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Blocked: '$path' looks secret-bearing. Do not let the agent write credentials, keys, or wallet material."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register it in &lt;code&gt;.claude/settings.json&lt;/code&gt; so it only runs on file writes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Write|Edit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;".claude/hooks/block-secret-writes.sh"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What happens
&lt;/h2&gt;

&lt;p&gt;When Claude tries to save a matching path, the hook exits with code 2. The write never happens, and the stderr message goes back to Claude so it can explain the block instead of retrying.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pair this with Read deny rules for &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;~/.ssh/**&lt;/code&gt;, and &lt;code&gt;~/.aws/**&lt;/code&gt;. Deny stops reads; this hook stops writes.&lt;/li&gt;
&lt;li&gt;Keep the pattern list tight. If a project legitimately uses a &lt;code&gt;.key&lt;/code&gt; extension for something safe, add an allow exception rather than deleting the hook.&lt;/li&gt;
&lt;li&gt;Commit the hook so every teammate gets the same guardrail.&lt;/li&gt;
&lt;li&gt;Test with a harmless fixture such as &lt;code&gt;example.env&lt;/code&gt;, not a real secret.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>security</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Keep Claude Code away from your .env files with permission deny rules</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Mon, 09 Nov 2026 01:16:24 +0000</pubDate>
      <link>https://dev.to/vildandenai/keep-claude-code-away-from-your-env-files-with-permission-deny-rules-gii</link>
      <guid>https://dev.to/vildandenai/keep-claude-code-away-from-your-env-files-with-permission-deny-rules-gii</guid>
      <description>&lt;p&gt;Claude Code reads files to help you. That is great, until the file is .env, a private key, or a cloud credentials folder. Permission deny rules let you block those reads outright.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimal deny list
&lt;/h2&gt;

&lt;p&gt;In .claude/settings.json (shared with the team) or settings.local.json (personal), add these entries under permissions.deny:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read(./.env)&lt;/li&gt;
&lt;li&gt;Read(./.env.*)&lt;/li&gt;
&lt;li&gt;Read(./secrets/**)&lt;/li&gt;
&lt;li&gt;Read(~/.aws/**)&lt;/li&gt;
&lt;li&gt;Read(~/.ssh/**)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deny rules win over allow rules, so even if you later allow broad Read access, these paths stay blocked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Commit the deny list in .claude/settings.json so every teammate gets it.&lt;/li&gt;
&lt;li&gt;Add patterns for your own stack: &lt;em&gt;.pem, terraform.tfstate, service-account&lt;/em&gt;.json.&lt;/li&gt;
&lt;li&gt;Deny Bash(curl:*) too if you do not want the agent sending data out.&lt;/li&gt;
&lt;li&gt;Test it: ask Claude Code to read .env and confirm it is refused.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pair with ask rules
&lt;/h2&gt;

&lt;p&gt;Use deny for things that must never happen, ask for things like git push that need a human, and allow for safe everyday commands like npm test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in Vildanden Agent Config. There is a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>security</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Inject git status into every Claude Code session with a SessionStart hook</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Fri, 06 Nov 2026 01:11:17 +0000</pubDate>
      <link>https://dev.to/vildandenai/inject-git-status-into-every-claude-code-session-with-a-sessionstart-hook-4i89</link>
      <guid>https://dev.to/vildandenai/inject-git-status-into-every-claude-code-session-with-a-sessionstart-hook-4i89</guid>
      <description>&lt;p&gt;Claude Code can run a hook when a session starts. That is the right place to inject context you always want: current branch, dirty files, open TODOs — without typing it every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimal SessionStart hook
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;.claude/settings.json&lt;/code&gt; (or &lt;code&gt;settings.local.json&lt;/code&gt; for personal-only rules):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"SessionStart"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bash -lc 'echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;## Session context&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;; echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Branch: $(git rev-parse --abbrev-ref HEAD 2&amp;gt;/dev/null || echo n/a)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;; echo; git status -sb 2&amp;gt;/dev/null | head -40'"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Claude Code opens, the command runs once. Its stdout is added to the session context, so the model already knows which branch you are on and what is dirty.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep it short
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cap the output (&lt;code&gt;head -40&lt;/code&gt;) so you do not dump a huge status into every chat.&lt;/li&gt;
&lt;li&gt;Prefer &lt;code&gt;settings.local.json&lt;/code&gt; if the hook is personal and should stay out of git.&lt;/li&gt;
&lt;li&gt;Fail soft: wrap git calls so a non-repo folder does not break session start.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pair it with house rules
&lt;/h2&gt;

&lt;p&gt;Your project &lt;code&gt;CLAUDE.md&lt;/code&gt; still loads as usual. The SessionStart hook is for &lt;em&gt;live&lt;/em&gt; facts (branch, status); put stable rules (coding style, never push main) in CLAUDE.md instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>git</category>
    </item>
    <item>
      <title>Run a Claude Code review in CI with one claude -p line</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Thu, 05 Nov 2026 01:11:40 +0000</pubDate>
      <link>https://dev.to/vildandenai/run-a-claude-code-review-in-ci-with-one-claude-p-line-1i8c</link>
      <guid>https://dev.to/vildandenai/run-a-claude-code-review-in-ci-with-one-claude-p-line-1i8c</guid>
      <description>&lt;p&gt;Most people only use Claude Code interactively. But the same CLI has a headless mode: &lt;code&gt;claude -p "&amp;lt;prompt&amp;gt;"&lt;/code&gt; runs one prompt, prints the answer, and exits. That makes it a normal script step you can drop into CI or a git hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one line
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff origin/main...HEAD | claude &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Review this diff. List real bugs only. If there are none, print exactly: LGTM"&lt;/span&gt; &lt;span class="nt"&gt;--output-format&lt;/span&gt; text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Piped stdin becomes context, &lt;code&gt;-p&lt;/code&gt; runs non-interactively, and the output is plain text you can grep.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make it fail the build
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;out&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git diff origin/main...HEAD | claude &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s2"&gt;"Review this diff for bugs, missing error handling and leaked secrets. If nothing is wrong, reply with exactly LGTM."&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--allowedTools&lt;/span&gt; &lt;span class="s2"&gt;"Read,Grep"&lt;/span&gt; &lt;span class="nt"&gt;--max-turns&lt;/span&gt; 3&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"LGTM"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--allowedTools "Read,Grep"&lt;/code&gt; keeps the CI run read-only: it can look at files but not edit or run shell commands.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--max-turns 3&lt;/code&gt; caps how long it can wander.&lt;/li&gt;
&lt;li&gt;Need structured results? Use &lt;code&gt;--output-format json&lt;/code&gt; and parse &lt;code&gt;.result&lt;/code&gt; with &lt;code&gt;jq&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  GitHub Actions step
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Claude review&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.ANTHROPIC_API_KEY }}&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;npm i -g @anthropic-ai/claude-code&lt;/span&gt;
    &lt;span class="s"&gt;./scripts/claude-review.sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the key in repository secrets, never in the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the prompt strict ("bugs only", "exactly LGTM") so the output is easy to check.&lt;/li&gt;
&lt;li&gt;Your project &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;.claude/settings.json&lt;/code&gt; still load in headless mode, so your house rules apply in CI too.&lt;/li&gt;
&lt;li&gt;Start as a non-blocking job (&lt;code&gt;continue-on-error: true&lt;/code&gt;) for a week before you let it fail builds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the rest of the setup?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;. There's a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>devops</category>
      <category>productivity</category>
    </item>
    <item>
      <title>One /fix-issue slash command for every GitHub issue, using $ARGUMENTS</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Wed, 04 Nov 2026 01:13:08 +0000</pubDate>
      <link>https://dev.to/vildandenai/one-fix-issue-slash-command-for-every-github-issue-using-arguments-1a92</link>
      <guid>https://dev.to/vildandenai/one-fix-issue-slash-command-for-every-github-issue-using-arguments-1a92</guid>
      <description>&lt;p&gt;If you keep typing the same "read issue 123, find the cause, fix it, add a test" prompt into Claude Code, turn it into a custom slash command. The &lt;code&gt;$ARGUMENTS&lt;/code&gt; placeholder lets you pass the issue number each time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the command
&lt;/h2&gt;

&lt;p&gt;Project commands live in &lt;code&gt;.claude/commands/&lt;/code&gt;. The file name becomes the command name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.claude/commands/fix-issue.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Fix&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;GitHub&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;issue&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;by&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;number"&lt;/span&gt;
&lt;span class="na"&gt;argument-hint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;issue-number&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;allowed-tools&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Bash(gh issue view:*), Bash(git diff:*), Read, Edit, Grep&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;

Fix GitHub issue #$ARGUMENTS.
&lt;span class="p"&gt;
1.&lt;/span&gt; Run &lt;span class="sb"&gt;`gh issue view $ARGUMENTS`&lt;/span&gt; and summarize the problem in two lines.
&lt;span class="p"&gt;2.&lt;/span&gt; Find the relevant code with Grep before editing anything.
&lt;span class="p"&gt;3.&lt;/span&gt; Make the smallest change that fixes it.
&lt;span class="p"&gt;4.&lt;/span&gt; Add or update a test that fails without the fix.
&lt;span class="p"&gt;5.&lt;/span&gt; Show &lt;span class="sb"&gt;`git diff`&lt;/span&gt; and stop. Do not commit.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/fix-issue 123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code replaces &lt;code&gt;$ARGUMENTS&lt;/code&gt; with &lt;code&gt;123&lt;/code&gt;. Need several values? Use &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt; positional placeholders instead (for example &lt;code&gt;/fix-issue 123 high&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this beats a pasted prompt
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Same routine every time&lt;/strong&gt;: the steps are in git, so the whole team gets them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scoped tools&lt;/strong&gt;: &lt;code&gt;allowed-tools&lt;/code&gt; limits what the command may run without asking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stops before commit&lt;/strong&gt;: you review the diff yourself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Personal commands you don't want in the repo go in &lt;code&gt;~/.claude/commands/&lt;/code&gt; instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want the full kit?
&lt;/h2&gt;

&lt;p&gt;I keep copy-ready slash commands, hooks, &lt;code&gt;settings.json&lt;/code&gt; permission rules and a short &lt;code&gt;CLAUDE.md&lt;/code&gt; in &lt;strong&gt;Vildanden Agent Config&lt;/strong&gt;, with a free sample: &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;https://justly-mia-429.rehost.page/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>github</category>
    </item>
    <item>
      <title>Back up your Claude Code session before it compacts, with a PreCompact hook</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Tue, 03 Nov 2026 01:15:46 +0000</pubDate>
      <link>https://dev.to/vildandenai/back-up-your-claude-code-session-before-it-compacts-with-a-precompact-hook-5e1</link>
      <guid>https://dev.to/vildandenai/back-up-your-claude-code-session-before-it-compacts-with-a-precompact-hook-5e1</guid>
      <description>&lt;p&gt;Long Claude Code sessions eventually compact: the conversation gets summarized to free up context. Usually that's fine, but sometimes the detail you needed (an error message, a decision, a file list) gets squashed. A &lt;code&gt;PreCompact&lt;/code&gt; hook lets you save a copy first.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a PreCompact hook does
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;PreCompact&lt;/code&gt; runs right before Claude Code compacts, whether you typed &lt;code&gt;/compact&lt;/code&gt; (&lt;code&gt;manual&lt;/code&gt;) or the context filled up (&lt;code&gt;auto&lt;/code&gt;). The hook gets JSON on stdin that includes &lt;code&gt;transcript_path&lt;/code&gt; and &lt;code&gt;trigger&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add this to &lt;code&gt;.claude/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PreCompact"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"manual|auto"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mkdir -p .claude/backups &amp;amp;&amp;amp; jq -r '.transcript_path' | xargs -I{} cp {} .claude/backups/pre-compact-$(date +%Y%m%d-%H%M%S).jsonl"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every time the session compacts, the full transcript gets copied to &lt;code&gt;.claude/backups/&lt;/code&gt; with a timestamp. If the summary loses something, grep the backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;.claude/backups/&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;. Transcripts can contain secrets and file contents.&lt;/li&gt;
&lt;li&gt;Clear old backups now and then: &lt;code&gt;find .claude/backups -mtime +7 -delete&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Want only manual compacts? Set the matcher to &lt;code&gt;manual&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;/hooks&lt;/code&gt; to check the hook is loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shared settings, safety hooks, a short &lt;code&gt;CLAUDE.md&lt;/code&gt; and a read-only reviewer subagent ship ready to copy in &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;Vildanden Agent Config&lt;/a&gt;. The free sample is enough to get started today.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Auto-format every file Claude Code edits with a PostToolUse hook</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Mon, 02 Nov 2026 01:12:15 +0000</pubDate>
      <link>https://dev.to/vildandenai/auto-format-every-file-claude-code-edits-with-a-posttooluse-hook-26f9</link>
      <guid>https://dev.to/vildandenai/auto-format-every-file-claude-code-edits-with-a-posttooluse-hook-26f9</guid>
      <description>&lt;p&gt;Claude Code writes decent code, but it doesn't always match your formatter. You can keep asking it to "run prettier", or you can make formatting automatic with a &lt;code&gt;PostToolUse&lt;/code&gt; hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a PostToolUse hook does
&lt;/h2&gt;

&lt;p&gt;Hooks are shell commands Claude Code runs at fixed points. A &lt;code&gt;PostToolUse&lt;/code&gt; hook runs right after a tool call finishes. Point it at the edit tools and your formatter runs every time a file changes.&lt;/p&gt;

&lt;p&gt;Add this to &lt;code&gt;.claude/settings.json&lt;/code&gt; in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PostToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Edit|MultiEdit|Write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jq -r '.tool_input.file_path' | xargs -r npx prettier --write --ignore-unknown"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hook gets the tool call as JSON on stdin. &lt;code&gt;jq&lt;/code&gt; pulls out the edited file's path, and Prettier formats just that file. &lt;code&gt;--ignore-unknown&lt;/code&gt; keeps it quiet on file types Prettier doesn't handle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other languages
&lt;/h2&gt;

&lt;p&gt;Swap the formatter for your stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python: &lt;code&gt;xargs -r ruff format&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go: &lt;code&gt;xargs -r gofmt -w&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Rust: &lt;code&gt;xargs -r rustfmt&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the command fast. It runs after every edit, so format one file, not the whole repo.&lt;/li&gt;
&lt;li&gt;Commit &lt;code&gt;.claude/settings.json&lt;/code&gt; so the whole team gets the same behavior.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;/hooks&lt;/code&gt; in Claude Code to check the hook is loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shared settings, a risky-git &lt;code&gt;PreToolUse&lt;/code&gt; hook, a short &lt;code&gt;CLAUDE.md&lt;/code&gt; and a read-only reviewer subagent all ship ready to copy in &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;Vildanden Agent Config&lt;/a&gt;. The free sample is enough to get started today.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Split a long CLAUDE.md into small files with @ imports</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Fri, 30 Oct 2026 01:09:26 +0000</pubDate>
      <link>https://dev.to/vildandenai/split-a-long-claudemd-into-small-files-with-imports-419o</link>
      <guid>https://dev.to/vildandenai/split-a-long-claudemd-into-small-files-with-imports-419o</guid>
      <description>&lt;p&gt;A &lt;code&gt;CLAUDE.md&lt;/code&gt; tends to grow. Build commands, code style, testing rules, release steps, and soon it's 200 lines that Claude Code skims instead of follows. You don't have to pick between short and complete: &lt;code&gt;CLAUDE.md&lt;/code&gt; can pull in other files with &lt;code&gt;@&lt;/code&gt; imports.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;Any line in &lt;code&gt;CLAUDE.md&lt;/code&gt; can reference another file with &lt;code&gt;@path&lt;/code&gt;. Claude Code reads the imported file as if its text were written there. Paths can be relative to the file that does the importing, or start with &lt;code&gt;~&lt;/code&gt; for your home folder.&lt;/p&gt;

&lt;p&gt;A short root file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Project notes&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Run &lt;span class="sb"&gt;`npm test`&lt;/span&gt; before saying a change is done.
&lt;span class="p"&gt;-&lt;/span&gt; Never edit files under &lt;span class="sb"&gt;`vendor/`&lt;/span&gt;.

Testing details: @docs/claude/testing.md
Release steps: @docs/claude/release.md
API style guide: @docs/claude/api-style.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each imported file stays focused on one topic, so it's easy to review in a pull request and easy to keep current.&lt;/p&gt;

&lt;h2&gt;
  
  
  Personal notes without touching the team file
&lt;/h2&gt;

&lt;p&gt;Imports also work for things only you care about. Add a line like this to the project &lt;code&gt;CLAUDE.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;My local preferences: @~/.claude/my-project-notes.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Teammates who don't have that file aren't affected, and your notes never land in git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the root file to the rules that matter on every task. Move reference material into imports.&lt;/li&gt;
&lt;li&gt;Imports can nest, but keep it shallow so you can still tell where a rule came from.&lt;/li&gt;
&lt;li&gt;Text inside code spans and code blocks isn't treated as an import, so writing &lt;code&gt;@scope/package&lt;/code&gt; in a snippet is safe.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;/memory&lt;/code&gt; in Claude Code to see which memory files are loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A ready-made short &lt;code&gt;CLAUDE.md&lt;/code&gt;, shared permissions, a risky-git hook and a read-only reviewer subagent all ship in &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;Vildanden Agent Config&lt;/a&gt;. The free sample is enough to get started today.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Show the model and git branch in Claude Code with a 6-line status line script</title>
      <dc:creator>Vildanden</dc:creator>
      <pubDate>Thu, 29 Oct 2026 01:14:55 +0000</pubDate>
      <link>https://dev.to/vildandenai/show-the-model-and-git-branch-in-claude-code-with-a-6-line-status-line-script-1fc1</link>
      <guid>https://dev.to/vildandenai/show-the-model-and-git-branch-in-claude-code-with-a-6-line-status-line-script-1fc1</guid>
      <description>&lt;p&gt;When you run Claude Code in a few repos at once, it's easy to lose track of which branch you're on and which model is answering. Claude Code has a configurable status line for exactly this: a small script whose output shows up under the prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;You point &lt;code&gt;statusLine&lt;/code&gt; in your settings at a command. Claude Code runs it, passes session details as JSON on stdin, and shows the first line the script prints.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;~/.claude/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"statusLine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"~/.claude/statusline.sh"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;~/.claude/statusline.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nv"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$input&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.model.display_name'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$input&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.workspace.current_dir'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;branch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; branch &lt;span class="nt"&gt;--show-current&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[&lt;/span&gt;&lt;span class="nv"&gt;$model&lt;/span&gt;&lt;span class="s2"&gt;] &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;##*/&lt;/span&gt;&lt;span class="k"&gt;}${&lt;/span&gt;&lt;span class="nv"&gt;branch&lt;/span&gt;:+&lt;span class="p"&gt; on &lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make it executable with &lt;code&gt;chmod +x ~/.claude/statusline.sh&lt;/code&gt;, and you'll see something like &lt;code&gt;[Sonnet] api on fix/login-timeout&lt;/code&gt; under the prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep it fast. It runs often, so avoid network calls or slow git commands.&lt;/li&gt;
&lt;li&gt;It needs &lt;code&gt;jq&lt;/code&gt;. If you'd rather not install it, the same script works in a few lines of Python reading &lt;code&gt;sys.stdin&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Put it in your user settings, not the project file, since it's a personal preference rather than a team rule.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;/statusline&lt;/code&gt; in Claude Code if you'd like it to draft a script for you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The team-side setup that goes with this (a short &lt;code&gt;CLAUDE.md&lt;/code&gt;, shared permissions, a risky-git hook and a read-only reviewer subagent) ships in &lt;a href="https://justly-mia-429.rehost.page/" rel="noopener noreferrer"&gt;Vildanden Agent Config&lt;/a&gt;. The free sample is enough to get started today.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>git</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
