vercel / vercel/vercel-plugin

Greenfield detection activates plugin for all empty directories, ignoring Vercel markers

Open
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
287
Forks
58
Avg merge
1d 1h
Merged PRs (30d)
17

Description

Bug Description

The Vercel plugin's session-start-profiler.mjs and inject-claude-md.mjs hooks activate for any empty directory, even when the directory has no relation to Vercel. The greenfield detection bypasses the Vercel-specific activation marker check.

Root Cause

In session-start-activation.mjs, isGreenfieldDirectory() returns true for any directory without non-dot files:

function isGreenfieldDirectory(projectRoot) {
  const hasNonDotDir = dirents.some(d => !d.name.startsWith("."));
  const hasDotFile = dirents.some(d => d.name.startsWith(".") && d.isFile());
  return !hasNonDotDir && !hasDotFile;
}

Then in session-start-profiler.mjs:413:

const shouldActivate = greenfield !== null || !existsSync(projectRoot) || hasSessionStartActivationMarkers(projectRoot);

The greenfield !== null check comes before hasSessionStartActivationMarkers, so any empty directory activates the plugin regardless of whether it's a Vercel project.

Same in inject-claude-md.mjs:65:

const shouldActivate = isGreenfield || greenfieldOverride || ...

Impact

  • Non-Vercel empty directories get Vercel-specific context injected ("greenfield execution mode", "skip exploration", Vercel CLI install recommendations)
  • This happens even when the plugin is disabled via enabledPlugins: false (separate Claude Code bug)
  • Pollutes the conversation context with irrelevant Vercel guidance
  • Default skills are set to ["nextjs", "ai-sdk", "vercel-cli", "env-vars"] for ANY empty folder

Suggested Fix

The greenfield check should be combined with the activation marker check, not bypass it. If a directory is empty AND there are no Vercel signals, the plugin should not activate.

// Option: only treat as greenfield if there's at least one Vercel signal
const shouldActivate = hasSessionStartActivationMarkers(projectRoot) 
  || (greenfield !== null && hasVercelSignal(projectRoot));

Or at minimum, respect the enabledPlugins setting before running any hook logic.

Environment

  • Platform: Windows 10 Pro
  • Plugin version: 0.40.0
  • Claude Code: latest

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with isGreenfieldDirectory() in session-start-activation.mjs, then compare the activation decisions in session-start-profiler.mjs around line 413 and inject-claude-md.mjs around line 65. Verify that an empty non-Vercel directory does not activate the hooks, while directories with Vercel activation markers still receive the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.