[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$f2k9tjicca5wqa":3},{"entry":4,"body":9,"data":574},{"slug":5,"title":6,"file":7,"description":8},"hooks-and-settings","Hooks and settings","hooks-and-settings.md","Shipping settings.local.json and hook scripts.",{"type":10,"children":11},"root",[12,19,25,32,37,382,403,424,429,450,455,461,568],{"type":13,"tag":14,"props":15,"children":16},"element","h1",{"id":5},[17],{"type":18,"value":6},"text",{"type":13,"tag":20,"props":21,"children":22},"p",{},[23],{"type":18,"value":24},"Claude Code hooks are configured in a settings file and point at scripts. A bundle can ship both.",{"type":13,"tag":26,"props":27,"children":29},"h2",{"id":28},"settingslocaljson",[30],{"type":18,"value":31},"settings.local.json",{"type":13,"tag":20,"props":33,"children":34},{},[35],{"type":18,"value":36},"Ship the settings you want the user to merge, nothing more. A typical bundle-level file only carries hooks and permission allowlists:",{"type":13,"tag":38,"props":39,"children":44},"pre",{"className":40,"code":41,"language":42,"meta":43,"style":43},"language-json shiki shiki-themes material-theme-lighter github-light github-dark","{\n  \"permissions\": {\n    \"allow\": [\"Bash(python3 .claude\u002Fskills\u002F*\u002Ffetch.py:*)\"]\n  },\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [{ \"type\": \"command\", \"command\": \"bash .claude\u002Fhooks\u002Fguard.sh\" }]\n      }\n    ]\n  }\n}\n","json","",[45],{"type":13,"tag":46,"props":47,"children":48},"code",{"__ignoreMap":43},[49,61,92,140,149,174,200,209,251,346,355,364,373],{"type":13,"tag":50,"props":51,"children":54},"span",{"class":52,"line":53},"line",1,[55],{"type":13,"tag":50,"props":56,"children":58},{"style":57},"--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8",[59],{"type":18,"value":60},"{\n",{"type":13,"tag":50,"props":62,"children":64},{"class":52,"line":63},2,[65,71,77,82,87],{"type":13,"tag":50,"props":66,"children":68},{"style":67},"--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[69],{"type":18,"value":70},"  \"",{"type":13,"tag":50,"props":72,"children":74},{"style":73},"--shiki-light:#9C3EDA;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[75],{"type":18,"value":76},"permissions",{"type":13,"tag":50,"props":78,"children":79},{"style":67},[80],{"type":18,"value":81},"\"",{"type":13,"tag":50,"props":83,"children":84},{"style":57},[85],{"type":18,"value":86},":",{"type":13,"tag":50,"props":88,"children":89},{"style":57},[90],{"type":18,"value":91}," {\n",{"type":13,"tag":50,"props":93,"children":95},{"class":52,"line":94},3,[96,101,107,111,115,120,125,131,135],{"type":13,"tag":50,"props":97,"children":98},{"style":67},[99],{"type":18,"value":100},"    \"",{"type":13,"tag":50,"props":102,"children":104},{"style":103},"--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[105],{"type":18,"value":106},"allow",{"type":13,"tag":50,"props":108,"children":109},{"style":67},[110],{"type":18,"value":81},{"type":13,"tag":50,"props":112,"children":113},{"style":57},[114],{"type":18,"value":86},{"type":13,"tag":50,"props":116,"children":117},{"style":57},[118],{"type":18,"value":119}," [",{"type":13,"tag":50,"props":121,"children":123},{"style":122},"--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF",[124],{"type":18,"value":81},{"type":13,"tag":50,"props":126,"children":128},{"style":127},"--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF",[129],{"type":18,"value":130},"Bash(python3 .claude\u002Fskills\u002F*\u002Ffetch.py:*)",{"type":13,"tag":50,"props":132,"children":133},{"style":122},[134],{"type":18,"value":81},{"type":13,"tag":50,"props":136,"children":137},{"style":57},[138],{"type":18,"value":139},"]\n",{"type":13,"tag":50,"props":141,"children":143},{"class":52,"line":142},4,[144],{"type":13,"tag":50,"props":145,"children":146},{"style":57},[147],{"type":18,"value":148},"  },\n",{"type":13,"tag":50,"props":150,"children":152},{"class":52,"line":151},5,[153,157,162,166,170],{"type":13,"tag":50,"props":154,"children":155},{"style":67},[156],{"type":18,"value":70},{"type":13,"tag":50,"props":158,"children":159},{"style":73},[160],{"type":18,"value":161},"hooks",{"type":13,"tag":50,"props":163,"children":164},{"style":67},[165],{"type":18,"value":81},{"type":13,"tag":50,"props":167,"children":168},{"style":57},[169],{"type":18,"value":86},{"type":13,"tag":50,"props":171,"children":172},{"style":57},[173],{"type":18,"value":91},{"type":13,"tag":50,"props":175,"children":177},{"class":52,"line":176},6,[178,182,187,191,195],{"type":13,"tag":50,"props":179,"children":180},{"style":67},[181],{"type":18,"value":100},{"type":13,"tag":50,"props":183,"children":184},{"style":103},[185],{"type":18,"value":186},"PreToolUse",{"type":13,"tag":50,"props":188,"children":189},{"style":67},[190],{"type":18,"value":81},{"type":13,"tag":50,"props":192,"children":193},{"style":57},[194],{"type":18,"value":86},{"type":13,"tag":50,"props":196,"children":197},{"style":57},[198],{"type":18,"value":199}," [\n",{"type":13,"tag":50,"props":201,"children":203},{"class":52,"line":202},7,[204],{"type":13,"tag":50,"props":205,"children":206},{"style":57},[207],{"type":18,"value":208},"      {\n",{"type":13,"tag":50,"props":210,"children":212},{"class":52,"line":211},8,[213,218,224,228,232,237,242,246],{"type":13,"tag":50,"props":214,"children":215},{"style":67},[216],{"type":18,"value":217},"        \"",{"type":13,"tag":50,"props":219,"children":221},{"style":220},"--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[222],{"type":18,"value":223},"matcher",{"type":13,"tag":50,"props":225,"children":226},{"style":67},[227],{"type":18,"value":81},{"type":13,"tag":50,"props":229,"children":230},{"style":57},[231],{"type":18,"value":86},{"type":13,"tag":50,"props":233,"children":234},{"style":122},[235],{"type":18,"value":236}," \"",{"type":13,"tag":50,"props":238,"children":239},{"style":127},[240],{"type":18,"value":241},"Bash",{"type":13,"tag":50,"props":243,"children":244},{"style":122},[245],{"type":18,"value":81},{"type":13,"tag":50,"props":247,"children":248},{"style":57},[249],{"type":18,"value":250},",\n",{"type":13,"tag":50,"props":252,"children":254},{"class":52,"line":253},9,[255,259,263,267,271,276,280,286,290,294,298,303,307,312,316,320,324,328,332,337,341],{"type":13,"tag":50,"props":256,"children":257},{"style":67},[258],{"type":18,"value":217},{"type":13,"tag":50,"props":260,"children":261},{"style":220},[262],{"type":18,"value":161},{"type":13,"tag":50,"props":264,"children":265},{"style":67},[266],{"type":18,"value":81},{"type":13,"tag":50,"props":268,"children":269},{"style":57},[270],{"type":18,"value":86},{"type":13,"tag":50,"props":272,"children":273},{"style":57},[274],{"type":18,"value":275}," [{",{"type":13,"tag":50,"props":277,"children":278},{"style":67},[279],{"type":18,"value":236},{"type":13,"tag":50,"props":281,"children":283},{"style":282},"--shiki-light:#E53935;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[284],{"type":18,"value":285},"type",{"type":13,"tag":50,"props":287,"children":288},{"style":67},[289],{"type":18,"value":81},{"type":13,"tag":50,"props":291,"children":292},{"style":57},[293],{"type":18,"value":86},{"type":13,"tag":50,"props":295,"children":296},{"style":122},[297],{"type":18,"value":236},{"type":13,"tag":50,"props":299,"children":300},{"style":127},[301],{"type":18,"value":302},"command",{"type":13,"tag":50,"props":304,"children":305},{"style":122},[306],{"type":18,"value":81},{"type":13,"tag":50,"props":308,"children":309},{"style":57},[310],{"type":18,"value":311},",",{"type":13,"tag":50,"props":313,"children":314},{"style":67},[315],{"type":18,"value":236},{"type":13,"tag":50,"props":317,"children":318},{"style":282},[319],{"type":18,"value":302},{"type":13,"tag":50,"props":321,"children":322},{"style":67},[323],{"type":18,"value":81},{"type":13,"tag":50,"props":325,"children":326},{"style":57},[327],{"type":18,"value":86},{"type":13,"tag":50,"props":329,"children":330},{"style":122},[331],{"type":18,"value":236},{"type":13,"tag":50,"props":333,"children":334},{"style":127},[335],{"type":18,"value":336},"bash .claude\u002Fhooks\u002Fguard.sh",{"type":13,"tag":50,"props":338,"children":339},{"style":122},[340],{"type":18,"value":81},{"type":13,"tag":50,"props":342,"children":343},{"style":57},[344],{"type":18,"value":345}," }]\n",{"type":13,"tag":50,"props":347,"children":349},{"class":52,"line":348},10,[350],{"type":13,"tag":50,"props":351,"children":352},{"style":57},[353],{"type":18,"value":354},"      }\n",{"type":13,"tag":50,"props":356,"children":358},{"class":52,"line":357},11,[359],{"type":13,"tag":50,"props":360,"children":361},{"style":57},[362],{"type":18,"value":363},"    ]\n",{"type":13,"tag":50,"props":365,"children":367},{"class":52,"line":366},12,[368],{"type":13,"tag":50,"props":369,"children":370},{"style":57},[371],{"type":18,"value":372},"  }\n",{"type":13,"tag":50,"props":374,"children":376},{"class":52,"line":375},13,[377],{"type":13,"tag":50,"props":378,"children":379},{"style":57},[380],{"type":18,"value":381},"}\n",{"type":13,"tag":20,"props":383,"children":384},{},[385,387,393,395,401],{"type":18,"value":386},"Paths inside the settings file are relative to the ",{"type":13,"tag":388,"props":389,"children":390},"strong",{},[391],{"type":18,"value":392},"project root",{"type":18,"value":394},", so reference hook scripts as ",{"type":13,"tag":46,"props":396,"children":398},{"className":397},[],[399],{"type":18,"value":400},".claude\u002Fhooks\u002F\u003Cscript>",{"type":18,"value":402},".",{"type":13,"tag":20,"props":404,"children":405},{},[406,408,414,416,422],{"type":18,"value":407},"The user merges this into their own ",{"type":13,"tag":46,"props":409,"children":411},{"className":410},[],[412],{"type":18,"value":413},".claude\u002Fsettings.local.json",{"type":18,"value":415}," (or ",{"type":13,"tag":46,"props":417,"children":419},{"className":418},[],[420],{"type":18,"value":421},"settings.json",{"type":18,"value":423},"); the site does not do that for them, so say so in the README.",{"type":13,"tag":26,"props":425,"children":426},{"id":161},[427],{"type":18,"value":428},"hooks\u002F",{"type":13,"tag":20,"props":430,"children":431},{},[432,434,440,442,448],{"type":18,"value":433},"Put the scripts the settings reference here. Make them executable in git (",{"type":13,"tag":46,"props":435,"children":437},{"className":436},[],[438],{"type":18,"value":439},"chmod +x",{"type":18,"value":441},", then commit) and start them with a shebang. Keep them dependency-free where possible; if they need a tool, add it to ",{"type":13,"tag":46,"props":443,"children":445},{"className":444},[],[446],{"type":18,"value":447},"requires",{"type":18,"value":449}," in the README frontmatter.",{"type":13,"tag":20,"props":451,"children":452},{},[453],{"type":18,"value":454},"Shell, Python, JavaScript and TypeScript files render with syntax highlighting on the site so people can read a hook before they trust it.",{"type":13,"tag":26,"props":456,"children":458},{"id":457},"testing-a-hook-locally",[459],{"type":18,"value":460},"Testing a hook locally",{"type":13,"tag":38,"props":462,"children":466},{"className":463,"code":464,"language":465,"meta":43,"style":43},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","unzip \u003Cslug>.zip\ncp -R \u003Cslug>\u002Fhooks .claude\u002F\n# merge \u003Cslug>\u002Fsettings.local.json into .claude\u002Fsettings.local.json\nclaude   # start a session and trigger the matcher\n","bash",[467],{"type":13,"tag":46,"props":468,"children":469},{"__ignoreMap":43},[470,506,546,555],{"type":13,"tag":50,"props":471,"children":472},{"class":52,"line":53},[473,479,485,490,496,501],{"type":13,"tag":50,"props":474,"children":476},{"style":475},"--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0",[477],{"type":18,"value":478},"unzip",{"type":13,"tag":50,"props":480,"children":482},{"style":481},"--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583",[483],{"type":18,"value":484}," \u003C",{"type":13,"tag":50,"props":486,"children":487},{"style":127},[488],{"type":18,"value":489},"slu",{"type":13,"tag":50,"props":491,"children":493},{"style":492},"--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8",[494],{"type":18,"value":495},"g",{"type":13,"tag":50,"props":497,"children":498},{"style":481},[499],{"type":18,"value":500},">",{"type":13,"tag":50,"props":502,"children":503},{"style":127},[504],{"type":18,"value":505},".zip\n",{"type":13,"tag":50,"props":507,"children":508},{"class":52,"line":63},[509,514,520,524,528,532,536,541],{"type":13,"tag":50,"props":510,"children":511},{"style":475},[512],{"type":18,"value":513},"cp",{"type":13,"tag":50,"props":515,"children":517},{"style":516},"--shiki-light:#91B859;--shiki-default:#005CC5;--shiki-dark:#79B8FF",[518],{"type":18,"value":519}," -R",{"type":13,"tag":50,"props":521,"children":522},{"style":481},[523],{"type":18,"value":484},{"type":13,"tag":50,"props":525,"children":526},{"style":127},[527],{"type":18,"value":489},{"type":13,"tag":50,"props":529,"children":530},{"style":492},[531],{"type":18,"value":495},{"type":13,"tag":50,"props":533,"children":534},{"style":481},[535],{"type":18,"value":500},{"type":13,"tag":50,"props":537,"children":538},{"style":127},[539],{"type":18,"value":540},"\u002Fhooks",{"type":13,"tag":50,"props":542,"children":543},{"style":127},[544],{"type":18,"value":545}," .claude\u002F\n",{"type":13,"tag":50,"props":547,"children":548},{"class":52,"line":94},[549],{"type":13,"tag":50,"props":550,"children":552},{"style":551},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit",[553],{"type":18,"value":554},"# merge \u003Cslug>\u002Fsettings.local.json into .claude\u002Fsettings.local.json\n",{"type":13,"tag":50,"props":556,"children":557},{"class":52,"line":142},[558,563],{"type":13,"tag":50,"props":559,"children":560},{"style":475},[561],{"type":18,"value":562},"claude",{"type":13,"tag":50,"props":564,"children":565},{"style":551},[566],{"type":18,"value":567},"   # start a session and trigger the matcher\n",{"type":13,"tag":569,"props":570,"children":571},"style",{},[572],{"type":18,"value":573},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{}]