Skip to content

feat(hooks): SessionStart hook auto-injects Purchasely skill pointers#5

Merged
kherembourg merged 1 commit into
mainfrom
feat/session-start-hook
May 19, 2026
Merged

feat(hooks): SessionStart hook auto-injects Purchasely skill pointers#5
kherembourg merged 1 commit into
mainfrom
feat/session-start-hook

Conversation

@kherembourg
Copy link
Copy Markdown
Contributor

Objectif

Ajouter un hook SessionStart qui injecte automatiquement un court pointer vers les skills Purchasely (integrate, review, debug) et la commande /purchasely:question à chaque démarrage de session, sur le modèle d'obra/superpowers/hooks/.

Sans ce hook, l'utilisateur doit explicitement taper /purchasely:question ou nommer la skill ; avec, Claude / Cursor / Copilot CLI savent que le plugin est disponible dès le démarrage.

Fichiers ajoutés

Fichier Rôle
hooks/hooks.json Config hook Claude Code (matcher: "startup|clear|compact")
hooks/hooks-cursor.json Équivalent Cursor (sessionStart)
hooks/session-start Script POSIX shell (zero-dep) qui émet le contexte au format attendu par le host
hooks/run-hook.cmd Wrapper polyglotte cmd/bash pour Windows (Git Bash / WSL)
hooks/intro.md Texte court (~25 lignes) listant les skills + slash command
.claude-plugin/plugin.json Pointe vers ./hooks/hooks.json

Détection du format de sortie

Le script session-start détecte le host via variables d'environnement et émet :

  • Claude Code (CLAUDECODE=1 ou CLAUDE_PLUGIN_ROOT défini) → {"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "..."}}
  • Cursor (CURSOR_AGENT ou CURSOR_TRACE_ID) → {"additional_context": "..."}
  • Standard SDK (défaut) → {"additionalContext": "..."}

Contenu injecté

Court paragraphe + bullet list pointant vers les 3 skills et la slash command — pas un dump du contenu des skills, juste un signal que le playbook existe. Voir hooks/intro.md. ~25 lignes.

Tests locaux

$ CLAUDECODE=1 hooks/session-start | python3 -m json.tool
{
    "hookSpecificOutput": {
        "hookEventName": "SessionStart",
        "additionalContext": "..."
    }
}

$ CURSOR_AGENT=1 hooks/session-start | python3 -m json.tool
{ "additional_context": "..." }

$ hooks/session-start | python3 -m json.tool
{ "additionalContext": "..." }

Tous valident comme JSON correct.

Acceptance criteria

  • Hook testé manuellement, sort du JSON valide dans les 3 formats.
  • Zero dépendance externe (/bin/sh + awk POSIX).
  • Fonctionne sur macOS, Linux, et Windows via le wrapper polyglotte (Git Bash / WSL côté Windows — détection avec fallback).
  • CHANGELOG.md mis à jour : ### AddedSessionStart hook auto-injects Purchasely skill pointers.

Generated by Claude Code

@kherembourg kherembourg force-pushed the feat/session-start-hook branch 2 times, most recently from 724648c to d5952b3 Compare May 19, 2026 19:01
…inters

Lets Claude/Cursor/Copilot CLI know the integrate/review/debug skills and
/purchasely:question command exist as soon as a session starts, without the
user having to type a slash command first.

Files:
- hooks/hooks.json         — Claude Code plugin hook config (startup|clear|compact)
- hooks/hooks-cursor.json  — Cursor hook config
- hooks/session-start      — POSIX shell script, zero deps, emits JSON in the
                              correct envelope per host (Claude Code's
                              hookSpecificOutput, Cursor's additional_context,
                              or the generic additionalContext)
- hooks/run-hook.cmd       — polyglot cmd/bash wrapper for Windows (Git Bash/WSL)
- hooks/intro.md           — short pointer text injected into context
- .claude-plugin/plugin.json — references hooks/hooks.json

Tested locally: all three output envelopes produce valid JSON.
@kherembourg kherembourg force-pushed the feat/session-start-hook branch from d5952b3 to d3e617d Compare May 19, 2026 19:11
@kherembourg kherembourg merged commit 327591f into main May 19, 2026
9 checks passed
@kherembourg kherembourg deleted the feat/session-start-hook branch May 19, 2026 19:12
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.

2 participants