Skip to content

Feature: make SessionStart knowledge graph injection opt-in or on-demand #12

@mark-c4r

Description

@mark-c4r

Problem

The inject-claude-md.mjs SessionStart hook injects the full Vercel ecosystem knowledge graph (~19k tokens) on every session event (startup|resume|clear|compact), regardless of whether the session will touch Vercel-related code.

For users working across multiple projects (some Vercel, some not), this is a fixed ~19k token cost on every session — even when the session is pure backend work, data science, or non-Vercel frontend.

Current behavior

SessionStart (startup|resume|clear|compact)
  → inject-claude-md.mjs fires
  → Full vercel.md (~19k tokens) injected into conversation
  → Always, unconditionally

Desired behavior

A configuration option to control this injection. For example:

# Environment variable
VERCEL_PLUGIN_SESSION_INJECT=off  # skip SessionStart injection

# Or a config in plugin settings
{ "sessionStartInject": "on-demand" }

When disabled, the plugin would still work via the existing on-demand hooks:

  • PreToolUse skill injection (fires when reading/editing Vercel-related files)
  • UserPromptSubmit skill injection (fires when the user's prompt mentions Vercel topics)

These on-demand hooks already provide excellent coverage — they inject the right skill at the right time. The SessionStart dump is redundant for sessions that trigger these hooks, and wasteful for sessions that don't.

Impact

  • 1M context models: ~2% — tolerable but unnecessary
  • 200k context models: ~10% — significant baseline cost
  • Sessions per day: Multiplied across every session start, resume, clear, and compact event

Suggested approaches

  1. Environment variable toggle (VERCEL_PLUGIN_SESSION_INJECT=off) — simplest, user controls it
  2. Project-level detection — skip injection if no vercel.json, next.config.*, or .vercel/ in the working directory
  3. Lazy injection — defer the knowledge graph until the first Vercel-related PreToolUse or UserPromptSubmit match, then inject once per session

Option 3 would be the best UX — zero config, zero waste, same coverage.

Environment

  • Plugin version: 0.22.1
  • Claude Code with 1M context (claude-opus-4-6)
  • Working directory contains both Vercel and non-Vercel projects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions