Skip to content

Module 01 / Lesson 03

Replace Outdated API Guesses with Context7 and Repomix

Module 01 · Real-World ContextStep 03 of 03

Never ask an AI to write code until you have defined what success and failure look like.

Imagine your payment or messaging service degrades during peak hours. You need your team to publish an urgent incident notice to customers. If you ask an AI coding agent with a vague prompt like "build a status page with a publish button", it quickly outputs a flashy mockup with billing tabs and animations you never requested, but clicking Publish does not actually save or update anything.

Narrated lesson · 1:48
Read the narration transcript

The example looks right until the build runs

The new route needs the signed-in user. The agent remembers an older Supabase auth helper. It looks like real code because it used to be a real API in another setup.

Now the build cannot resolve the import. Before adding a package, read the lockfile and the server helper this project already uses. That tells you where the example and the repo first disagreed.

Cross-check three sources

Start with the lockfile and the server client in this repo. Context Seven can fetch the official docs when you tell it the package and version. Compare that reference with what's installed.

Second, read the existing server auth helper. Check how it is called. A browser sign-in example will not answer a question about the server publish action.

Third, open the official docs for your version and confirm the signature. Give the agent the matching reference along with the local path.

Fetch the small piece of context you need

I start with package versions and the existing server helper. The version in front of me is the one that matters, even if the agent remembers a newer example.

Context Seven can run as a skill plus command-line tool, so the agent calls it when it needs documentation. Keep company secrets out of that request. The hosted index has quotas.

For a public reference repo, Repomix can pack a small excerpt. I review the output before sharing it and leave untrusted remote config disabled. To find a file in this project, ordinary search is usually enough.

Verify the type and the user path

Run the type check. That proves the project can use that import. It leaves the runtime behavior open.

Open the route as a signed-in operator, then without a session. Record both outcomes. The best evidence fits the existing project and confirms the behavior the user actually needs.

The everyday problem

The agent adds an auth import to the status app and says it’s done. The code looks like other Supabase examples, but pnpm build says the imported package cannot be resolved. The example came from a different setup. Before changing the lockfile, check the version your project actually runs.

This lesson asks three different questions: where your auth helper lives, how the current package is called, and which part of a public reference project is worth studying. Each answer needs a different source.

Why the agent got it wrong

The agent knows patterns it has seen. It may combine an older Next.js cookie API with current Supabase code because both are familiar. A current vendor page can also describe a different version from the one installed in your checkout. Genuine documentation can still be the wrong evidence for this patch.

package.json expresses a dependency range. The lockfile records the resolved dependency version for the install. Inspect both the current helper and the resolved package before deciding to create or upgrade anything.

The tool and technique

Search the local repo for src/lib/supabase/server.ts and its callers. Use Context7 to retrieve documentation for the installed package version when it adds value. The CLI plus skill mode can fetch docs on demand. For a public example repository, Repomix can produce a small, reviewable bundle of matching files.

Use those sources in order. The repo tells you the current behavior, the documentation tells you the supported API, and the public reference illustrates another implementation. A reference excerpt should never become evidence that this checkout runs the same dependencies.

Look up a specific API version

Find the installed package first. Use Context7 for a version-specific reference if your client needs help fetching official docs. Use Repomix when you need a compact snapshot of selected files from a public reference repo. For your own repo, a local file search can get directly to the server helper.

pnpm list @supabase/ssr next --depth 0
npx ctx7 setup

Read src/lib/supabase/server.ts. Find the official docs for the installed
@supabase/ssr version and compare its cookie API with our helper.

# In a reviewed local checkout of a public reference repository
npx repomix --include "src/lib/supabase/**"

Check the import and call signature in the installed version and run the project’s build. Context7 uses a hosted index with quotas. Keep private details out of queries. Repomix can scan for secrets, but still review the output and leave remote repository configuration untrusted.

On screen in the status app

In the before example, the first proposal reaches for @supabase/auth-helpers-nextjs, a historical package. The current sample uses @supabase/ssr inside an existing server helper. Ask the agent to identify the installed Next.js and Supabase versions and show the cookie methods that helper expects.

Run npx ctx7 setup when you want its documented integration. In a reviewed public checkout, scope the Repomix include pattern to the relevant helpers. Read the output before you share it, especially if the repo has hidden setup files, local fixtures, or tracked credentials. For the private status app itself, ordinary repo search is enough.

src/lib/supabase/server.ts

Before

import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'
// Agent copied an older auth example without checking dependencies.

After

Check: pnpm list @supabase/ssr next --depth 0
Find: the server client already called by the publish action
Confirm: the installed @supabase/ssr API and this Next.js version’s cookie interface
Change: reuse the existing server helper, with no dependency upgrade in this patch
Verify: pnpm build, then check the signed-in publish path with a seeded account

What to watch for

Context7 uses a hosted index with quotas. Keep tokens, customer IDs, and repository contents out of the query. Check the version reported by the result and go directly to the vendor docs or installed package when the index lacks the version you need.

Leave remote config trust disabled for unfamiliar Repomix sources. Its secret scan can help flag content you should remove. Treat the packed output like a file you are about to share. Check which files are in it and which context may be missing before relying on it.

How you know it worked

Check the import and call signature in the existing helper, run the project’s build, and exercise the same sign-in and publish path with a seeded account. A passing build proves the code integrates with the installed types. The signed-in browser path confirms the runtime session reaches the route.

If you find an API mismatch, choose a compatible call or write a separate upgrade proposal with its own checks. Record the installed versions and source link in the review. That evidence is more actionable than saving a large chat log.

References