Hook
Remind Run Tests
A Claude Code hook that holds back the end of a turn once, asking the agent to run the test suite when source files changed since the last commit.
1node -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{let j={};try{j=JSON.parse(d)||{}}catch(e){process.exit(0)}const i=j.tool_input||{};const q=String.fromCharCode(34),sq=String.fromCharCode(39),bs=String.fromCharCode(92),nl=String.fromCharCode(10);if(j.stop_hook_active)process.exit(0);const r=require('child_process').spawnSync('git',['status','--porcelain','-uall'],{cwd:j.cwd||process.cwd(),encoding:'utf8'});if(r.status!==0||!r.stdout)process.exit(0);const fl=r.stdout.split(nl).filter(Boolean).map(l=>l.slice(3).trim().split(' -> ').pop().split(q).join(''));const src=fl.filter(f=>/[.](js|jsx|ts|tsx|mjs|cjs|py|go|rs|java|kt|rb|php|cs|swift|c|cpp|h|vue|svelte)$/.test(f)&&!/([.](test|spec)[.]|__tests__|_test[.]|(^|[/])tests?[/])/.test(f));if(src.length===0)process.exit(0);console.error('Before you finish: '+src.length+' source file(s) changed since the last commit ('+src.slice(0,5).join(', ')+'). Run the project test suite, report the result, then stop.');process.exit(2)})"
Claude CodeCodex
Remind Run Tests
HookTesting
Free