Skip to content

fix(claude): SessionStart hook SKILL.md path broken after src/ restructure#498

Open
ousamabenyounes wants to merge 3 commits into
JuliusBrussee:mainfrom
ousamabenyounes:fix/467-skillmd-path-src-restructure
Open

fix(claude): SessionStart hook SKILL.md path broken after src/ restructure#498
ousamabenyounes wants to merge 3 commits into
JuliusBrussee:mainfrom
ousamabenyounes:fix/467-skillmd-path-src-restructure

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jun 6, 2026

Copy link
Copy Markdown

Fixes #467

Problem

After the src/ restructure, caveman-activate.js moved from hooks/ to src/hooks/, but the relative path to skills/caveman/SKILL.md was not updated. The hook resolved __dirname/../skills/...src/skills/... — a path that doesn't exist. readFileSync threw, the catch swallowed it, and every session silently served the weak hardcoded fallback ruleset (no intensity table, no examples). Models drifted back to verbose prose within a few turns.

Fix

Probe both layouts before falling back:

  • src/hooks/ → ../../skills/caveman/SKILL.md (current layout)
  • hooks/ → ../skills/caveman/SKILL.md (legacy layout)

Test — real RED → GREEN

tests/test_activate_skillmd_path.js spawns the real hook and asserts the full SKILL.md is loaded (the ## Intensity table is SKILL.md-only — never in the fallback).

GREEN (fix in place):

✓ activation loads full SKILL.md (not the weak fallback)
✓ intensity table is filtered to the active level
2 passed, 0 failed

RED (candidate path reverted to the stale ../skills):

✗ activation loads full SKILL.md (not the weak fallback)
    expected SKILL.md content ("## Intensity"), got fallback:
    CAVEMAN MODE ACTIVE — level: full
    Respond terse like smart caveman. … (hardcoded fallback, no ## Intensity)
✗ intensity table is filtered to the active level
0 passed, 2 failed

The reverted hook emits the weak fallback — the exact silent-degradation this issue reports. The test proves the SKILL.md path is actually resolved.

Run: node tests/test_activate_skillmd_path.js

ousamabenyounes and others added 2 commits June 6, 2026 15:44
…cture

After the src/ directory restructure, caveman-activate.js moved from
hooks/ to src/hooks/, but the relative path to skills/caveman/SKILL.md
was not updated. The hook resolved __dirname/../skills/... which maps
to src/skills/... — a path that doesn't exist. The readFileSync threw,
the catch swallowed it, and every session silently served the weak
hardcoded fallback ruleset (no intensity table, no examples). Models
drifted back to verbose prose within a few turns.

Fix: probe both post-restructure and legacy layouts before falling back:
  - src/hooks/ → ../../skills/caveman/SKILL.md (current)
  - hooks/     → ../skills/caveman/SKILL.md    (legacy)

Updated stale __dirname comment from hooks/ to src/hooks/.

Closes JuliusBrussee#467
The fix shipped with no automated test. Adds tests/test_activate_skillmd_path.js
spawning the real hook and asserting it loads the full SKILL.md ruleset, not the
weak hardcoded fallback.

- activation loads full SKILL.md: asserts `## Intensity` (SKILL.md-only) is in
  the output. RED when the candidate path is reverted to the stale `../skills`
  (src/hooks → src/skills, absent) — the hook drops to the fallback.
- intensity table filtered to active level: `| **full** |` kept, `| **lite** |`
  dropped, proving the loaded file is actually parsed.

node tests/test_activate_skillmd_path.js → 2 passed (revert: 2 failed, fallback).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Claude Code SessionStart activation hook silently falling back to the hardcoded rules because skills/caveman/SKILL.md was no longer found after the src/ restructure (hook moved under src/hooks/).

Changes:

  • Update src/hooks/caveman-activate.js to probe multiple candidate SKILL.md paths (current + legacy layout) before falling back.
  • Add a regression test that executes the real hook and asserts the output contains SKILL.md-only content (the ## Intensity section + correct row filtering).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/hooks/caveman-activate.js Tries multiple SKILL.md locations to avoid silent fallback after hook path changes.
tests/test_activate_skillmd_path.js Adds an executable Node-based test verifying SKILL.md is actually loaded and intensity table filtering works.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/caveman-activate.js
Comment thread tests/test_activate_skillmd_path.js Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code SessionStart hook serves weak fallback — src/hooks/ SKILL.md path off by one

2 participants