Skip to content

feat: add SessionStart hook for early auth/scope and project-existence warning#75

Merged
gringolito merged 1 commit into
masterfrom
feat/session-start-hook-39
May 24, 2026
Merged

feat: add SessionStart hook for early auth/scope and project-existence warning#75
gringolito merged 1 commit into
masterfrom
feat/session-start-hook-39

Conversation

@gringolito
Copy link
Copy Markdown
Owner

Closes #39

Summary

  • Adds scripts/session-start-check.sh — runs at session start in any repo with .claude/backlog-project.json; silently exits if the file is absent (no noise in unrelated repos)
  • Registers it in hooks/hooks.json as a SessionStart hook via ${CLAUDE_PLUGIN_ROOT}/scripts/session-start-check.sh
  • Always exits 0 — warns but never blocks the session

What the hook checks

Check 1 — required token scopes: parses gh auth status --hostname github.com and verifies repo, project, read:user are present (plus read:org when the project owner is a GitHub organisation). On failure, emits a banner naming the missing scopes and the exact gh auth refresh --scopes … command.

Check 2 — project still exists: queries the live project ID via gh project view and compares it against the stored project_id from .claude/backlog-project.json. On mismatch or missing project, emits a banner with the remediation (/initialize-backlog or delete the metadata file).

Acceptance Criteria

AC Status
scripts/session-start-check.sh exists, executable, #!/usr/bin/env bash shebang
hooks/hooks.json registers a SessionStart hook invoking the script
Silent when no .claude/backlog-project.json present ✅ tested
Silent when token fully scoped + project exists ✅ (happy path verified)
Missing scope → banner + exact gh auth refresh … command ✅ tested
Wrong project_id → banner + remediation message ✅ (code path verified)
Both failure cases exit 0 ✅ tested
Banner appears at session start, before any prompt ✅ (SessionStart fires before user input)

Note: The scratch-repo smoke test (claude --debug shows hook registered) and the missing-project-id path require a live install and are not automatable in CI — verify manually before merging.

🤖 Generated with Claude Code

…e warning

Adds scripts/session-start-check.sh that runs at session start in any
repo with .claude/backlog-project.json. Checks two failure conditions
and emits a warning banner with a copy-paste fix command for each:

1. Missing required token scopes (repo, project, read:user; read:org
   when the project owner is a GitHub organisation).
2. Configured project missing or project_id mismatch, indicating the
   Project was deleted or re-created since initialize-backlog ran.

Hook is registered in hooks/hooks.json as a SessionStart command.
Always exits 0 — warns but never blocks the session.

Refs #39

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gringolito gringolito added this to the v0.3.0 milestone May 23, 2026
@gringolito gringolito self-assigned this May 23, 2026
@gringolito gringolito merged commit b83fac1 into master May 24, 2026
1 check passed
@gringolito gringolito deleted the feat/session-start-hook-39 branch May 24, 2026 00:06
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.

Add SessionStart hook for early auth/scope and project-existence warning

1 participant