@@ -1837,7 +1837,7 @@ describe('Codex generation (--host codex)', () => {
18371837 expect ( frontmatter ) . toContain ( 'YC Office Hours' ) ;
18381838 } ) ;
18391839
1840- test ( 'hook skills have safety prose and no hooks: in frontmatter' , ( ) => {
1840+ test ( 'Codex hook skills have safety prose and no hooks: in frontmatter' , ( ) => {
18411841 const HOOK_SKILLS = [ 'gstack-careful' , 'gstack-freeze' , 'gstack-guard' ] ;
18421842 for ( const skillName of HOOK_SKILLS ) {
18431843 const content = fs . readFileSync ( path . join ( AGENTS_DIR , skillName , 'SKILL.md' ) , 'utf-8' ) ;
@@ -1850,6 +1850,24 @@ describe('Codex generation (--host codex)', () => {
18501850 }
18511851 } ) ;
18521852
1853+ test ( 'Claude hook commands do not depend on CLAUDE_SKILL_DIR' , ( ) => {
1854+ // #1871: Claude Code 2.1.162 does not populate CLAUDE_SKILL_DIR for
1855+ // skill-frontmatter PreToolUse hooks. If these commands use that variable,
1856+ // they expand to paths like /../freeze/bin/check-freeze.sh and fail before
1857+ // the safety hook can do its job.
1858+ const HOOK_SKILLS = [ 'careful' , 'freeze' , 'guard' , 'investigate' ] ;
1859+ for ( const skillName of HOOK_SKILLS ) {
1860+ const content = fs . readFileSync ( path . join ( ROOT , skillName , 'SKILL.md' ) , 'utf-8' ) ;
1861+ const fmEnd = content . indexOf ( '\n---' , 4 ) ;
1862+ const frontmatter = content . slice ( 4 , fmEnd ) ;
1863+ expect ( frontmatter ) . toContain ( 'hooks:' ) ;
1864+ expect ( frontmatter ) . not . toContain ( 'CLAUDE_SKILL_DIR' ) ;
1865+ expect ( frontmatter ) . toContain ( 'git rev-parse --show-toplevel' ) ;
1866+ expect ( frontmatter ) . toContain ( '$R/.claude/skills/gstack/' ) ;
1867+ expect ( frontmatter ) . toContain ( '$HOME/.claude/skills/gstack/' ) ;
1868+ }
1869+ } ) ;
1870+
18531871 test ( 'all Codex SKILL.md files have auto-generated header' , ( ) => {
18541872 for ( const skill of CODEX_SKILLS ) {
18551873 const content = fs . readFileSync ( path . join ( AGENTS_DIR , skill . codexName , 'SKILL.md' ) , 'utf-8' ) ;
0 commit comments