CLI and observability

Install, link, and pull configuration

Connect a local directory to the intended Vercel project and retrieve Development configuration without committing local project metadata or secrets blindly.

Everything we did in the dashboard so far, the Vercel CLI can do from the terminal. It can also do one thing the dashboard can’t: pull environment variables onto your machine so npm run dev works with the same names Production uses.

Before it can do anything, the CLI needs to know which project this folder is. That’s what linking does.

Install and log in

I run the CLI through npx so I always get the current version without a global install:

npx vercel@latest login
npx vercel@latest whoami

whoami prints your username. If you belong to several teams, this matters in a moment.

From the Field Notes directory, run:

npx vercel@latest link

The CLI asks which scope to use and whether to link to an existing project. Pick the same team and the field-notes project you imported earlier. It then writes a .vercel folder with a project.json file:

{
  "orgId": "team_9Xk2mQ7pL4nR8sT1vW3yZ5aB",
  "projectId": "prj_4Fh8Jk2Lm9Np3Qr7St1Uv5Wx6Yz"
}

Open that file and check both ids against the dashboard. This is not paranoia. If you copy a folder from another repository, the old .vercel comes with it, and every deploy from there quietly goes to the wrong project while the terminal reports success.

The CLI adds .vercel to .gitignore for you. Keep it there.

Pull the Development variables

Now fetch the variables scoped to Development into a local file:

npx vercel@latest env pull .env.local

The output confirms the download and the environment. Open .env.local to review the names, but don’t paste its contents into a chat or a ticket. .env.local is in .gitignore by default in a Next.js project. Verify that with git status --ignored, where both .vercel/ and .env.local should appear under the ignored files.

One thing to remember: env pull is a snapshot. It doesn’t sync. When someone adds a variable in the dashboard, pull again, or your local app fails on a name Production has and you don’t.

Try this on your own project: link Field Notes, compare the ids in .vercel/project.json with the dashboard, pull the Development values, and run git status --ignored before you start the dev server.

Lesson completed