Skip to main content

CodeLens — Usage Count

CodeLens adds a clickable annotation above every variable line in your .env files showing how many source files reference that variable.

What You See

When you open any .env* file, each variable line shows an inline annotation:

# used in 3 files ← click to find usages
DATABASE_URL=postgres://...

# ⚠ never referenced in source
LEGACY_API_KEY=old-key

Clicking the Annotation

Clicking "used in N files" runs Find All Usages by Key, which opens the References panel listing every file and line number where that variable is used.

Clicking "⚠ never referenced" does the same — it may return no results, confirming the variable is unused. This is useful for cleaning up stale variables.

How the Cache Works

The usage count is computed by scanning all non-binary source files in your workspace for process.env.KEY and import.meta.env.KEY patterns. The results are cached in memory and invalidated whenever:

  • A .env* file changes
  • You run Refresh Files

The first scan after opening a workspace may take a moment on large codebases; subsequent lookups are instant from cache.

Performance

Files and directories excluded from the scan: node_modules, .git, dist, build, .next, out, vendor, __pycache__, .turbo.

Binary files (images, fonts, archives) are automatically skipped.